diff mbox

[FFmpeg-devel,5/5] avformat/ffmdec: remove last use of st->codec

Message ID 20161202235258.26223-5-michael@niedermayer.cc
State Accepted
Headers show

Commit Message

Michael Niedermayer Dec. 2, 2016, 11:52 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/ffmdec.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

Comments

Andreas Cadhalpun Dec. 3, 2016, 11:51 a.m. UTC | #1
On 03.12.2016 00:52, Michael Niedermayer wrote:
> @@ -364,14 +364,19 @@ static int ffm2_read_header(AVFormatContext *s)
>              }
>              codecpar->bit_rate = avio_rb32(pb);
>              if (codecpar->bit_rate < 0) {
> -                av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
> +                av_log(s, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
>                  ret = AVERROR_INVALIDDATA;
>                  goto fail;
>              }
> -            codec->flags = avio_rb32(pb);
> +            flags = avio_rb32(pb);
> +#if FF_API_LAVF_AVCTX
> +FF_DISABLE_DEPRECATION_WARNINGS
> +            st->codec->flags = flags;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif

What's the point of this? It doesn't seem to be needed by ffserver.

Best regards,
Andreas
Michael Niedermayer Dec. 3, 2016, 12:14 p.m. UTC | #2
On Sat, Dec 03, 2016 at 12:51:12PM +0100, Andreas Cadhalpun wrote:
> On 03.12.2016 00:52, Michael Niedermayer wrote:
> > @@ -364,14 +364,19 @@ static int ffm2_read_header(AVFormatContext *s)
> >              }
> >              codecpar->bit_rate = avio_rb32(pb);
> >              if (codecpar->bit_rate < 0) {
> > -                av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
> > +                av_log(s, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
> >                  ret = AVERROR_INVALIDDATA;
> >                  goto fail;
> >              }
> > -            codec->flags = avio_rb32(pb);
> > +            flags = avio_rb32(pb);
> > +#if FF_API_LAVF_AVCTX
> > +FF_DISABLE_DEPRECATION_WARNINGS
> > +            st->codec->flags = flags;
> > +FF_ENABLE_DEPRECATION_WARNINGS
> > +#endif
> 
> What's the point of this? It doesn't seem to be needed by ffserver.

not by the current one but by the one a few commits ago

[...]
Andreas Cadhalpun Dec. 3, 2016, 1:03 p.m. UTC | #3
On 03.12.2016 13:14, Michael Niedermayer wrote:
> On Sat, Dec 03, 2016 at 12:51:12PM +0100, Andreas Cadhalpun wrote:
>> On 03.12.2016 00:52, Michael Niedermayer wrote:
>>> @@ -364,14 +364,19 @@ static int ffm2_read_header(AVFormatContext *s)
>>>              }
>>>              codecpar->bit_rate = avio_rb32(pb);
>>>              if (codecpar->bit_rate < 0) {
>>> -                av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
>>> +                av_log(s, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
>>>                  ret = AVERROR_INVALIDDATA;
>>>                  goto fail;
>>>              }
>>> -            codec->flags = avio_rb32(pb);
>>> +            flags = avio_rb32(pb);
>>> +#if FF_API_LAVF_AVCTX
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +            st->codec->flags = flags;
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>
>> What's the point of this? It doesn't seem to be needed by ffserver.
> 
> not by the current one but by the one a few commits ago

I see, commit 311107. Patch is OK.

Best regards,
Andreas
Michael Niedermayer Dec. 3, 2016, 1:09 p.m. UTC | #4
On Sat, Dec 03, 2016 at 02:03:22PM +0100, Andreas Cadhalpun wrote:
> On 03.12.2016 13:14, Michael Niedermayer wrote:
> > On Sat, Dec 03, 2016 at 12:51:12PM +0100, Andreas Cadhalpun wrote:
> >> On 03.12.2016 00:52, Michael Niedermayer wrote:
> >>> @@ -364,14 +364,19 @@ static int ffm2_read_header(AVFormatContext *s)
> >>>              }
> >>>              codecpar->bit_rate = avio_rb32(pb);
> >>>              if (codecpar->bit_rate < 0) {
> >>> -                av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
> >>> +                av_log(s, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
> >>>                  ret = AVERROR_INVALIDDATA;
> >>>                  goto fail;
> >>>              }
> >>> -            codec->flags = avio_rb32(pb);
> >>> +            flags = avio_rb32(pb);
> >>> +#if FF_API_LAVF_AVCTX
> >>> +FF_DISABLE_DEPRECATION_WARNINGS
> >>> +            st->codec->flags = flags;
> >>> +FF_ENABLE_DEPRECATION_WARNINGS
> >>> +#endif
> >>
> >> What's the point of this? It doesn't seem to be needed by ffserver.
> > 
> > not by the current one but by the one a few commits ago
> 
> I see, commit 311107. Patch is OK.

applied

thx

[...]
diff mbox

Patch

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index f3497e2b24..9b9373eae5 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -276,7 +276,7 @@  static int ffm_append_recommended_configuration(AVStream *st, char **conf)
 
 #define VALIDATE_PARAMETER(parameter, name, check) {                              \
     if (check) {                                                                  \
-        av_log(codec, AV_LOG_ERROR, "Invalid " name " %d\n", codecpar->parameter);   \
+        av_log(s, AV_LOG_ERROR, "Invalid " name " %d\n", codecpar->parameter);   \
         ret = AVERROR_INVALIDDATA;                                                \
         goto fail;                                                                \
     }                                                                             \
@@ -287,7 +287,7 @@  static int ffm2_read_header(AVFormatContext *s)
     FFMContext *ffm = s->priv_data;
     AVStream *st;
     AVIOContext *pb = s->pb;
-    AVCodecContext *codec, *dummy_codec = NULL;
+    AVCodecContext *dummy_codec = NULL;
     AVCodecParameters *codecpar;
     const AVCodecDescriptor *codec_desc;
     int ret, i;
@@ -319,6 +319,7 @@  static int ffm2_read_header(AVFormatContext *s)
         unsigned size = avio_rb32(pb);
         int64_t next = avio_tell(pb) + size;
         char rc_eq_buf[128];
+        int flags;
 
         if(!id)
             break;
@@ -342,7 +343,6 @@  static int ffm2_read_header(AVFormatContext *s)
 
             avpriv_set_pts_info(st, 64, 1, 1000000);
 
-            codec = st->codec;
             codecpar = st->codecpar;
             /* generic info */
             codecpar->codec_id = avio_rb32(pb);
@@ -364,14 +364,19 @@  static int ffm2_read_header(AVFormatContext *s)
             }
             codecpar->bit_rate = avio_rb32(pb);
             if (codecpar->bit_rate < 0) {
-                av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
+                av_log(s, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
                 ret = AVERROR_INVALIDDATA;
                 goto fail;
             }
-            codec->flags = avio_rb32(pb);
+            flags = avio_rb32(pb);
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+            st->codec->flags = flags;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
             avio_rb32(pb);
             avio_rb32(pb);
-            if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
+            if (flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
                 int size = avio_rb32(pb);
                 if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
                     av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size);
@@ -536,7 +541,7 @@  static int ffm_read_header(AVFormatContext *s)
     FFMContext *ffm = s->priv_data;
     AVStream *st;
     AVIOContext *pb = s->pb;
-    AVCodecContext *codec, *dummy_codec = NULL;
+    AVCodecContext *dummy_codec = NULL;
     AVCodecParameters *codecpar;
     const AVCodecDescriptor *codec_desc;
     int i, nb_streams, ret;
@@ -567,6 +572,7 @@  static int ffm_read_header(AVFormatContext *s)
     /* read each stream */
     for(i=0;i<nb_streams;i++) {
         char rc_eq_buf[128];
+        int flags;
 
         st = avformat_new_stream(s, NULL);
         if (!st)
@@ -574,7 +580,6 @@  static int ffm_read_header(AVFormatContext *s)
 
         avpriv_set_pts_info(st, 64, 1, 1000000);
 
-        codec = st->codec;
         /* generic info */
         codecpar->codec_id = avio_rb32(pb);
         codec_desc = avcodec_descriptor_get(codecpar->codec_id);
@@ -593,10 +598,15 @@  static int ffm_read_header(AVFormatContext *s)
         }
         codecpar->bit_rate = avio_rb32(pb);
         if (codecpar->bit_rate < 0) {
-            av_log(codec, AV_LOG_WARNING, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
+            av_log(s, AV_LOG_WARNING, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate);
             goto fail;
         }
-        codec->flags = avio_rb32(pb);
+        flags = avio_rb32(pb);
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+            st->codec->flags = flags;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         avio_rb32(pb);
         avio_rb32(pb);
         /* specific info */
@@ -665,7 +675,7 @@  static int ffm_read_header(AVFormatContext *s)
         default:
             goto fail;
         }
-        if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
+        if (flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
             int size = avio_rb32(pb);
             if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
                 av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size);