[FFmpeg-devel] [PATCH v2 1/3] avcodec/jpegxl_parser: add JPEG XL parser

James Almer jamrial at gmail.com
Thu Jun 22 04:21:25 EEST 2023


On 6/21/2023 10:06 PM, Leo Izen wrote:
> On 6/21/23 20:59, James Almer wrote:
>> On 6/21/2023 9:43 PM, Leo Izen wrote:
>>> diff --git a/libavcodec/jpegxl_parse.c b/libavcodec/jpegxl_parse.c
>>> new file mode 100644
>>> index 0000000000..be360acb08
>>> --- /dev/null
>>> +++ b/libavcodec/jpegxl_parse.c
>>> @@ -0,0 +1,22 @@
>>> +/*
>>> + * JPEG XL Header Parser
>>> + * Copyright (c) 2023 Leo Izen<leo.izen at gmail.com>
>>> + *
>>> + * This file is part of FFmpeg.
>>> + *
>>> + * FFmpeg is free software; you can redistribute it and/or
>>> + * modify it under the terms of the GNU Lesser General Public
>>> + * License as published by the Free Software Foundation; either
>>> + * version 2.1 of the License, or (at your option) any later version.
>>> + *
>>> + * FFmpeg is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * Lesser General Public License for more details.
>>> + *
>>> + * You should have received a copy of the GNU Lesser General Public
>>> + * License along with FFmpeg; if not, write to the Free Software
>>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
>>> 02110-1301 USA
>>> + */
>>> +
>>> +#include "jpegxl_parse.h"
>>
>> This is a really weird way to achieve code sharing between libraries.
>> What you named jpegxl_parse.h should be jpegxl_parse.c instead, and 
>> jpegxl_parse.h should only have the prototypes for 
>> ff_jpegxl_collect_codestream_header() and 
>> ff_jpegxl_parse_codestream_header(), plus the definition of 
>> FFJXLMetadata. The enums can stay in jpegxl.h, and they for that 
>> matter don't need the FF_ prefix.
> 
> 
> This is based on JEEB's recommendation. He provided these as examples:
> 
> https://github.com/jeeb/ffmpeg/commit/b74e47c4ff5bca998936c0d8b9a0892104a7403d
> https://github.com/jeeb/ffmpeg/commit/d7a75d21635eab4f4a1efea22945933059c2e36f
> 
> How else should I do it? If I do the usual thing where I put prototypes 
> and structs in the header file and the implementation in the C file, 
> then I won't be able to compile them into avformat as well, as it will 
> just grab the stubs, and the ff_funcs won't be exported from avcodec.

Create a jpegxl_parse.c file in libavformat with the only line being

#include "libavcodec/jpegxl_parse.c"

Then add jpegxl_parse.o to SHLIBOBJS-$(CONFIG_JPEGXL_ANIM_DEMUXER) in 
libavformat/Makefile.
You can remove jpegxl_parse.o from libavcodec's STLIBOBJS list too.


More information about the ffmpeg-devel mailing list