[FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar
Michael Niedermayer
michael at niedermayer.cc
Sat Dec 3 14:39:36 EET 2016
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
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161203/0649cf4c/attachment.sig>
More information about the ffmpeg-devel
mailing list