[FFmpeg-devel] [PATCH 4/5] avormat/av1dec: add low-overhead bitstream format

James Almer jamrial at gmail.com
Thu Aug 6 20:39:22 EEST 2020


On 8/6/2020 12:40 PM, Xu, Guangxin wrote:
> 
> 
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of James
>> Almer
>> Sent: Thursday, August 6, 2020 10:09 PM
>> To: ffmpeg-devel at ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH 4/5] avormat/av1dec: add low-overhead
>> bitstream format
>>
>> On 8/6/2020 5:04 AM, Xu Guangxin wrote:
>>> It's defined in Section 5.2, used by netflix.
>>> see http://download.opencontent.netflix.com/?prefix=AV1/Chimera/
>>> ---
>>>  libavformat/allformats.c |   1 +
>>>  libavformat/av1dec.c     | 193
>> +++++++++++++++++++++++++++++++++++++--
>>>  2 files changed, 185 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/libavformat/allformats.c b/libavformat/allformats.c index
>>> fd9e46e233..8eead5619d 100644
>>> --- a/libavformat/allformats.c
>>> +++ b/libavformat/allformats.c
>>> @@ -75,6 +75,7 @@ extern AVOutputFormat ff_asf_stream_muxer;  extern
>>> AVInputFormat  ff_au_demuxer;  extern AVOutputFormat ff_au_muxer;
>>> extern AVInputFormat  ff_av1_demuxer;
>>> +extern AVInputFormat  ff_av1_low_overhead_demuxer;
>>
>> How about ff_obu_demuxer instead?
>>
>>>  extern AVInputFormat  ff_avi_demuxer;  extern AVOutputFormat
>>> ff_avi_muxer;  extern AVInputFormat  ff_avisynth_demuxer; diff --git
>>> a/libavformat/av1dec.c b/libavformat/av1dec.c index
>>> ec66152e03..0c5d172a0f 100644
>>> --- a/libavformat/av1dec.c
>>> +++ b/libavformat/av1dec.c
>>> @@ -28,6 +28,9 @@
>>>  #include "avio_internal.h"
>>>  #include "internal.h"
>>>
>>> +//2 + max leb 128 size
>>> +#define MAX_HEAD_SIZE 10
>>
>> This value is also used in av1_parse.h, so you could put it there and reuse it. But
>> if you do, use a less generic name, like MAX_OBU_HEADER_SIZE.
>>
>>> +
>>>  typedef struct AnnexBContext {
>>>      const AVClass *class;
>>>      AVBSFContext *bsf;
>>> @@ -139,9 +142,8 @@ static int annexb_probe(const AVProbeData *p)
>>>      return 0;
>>>  }
>>>
>>> -static int annexb_read_header(AVFormatContext *s)
>>> +static int read_header(AVFormatContext *s, AVRational framerate,
>>> +AVBSFContext **bsf, void *c)
>>
>> Since c is now a log context, rename it to logctx.
>>
>>>  {
>>> -    AnnexBContext *c = s->priv_data;
>>>      const AVBitStreamFilter *filter =
>> av_bsf_get_by_name("av1_frame_merge");
>>>      AVStream *st;
>>>      int ret;
>>> @@ -160,25 +162,32 @@ static int annexb_read_header(AVFormatContext
>> *s)
>>>      st->codecpar->codec_id = AV_CODEC_ID_AV1;
>>>      st->need_parsing = AVSTREAM_PARSE_HEADERS;
>>>
>>> -    st->internal->avctx->framerate = c->framerate;
>>> +    st->internal->avctx->framerate = framerate;
>>>      // taken from rawvideo demuxers
>>>      avpriv_set_pts_info(st, 64, 1, 1200000);
>>>
>>> -    ret = av_bsf_alloc(filter, &c->bsf);
>>> +    ret = av_bsf_alloc(filter, bsf);
>>
>> If it requires this bsf, then it should be added as a depencency to configure.
> Could you explain more about this.
> The entire function is from original code, I just changed some signature.
> thanks

You're using the av1_frame_merge bitstream filter to assemble temporal
units. This means this demuxer depends on its presence to work.
This needs to be signaled in configure so, in any build where this
demuxer is present, the bsf will also be present.
For the annexb demuxer, this was done with the line:

av1_demuxer_select="av1_frame_merge_bsf av1_parser"

Which also ensures the av1 parser is present. For this new demuxer,
you'd do:

obu_demuxer_select="av1_frame_merge_bsf av1_parser"

(Assuming you change the name like i suggested).


More information about the ffmpeg-devel mailing list