diff mbox

[FFmpeg-devel] avcodec/mpeg12dec: Add FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM

Message ID 20161208215350.7922-1-michael@niedermayer.cc
State Accepted
Commit 5b73ba9887d419ee056723248c7a3dd51f05c3e7
Headers show

Commit Message

Michael Niedermayer Dec. 8, 2016, 9:53 p.m. UTC
This decreases the amount of computations and memory needed for analysing mpeg1/2 streams

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/mpeg12dec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andreas Cadhalpun Dec. 9, 2016, 12:02 a.m. UTC | #1
On 08.12.2016 22:53, Michael Niedermayer wrote:
> This decreases the amount of computations and memory needed for analysing mpeg1/2 streams
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/mpeg12dec.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index ac8160daff..63979079c8 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -1655,7 +1655,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
>              if (sd)
>                  memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
>              av_freep(&s1->a53_caption);
> -            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
>          }
>  
>          if (s1->has_stereo3d) {
> @@ -2258,6 +2257,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>              s1->a53_caption      = av_malloc(s1->a53_caption_size);
>              if (s1->a53_caption)
>                  memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
> +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
>          }
>          return 1;
>      } else if (buf_size >= 11 &&
> @@ -2313,6 +2313,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>                      p += 6;
>                  }
>              }
> +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
>          }
>          return 1;
>      }

How are the above changes related to the commit message?

> @@ -2868,6 +2869,7 @@ AVCodec ff_mpeg1video_decoder = {
>      .capabilities          = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
>                               AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
>                               AV_CODEC_CAP_SLICE_THREADS,
> +    .caps_internal         = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
>      .flush                 = flush,
>      .max_lowres            = 3,
>      .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
> @@ -2885,6 +2887,7 @@ AVCodec ff_mpeg2video_decoder = {
>      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
>                        AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
>                        AV_CODEC_CAP_SLICE_THREADS,
> +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
>      .flush          = flush,
>      .max_lowres     = 3,
>      .profiles       = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
> @@ -2901,6 +2904,7 @@ AVCodec ff_mpegvideo_decoder = {
>      .close          = mpeg_decode_end,
>      .decode         = mpeg_decode_frame,
>      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
> +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
>      .flush          = flush,
>      .max_lowres     = 3,
>  };
> 

Adding these here is probably OK.

Best regards,
Andreas
Michael Niedermayer Dec. 9, 2016, 1:50 a.m. UTC | #2
On Fri, Dec 09, 2016 at 01:02:08AM +0100, Andreas Cadhalpun wrote:
> On 08.12.2016 22:53, Michael Niedermayer wrote:
> > This decreases the amount of computations and memory needed for analysing mpeg1/2 streams
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/mpeg12dec.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> > index ac8160daff..63979079c8 100644
> > --- a/libavcodec/mpeg12dec.c
> > +++ b/libavcodec/mpeg12dec.c
> > @@ -1655,7 +1655,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
> >              if (sd)
> >                  memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
> >              av_freep(&s1->a53_caption);
> > -            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> >          }
> >  
> >          if (s1->has_stereo3d) {
> > @@ -2258,6 +2257,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
> >              s1->a53_caption      = av_malloc(s1->a53_caption_size);
> >              if (s1->a53_caption)
> >                  memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
> > +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> >          }
> >          return 1;
> >      } else if (buf_size >= 11 &&
> > @@ -2313,6 +2313,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
> >                      p += 6;
> >                  }
> >              }
> > +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> >          }
> >          return 1;
> >      }
> 
> How are the above changes related to the commit message?

the update is moved from code that is skiped if skip_frame is set
to code that is not skiped so the change below doesnt loose that
from being executed


> 
> > @@ -2868,6 +2869,7 @@ AVCodec ff_mpeg1video_decoder = {
> >      .capabilities          = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
> >                               AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
> >                               AV_CODEC_CAP_SLICE_THREADS,
> > +    .caps_internal         = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
> >      .flush                 = flush,
> >      .max_lowres            = 3,
> >      .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
> > @@ -2885,6 +2887,7 @@ AVCodec ff_mpeg2video_decoder = {
> >      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
> >                        AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
> >                        AV_CODEC_CAP_SLICE_THREADS,
> > +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
> >      .flush          = flush,
> >      .max_lowres     = 3,
> >      .profiles       = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
> > @@ -2901,6 +2904,7 @@ AVCodec ff_mpegvideo_decoder = {
> >      .close          = mpeg_decode_end,
> >      .decode         = mpeg_decode_frame,
> >      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
> > +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
> >      .flush          = flush,
> >      .max_lowres     = 3,
> >  };
> > 
> 
> Adding these here is probably OK.
> 
> Best regards,
> Andreas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Andreas Cadhalpun Dec. 9, 2016, 11:11 p.m. UTC | #3
On 09.12.2016 02:50, Michael Niedermayer wrote:
> On Fri, Dec 09, 2016 at 01:02:08AM +0100, Andreas Cadhalpun wrote:
>> On 08.12.2016 22:53, Michael Niedermayer wrote:
>>> This decreases the amount of computations and memory needed for analysing mpeg1/2 streams
>>>
>>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>>> ---
>>>  libavcodec/mpeg12dec.c | 6 +++++-
>>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
>>> index ac8160daff..63979079c8 100644
>>> --- a/libavcodec/mpeg12dec.c
>>> +++ b/libavcodec/mpeg12dec.c
>>> @@ -1655,7 +1655,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
>>>              if (sd)
>>>                  memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
>>>              av_freep(&s1->a53_caption);
>>> -            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
>>>          }
>>>  
>>>          if (s1->has_stereo3d) {
>>> @@ -2258,6 +2257,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>>>              s1->a53_caption      = av_malloc(s1->a53_caption_size);
>>>              if (s1->a53_caption)
>>>                  memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
>>> +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
>>>          }
>>>          return 1;
>>>      } else if (buf_size >= 11 &&
>>> @@ -2313,6 +2313,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>>>                      p += 6;
>>>                  }
>>>              }
>>> +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
>>>          }
>>>          return 1;
>>>      }
>>
>> How are the above changes related to the commit message?
> 
> the update is moved from code that is skiped if skip_frame is set
> to code that is not skiped so the change below doesnt loose that
> from being executed

