[FFmpeg-devel] [PATCH v2 3/7] avformat/matroskadec: export Dynamic HDR10+ packet side data
James Almer
jamrial at gmail.com
Thu Mar 30 04:51:09 EEST 2023
On 3/29/2023 9:43 PM, Andreas Rheinhardt wrote:
>> @@ -3615,12 +3635,58 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska,
>> }
>>
>> static int matroska_parse_block_additional(MatroskaDemuxContext *matroska,
>> - AVPacket *pkt,
>> + MatroskaTrack *track, AVPacket *pkt,
>> const uint8_t *data, int size, uint64_t id)
>> {
>> - uint8_t *side_data = av_packet_new_side_data(pkt,
>> - AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
>> - size + 8);
>> + uint8_t *side_data;
>> + int res;
>> +
>> + switch (id) {
>> + case 4: {
>> + GetByteContext bc;
>> + int country_code, provider_code;
>> + int provider_oriented_code, application_identifier;
>> + size_t hdrplus_size;
>> + AVDynamicHDRPlus *hdrplus;
>> +
>> + if (!track->blockaddid_itu_t_t35)
>> + break; //ignore
>> +
>> + bytestream2_init(&bc, data, size);
>> +
>> + /* ITU-T T.35 metadata */
>> + country_code = bytestream2_get_byte(&bc);
>> + provider_code = bytestream2_get_be16(&bc);
> This will add implicit overread checks; but you should check size
> explicitly instead.
> (The current behaviour of the bytestream2 API is to return 0 upon
> overreads; yet one should not rely on this and it could e.g. be changed
> so that bytestream2_get_byte returns 0xB5 and bytestream2_get_be16 0x3C
> upon overread.)
The only reason I'm using bytestream2 here was to not do a size check,
as Anton suggested.
Added one in any case, as well as using the u variants of
bytestream2_get_* since it will not overread now.
More information about the ffmpeg-devel
mailing list