[FFmpeg-devel] [PATCH 1/3] avcodec/av1_metadata: filter parameter sets in packet side data

James Almer jamrial at gmail.com
Sun May 3 17:43:58 EEST 2020


On 4/22/2020 9:37 PM, Andreas Rheinhardt wrote:
> James Almer:
>> Extradata included in packet side data is meant to replace the codec context
>> extradata. So when muxing for example to MP4 without this change and if
>> extradata is present in a packet side data, the result will be that the
>> parameter sets present in keyframes will be filtered, but the parameter sets
>> ultimately included in the av1C box will not.
>>
>> This is especially important for AV1 as both currently supported encoders don't
>> export the Sequence Header in the codec context extradata, but as packet side
>> data instead.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>>  libavcodec/av1_metadata_bsf.c | 52 +++++++++++++++++++++++++++++++++++
>>  1 file changed, 52 insertions(+)
>>
>> diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
>> index dd0c9b6148..f3161cb286 100644
>> --- a/libavcodec/av1_metadata_bsf.c
>> +++ b/libavcodec/av1_metadata_bsf.c
>> @@ -111,6 +111,54 @@ static int av1_metadata_update_sequence_header(AVBSFContext *bsf,
>>      return 0;
>>  }
>>  
>> +static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
>> +{
>> +    AV1MetadataContext *ctx = bsf->priv_data;
>> +    CodedBitstreamFragment *frag = &ctx->access_unit;
>> +    AV1RawOBU *obu;
>> +    uint8_t *side_data;
>> +    int side_data_size;
>> +    int err, i;
>> +
>> +    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
>> +                                        &side_data_size);
>> +    if (!side_data_size)
>> +        return 0;
>> +
>> +    err = ff_cbs_read(ctx->cbc, frag, side_data, side_data_size);
>> +    if (err < 0) {
>> +        av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n");
>> +        goto fail;
> 
> You can actually return immediately in this whole function: The fragment
> will be reset in the fail part of av1_metadata_filter().

Changed and pushed, thanks.


More information about the ffmpeg-devel mailing list