Thanks for explaining that. Maybe mention it in the commit message.
I can confirm that this patch significantly accelerates analyzing,
so it looks good to me.

Best regards,
Andreas
Michael Niedermayer Dec. 10, 2016, 2:31 a.m. UTC | #4
On Sat, Dec 10, 2016 at 12:11:35AM +0100, Andreas Cadhalpun wrote:
> On 09.12.2016 02:50, Michael Niedermayer wrote:
> > On Fri, Dec 09, 2016 at 01:02:08AM +0100, Andreas Cadhalpun wrote:
> >> On 08.12.2016 22:53, Michael Niedermayer wrote:
> >>> This decreases the amount of computations and memory needed for analysing mpeg1/2 streams
> >>>
> >>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> >>> ---
> >>>  libavcodec/mpeg12dec.c | 6 +++++-
> >>>  1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> >>> index ac8160daff..63979079c8 100644
> >>> --- a/libavcodec/mpeg12dec.c
> >>> +++ b/libavcodec/mpeg12dec.c
> >>> @@ -1655,7 +1655,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
> >>>              if (sd)
> >>>                  memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
> >>>              av_freep(&s1->a53_caption);
> >>> -            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> >>>          }
> >>>  
> >>>          if (s1->has_stereo3d) {
> >>> @@ -2258,6 +2257,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
> >>>              s1->a53_caption      = av_malloc(s1->a53_caption_size);
> >>>              if (s1->a53_caption)
> >>>                  memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
> >>> +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> >>>          }
> >>>          return 1;
> >>>      } else if (buf_size >= 11 &&
> >>> @@ -2313,6 +2313,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
> >>>                      p += 6;
> >>>                  }
> >>>              }
> >>> +            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> >>>          }
> >>>          return 1;
> >>>      }
> >>
> >> How are the above changes related to the commit message?
> > 
> > the update is moved from code that is skiped if skip_frame is set
> > to code that is not skiped so the change below doesnt loose that
> > from being executed
> 
> Thanks for explaining that. Maybe mention it in the commit message.
> I can confirm that this patch significantly accelerates analyzing,
> so it looks good to me.

changed, applied

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index ac8160daff..63979079c8 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1655,7 +1655,6 @@  static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
             if (sd)
                 memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
             av_freep(&s1->a53_caption);
-            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
         }
 
         if (s1->has_stereo3d) {
@@ -2258,6 +2257,7 @@  static int mpeg_decode_a53_cc(AVCodecContext *avctx,
             s1->a53_caption      = av_malloc(s1->a53_caption_size);
             if (s1->a53_caption)
                 memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
+            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
         }
         return 1;
     } else if (buf_size >= 11 &&
@@ -2313,6 +2313,7 @@  static int mpeg_decode_a53_cc(AVCodecContext *avctx,
                     p += 6;
                 }
             }
+            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
         }
         return 1;
     }
@@ -2868,6 +2869,7 @@  AVCodec ff_mpeg1video_decoder = {
     .capabilities          = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
                              AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
                              AV_CODEC_CAP_SLICE_THREADS,
+    .caps_internal         = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .flush                 = flush,
     .max_lowres            = 3,
     .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
@@ -2885,6 +2887,7 @@  AVCodec ff_mpeg2video_decoder = {
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
                       AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
                       AV_CODEC_CAP_SLICE_THREADS,
+    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .flush          = flush,
     .max_lowres     = 3,
     .profiles       = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
@@ -2901,6 +2904,7 @@  AVCodec ff_mpegvideo_decoder = {
     .close          = mpeg_decode_end,
     .decode         = mpeg_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
+    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .flush          = flush,
     .max_lowres     = 3,
 };