[FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sat Dec 3 15:08:37 EET 2016


On 03.12.2016 13:39, Michael Niedermayer wrote:
> On Sat, Dec 03, 2016 at 12:47:45PM +0100, Andreas Cadhalpun wrote:
>> On 03.12.2016 00:52, Michael Niedermayer wrote:
>>> @@ -400,16 +398,16 @@ static int ffm2_read_header(AVFormatContext *s)
>>>                  ret = AVERROR_INVALIDDATA;
>>>                  goto fail;
>>>              }
>>> -            codec->width = avio_rb16(pb);
>>> -            codec->height = avio_rb16(pb);
>>> -            ret = av_image_check_size(codec->width, codec->height, 0, s);
>>> +            codecpar->width = avio_rb16(pb);
>>> +            codecpar->height = avio_rb16(pb);
>>> +            ret = av_image_check_size(codecpar->width, codecpar->height, 0, s);
>>>              if (ret < 0)
>>>                  goto fail;
>>>              avio_rb16(pb);
>>> -            codec->pix_fmt = avio_rb32(pb);
>>> -            if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
>>> -                av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt);
>>> -                codec->pix_fmt = AV_PIX_FMT_NONE;
>>> +            codecpar->format = avio_rb32(pb);
>>
>> This change isn't as simple as it looks, because while the pix_fmt field exclusively
>> contains AVPixelFormat values, the format field is shared with AVSampleFormat.
>> Thus there now needs to be a check to ensure that codec_type is AVMEDIA_TYPE_VIDEO.
>>
>>> +            if (!av_pix_fmt_desc_get(codecpar->format)) {
>>> +                av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codecpar->format);
>>> +                codecpar->format = AV_PIX_FMT_NONE;
>>>                  goto fail;
>>>              }
>>>              avio_r8(pb);
>>
>>
> 
>>> @@ -610,15 +615,15 @@ static int ffm_read_header(AVFormatContext *s)
>>>                         codec->time_base.num, codec->time_base.den);
>>>                  goto fail;
>>>              }
>>> -            codec->width = avio_rb16(pb);
>>> -            codec->height = avio_rb16(pb);
>>> -            if (av_image_check_size(codec->width, codec->height, 0, s) < 0)
>>> +            codecpar->width = avio_rb16(pb);
>>> +            codecpar->height = avio_rb16(pb);
>>> +            if (av_image_check_size(codecpar->width, codecpar->height, 0, s) < 0)
>>>                  goto fail;
>>>              avio_rb16(pb);
>>> -            codec->pix_fmt = avio_rb32(pb);
>>> -            if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
>>> -                av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt);
>>> -                codec->pix_fmt = AV_PIX_FMT_NONE;
>>> +            codecpar->format = avio_rb32(pb);
>>
>> Same here.
> 
> not the same, this is under a codec_type check

Indeed.

Best regards,
Andreas



More information about the ffmpeg-devel mailing list