[FFmpeg-devel] ffprobe: Initialize coded_width/height

Submitted by Zhong Li on Jan. 19, 2018, 5:05 a.m.

Details

Message ID 1516338355-1976-1-git-send-email-zhong.li@intel.com
State New
Headers show

Commit Message

Zhong Li Jan. 19, 2018, 5:05 a.m.
coded_width/height are unnitialized and will be overwritten by
dec_ctx->width/height in avcodec_open2()

This fixes tiket #6958.

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 fftools/ffprobe.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Hendrik Leppkes Jan. 19, 2018, 10:09 a.m.
On Fri, Jan 19, 2018 at 6:05 AM, Zhong Li <zhong.li@intel.com> wrote:
> coded_width/height are unnitialized and will be overwritten by
> dec_ctx->width/height in avcodec_open2()
>
> This fixes tiket #6958.
>
> Signed-off-by: Zhong Li <zhong.li@intel.com>
> ---
>  fftools/ffprobe.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 0e7a771..233760d 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
>      case AVMEDIA_TYPE_VIDEO:
>          print_int("width",        par->width);
>          print_int("height",       par->height);
> +#if FF_API_LAVF_AVCTX
>          if (dec_ctx) {
>              print_int("coded_width",  dec_ctx->coded_width);
>              print_int("coded_height", dec_ctx->coded_height);
>          }
> +#endif
>          print_int("has_b_frames", par->video_delay);
>          sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
>          if (sar.den) {
> @@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile, const char *filename)
>
>              ist->dec_ctx->pkt_timebase = stream->time_base;
>              ist->dec_ctx->framerate = stream->avg_frame_rate;
> +#if FF_API_LAVF_AVCTX
> +            ist->dec_ctx->coded_width = stream->codec->coded_width;
> +            ist->dec_ctx->coded_height = stream->codec->coded_height;
> +#endif
>
>              if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
>                  av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",

Lets not write new code based on deprecated API.

- Hendrik
Zhong Li Jan. 22, 2018, 3:38 a.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Hendrik Leppkes

> Sent: Friday, January 19, 2018 6:10 PM

> To: FFmpeg development discussions and patches

> <ffmpeg-devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH] ffprobe: Initialize coded_width/height

> 

> On Fri, Jan 19, 2018 at 6:05 AM, Zhong Li <zhong.li@intel.com> wrote:

> > coded_width/height are unnitialized and will be overwritten by

> > dec_ctx->width/height in avcodec_open2()

> >

> > This fixes tiket #6958.

> >

> > Signed-off-by: Zhong Li <zhong.li@intel.com>

> > ---

> >  fftools/ffprobe.c | 6 ++++++

> >  1 file changed, 6 insertions(+)

> >

> > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index

> > 0e7a771..233760d 100644

> > --- a/fftools/ffprobe.c

> > +++ b/fftools/ffprobe.c

> > @@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w,

> AVFormatContext *fmt_ctx, int stream_id

> >      case AVMEDIA_TYPE_VIDEO:

> >          print_int("width",        par->width);

> >          print_int("height",       par->height);

> > +#if FF_API_LAVF_AVCTX

> >          if (dec_ctx) {

> >              print_int("coded_width",  dec_ctx->coded_width);

> >              print_int("coded_height", dec_ctx->coded_height);

> >          }

> > +#endif

> >          print_int("has_b_frames", par->video_delay);

> >          sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);

> >          if (sar.den) {

> > @@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile,

> > const char *filename)

> >

> >              ist->dec_ctx->pkt_timebase = stream->time_base;

> >              ist->dec_ctx->framerate = stream->avg_frame_rate;

> > +#if FF_API_LAVF_AVCTX

> > +            ist->dec_ctx->coded_width =

> stream->codec->coded_width;

> > +            ist->dec_ctx->coded_height =

> stream->codec->coded_height;

> > +#endif

> >

