[FFmpeg-devel] avcodec/bsf_list: implement a AVBSFContext.flush callback

Submitted by James Almer on Jan. 6, 2019, 4:31 a.m.

Details

Message ID 20190106043112.6504-1-jamrial@gmail.com
State Accepted
Headers show

Commit Message

James Almer Jan. 6, 2019, 4:31 a.m.
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/bsf.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Paul B Mahol Jan. 6, 2019, 9:08 a.m.
On 1/6/19, James Almer <jamrial@gmail.com> wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/bsf.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index 03841da682..41dde4dcc8 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -350,6 +350,16 @@ static int bsf_list_filter(AVBSFContext *bsf, AVPacket
> *out)
>      return ret;
>  }
>
> +static void bsf_list_flush(AVBSFContext *bsf)
> +{
> +    BSFListContext *lst = bsf->priv_data;
> +    int i;
> +
> +    for (i = 0; i < lst->nb_bsfs; ++i)

Weird style, please use i++
Also use for (int i; ....

> +        av_bsf_flush(lst->bsfs[i]);
> +    lst->idx = lst->flushed_idx = 0;
> +}
> +
>  static void bsf_list_close(AVBSFContext *bsf)
>  {
>      BSFListContext *lst = bsf->priv_data;
> @@ -398,6 +408,7 @@ const AVBitStreamFilter ff_list_bsf = {
>          .priv_class     = &bsf_list_class,
>          .init           = bsf_list_init,
>          .filter         = bsf_list_filter,
> +        .flush          = bsf_list_flush,
>          .close          = bsf_list_close,
>  };
>
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
James Almer Jan. 6, 2019, 1:37 p.m.
On 1/6/2019 6:08 AM, Paul B Mahol wrote:
> On 1/6/19, James Almer <jamrial@gmail.com> wrote:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  libavcodec/bsf.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
>> index 03841da682..41dde4dcc8 100644
>> --- a/libavcodec/bsf.c
>> +++ b/libavcodec/bsf.c
>> @@ -350,6 +350,16 @@ static int bsf_list_filter(AVBSFContext *bsf, AVPacket
>> *out)
>>      return ret;
>>  }
>>
>> +static void bsf_list_flush(AVBSFContext *bsf)
>> +{
>> +    BSFListContext *lst = bsf->priv_data;
>> +    int i;
>> +
>> +    for (i = 0; i < lst->nb_bsfs; ++i)
> 
> Weird style, please use i++
> Also use for (int i; ....

Yeah, it's weird but it's consistent with bsf_list_close() below.

I'll change it anyway.

> 
>> +        av_bsf_flush(lst->bsfs[i]);
>> +    lst->idx = lst->flushed_idx = 0;
>> +}
>> +
>>  static void bsf_list_close(AVBSFContext *bsf)
>>  {
>>      BSFListContext *lst = bsf->priv_data;
>> @@ -398,6 +408,7 @@ const AVBitStreamFilter ff_list_bsf = {
>>          .priv_class     = &bsf_list_class,
>>          .init           = bsf_list_init,
>>          .filter         = bsf_list_filter,
>> +        .flush          = bsf_list_flush,
>>          .close          = bsf_list_close,
>>  };
>>
>> --
>> 2.20.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Patch hide | download patch | download mbox

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 03841da682..41dde4dcc8 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -350,6 +350,16 @@  static int bsf_list_filter(AVBSFContext *bsf, AVPacket *out)
     return ret;
 }
 
+static void bsf_list_flush(AVBSFContext *bsf)
+{
+    BSFListContext *lst = bsf->priv_data;
+    int i;
+
+    for (i = 0; i < lst->nb_bsfs; ++i)
+        av_bsf_flush(lst->bsfs[i]);
+    lst->idx = lst->flushed_idx = 0;
+}
+
 static void bsf_list_close(AVBSFContext *bsf)
 {
     BSFListContext *lst = bsf->priv_data;
@@ -398,6 +408,7 @@  const AVBitStreamFilter ff_list_bsf = {
         .priv_class     = &bsf_list_class,
         .init           = bsf_list_init,
         .filter         = bsf_list_filter,
+        .flush          = bsf_list_flush,
         .close          = bsf_list_close,
 };