> >              if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {

> >                  av_log(NULL, AV_LOG_WARNING, "Could not open

> codec

> > for input stream %d\n",

> 

> Lets not write new code based on deprecated API.

> 

> - Hendrik


Refer the discussion on https://patchwork.ffmpeg.org/patch/7342/
Zhong Li Jan. 25, 2018, 6:26 a.m.
> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> Behalf

> > Of Hendrik Leppkes

> > Sent: Friday, January 19, 2018 6:10 PM

> > To: FFmpeg development discussions and patches

> > <ffmpeg-devel@ffmpeg.org>

> > Subject: Re: [FFmpeg-devel] [PATCH] ffprobe: Initialize

> > coded_width/height

> >

> > On Fri, Jan 19, 2018 at 6:05 AM, Zhong Li <zhong.li@intel.com> wrote:

> > > coded_width/height are unnitialized and will be overwritten by

> > > dec_ctx->width/height in avcodec_open2()

> > >

> > > This fixes tiket #6958.

> > >

> > > Signed-off-by: Zhong Li <zhong.li@intel.com>

> > > ---

> > >  fftools/ffprobe.c | 6 ++++++

> > >  1 file changed, 6 insertions(+)

> > >

> > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index

> > > 0e7a771..233760d 100644

> > > --- a/fftools/ffprobe.c

> > > +++ b/fftools/ffprobe.c

> > > @@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w,

> > AVFormatContext *fmt_ctx, int stream_id

> > >      case AVMEDIA_TYPE_VIDEO:

> > >          print_int("width",        par->width);

> > >          print_int("height",       par->height);

> > > +#if FF_API_LAVF_AVCTX

> > >          if (dec_ctx) {

> > >              print_int("coded_width",  dec_ctx->coded_width);

> > >              print_int("coded_height", dec_ctx->coded_height);

> > >          }

> > > +#endif

> > >          print_int("has_b_frames", par->video_delay);

> > >          sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);

> > >          if (sar.den) {

> > > @@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile,

> > > const char *filename)

> > >

> > >              ist->dec_ctx->pkt_timebase = stream->time_base;

> > >              ist->dec_ctx->framerate = stream->avg_frame_rate;

> > > +#if FF_API_LAVF_AVCTX

> > > +            ist->dec_ctx->coded_width =

> > stream->codec->coded_width;

> > > +            ist->dec_ctx->coded_height =

> > stream->codec->coded_height;

> > > +#endif

> > >

> > >              if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {

> > >                  av_log(NULL, AV_LOG_WARNING, "Could not open

> > codec

> > > for input stream %d\n",

> >

> > Lets not write new code based on deprecated API.

> >

> > - Hendrik

> 

> Refer the discussion on https://patchwork.ffmpeg.org/patch/7342/


Ping? 
I am also ok just remove these two line to print coded_w/h (If this is the best way, I can update this patch), then we can close this ticket.
James Almer Feb. 2, 2018, 7:46 p.m.
On 1/25/2018 3:26 AM, Li, Zhong wrote:
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On
>> Behalf
>>> Of Hendrik Leppkes
>>> Sent: Friday, January 19, 2018 6:10 PM
>>> To: FFmpeg development discussions and patches
>>> <ffmpeg-devel@ffmpeg.org>
>>> Subject: Re: [FFmpeg-devel] [PATCH] ffprobe: Initialize
>>> coded_width/height
>>>
>>> On Fri, Jan 19, 2018 at 6:05 AM, Zhong Li <zhong.li@intel.com> wrote:
>>>> coded_width/height are unnitialized and will be overwritten by
>>>> dec_ctx->width/height in avcodec_open2()
>>>>
>>>> This fixes tiket #6958.
>>>>
>>>> Signed-off-by: Zhong Li <zhong.li@intel.com>
>>>> ---
>>>>  fftools/ffprobe.c | 6 ++++++
>>>>  1 file changed, 6 insertions(+)
>>>>
>>>> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index
>>>> 0e7a771..233760d 100644
>>>> --- a/fftools/ffprobe.c
>>>> +++ b/fftools/ffprobe.c
>>>> @@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w,
>>> AVFormatContext *fmt_ctx, int stream_id
>>>>      case AVMEDIA_TYPE_VIDEO:
>>>>          print_int("width",        par->width);
>>>>          print_int("height",       par->height);
>>>> +#if FF_API_LAVF_AVCTX
>>>>          if (dec_ctx) {
>>>>              print_int("coded_width",  dec_ctx->coded_width);
>>>>              print_int("coded_height", dec_ctx->coded_height);
>>>>          }
>>>> +#endif
>>>>          print_int("has_b_frames", par->video_delay);
>>>>          sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
>>>>          if (sar.den) {
>>>> @@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile,
>>>> const char *filename)
>>>>
>>>>              ist->dec_ctx->pkt_timebase = stream->time_base;
>>>>              ist->dec_ctx->framerate = stream->avg_frame_rate;
>>>> +#if FF_API_LAVF_AVCTX
>>>> +            ist->dec_ctx->coded_width =
>>> stream->codec->coded_width;
>>>> +            ist->dec_ctx->coded_height =
>>> stream->codec->coded_height;
>>>> +#endif
>>>>
>>>>              if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
>>>>                  av_log(NULL, AV_LOG_WARNING, "Could not open
>>> codec
>>>> for input stream %d\n",
>>>
>>> Lets not write new code based on deprecated API.
>>>
>>> - Hendrik
>>
>> Refer the discussion on https://patchwork.ffmpeg.org/patch/7342/
> 
> Ping? 
> I am also ok just remove these two line to print coded_w/h (If this is the best way, I can update this patch), then we can close this ticket.

Pushed as is. Removing the two lines after printing bogus values for
four releases is imo not nice. For starters, it can't be backported.

They will be removed alongside AVStream->codec in the future.
Derek Buitenhuis Feb. 2, 2018, 8:20 p.m.
On 2/2/2018 7:46 PM, James Almer wrote:
> Pushed as is. Removing the two lines after printing bogus values for
> four releases is imo not nice. For starters, it can't be backported.
> 
> They will be removed alongside AVStream->codec in the future.

fftools/ffprobe.c:2918:1: error: unknown type name 'FF_DISABLE_DEPRECATION_WARNINGS'

- Derek
James Almer Feb. 2, 2018, 8:49 p.m.
On 2/2/2018 5:20 PM, Derek Buitenhuis wrote:
> On 2/2/2018 7:46 PM, James Almer wrote:
>> Pushed as is. Removing the two lines after printing bogus values for
>> four releases is imo not nice. For starters, it can't be backported.
>>
>> They will be removed alongside AVStream->codec in the future.
> 
> fftools/ffprobe.c:2918:1: error: unknown type name 'FF_DISABLE_DEPRECATION_WARNINGS'
> 
> - Derek

What system? Works on Windows, apparently because compat/w32pthreads.h
pulls it, So guess I'll just remove it.

Sorry for the breakage.

Patch hide | download patch | download mbox

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 0e7a771..233760d 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2512,10 +2512,12 @@  static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
     case AVMEDIA_TYPE_VIDEO:
         print_int("width",        par->width);
         print_int("height",       par->height);
+#if FF_API_LAVF_AVCTX
         if (dec_ctx) {
             print_int("coded_width",  dec_ctx->coded_width);
             print_int("coded_height", dec_ctx->coded_height);
         }
+#endif
         print_int("has_b_frames", par->video_delay);
         sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
         if (sar.den) {
@@ -2912,6 +2914,10 @@  static int open_input_file(InputFile *ifile, const char *filename)
 
             ist->dec_ctx->pkt_timebase = stream->time_base;
             ist->dec_ctx->framerate = stream->avg_frame_rate;
+#if FF_API_LAVF_AVCTX
+            ist->dec_ctx->coded_width = stream->codec->coded_width;
+            ist->dec_ctx->coded_height = stream->codec->coded_height;
+#endif
 
             if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
                 av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",