diff mbox series

[FFmpeg-devel,1/8] avcodec/cbs: add a flush callback to CodedBitstreamType

Message ID 20200925144318.6194-1-jamrial@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/8] avcodec/cbs: add a flush callback to CodedBitstreamType | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

James Almer Sept. 25, 2020, 2:43 p.m. UTC
Used to reset the codec's private internal state.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/cbs.c          | 6 ++++++
 libavcodec/cbs.h          | 5 +++++
 libavcodec/cbs_internal.h | 3 +++
 3 files changed, 14 insertions(+)

Comments

James Almer Sept. 28, 2020, 2:03 p.m. UTC | #1
On 9/25/2020 11:43 AM, James Almer wrote:
> Used to reset the codec's private internal state.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/cbs.c          | 6 ++++++
>  libavcodec/cbs.h          | 5 +++++
>  libavcodec/cbs_internal.h | 3 +++
>  3 files changed, 14 insertions(+)

Will apply this set soon.
Mark Thompson Sept. 29, 2020, 3:50 p.m. UTC | #2
On 25/09/2020 15:43, James Almer wrote:
> Used to reset the codec's private internal state.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/cbs.c          | 6 ++++++
>   libavcodec/cbs.h          | 5 +++++
>   libavcodec/cbs_internal.h | 3 +++
>   3 files changed, 14 insertions(+)
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 7c1aa005c2..c8c526ab12 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -112,6 +112,12 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
>       return 0;
>   }
>   
> +void ff_cbs_flush(CodedBitstreamContext *ctx)
> +{
> +    if (ctx->codec && ctx->codec->flush)
> +        ctx->codec->flush(ctx);
> +}
> +
>   void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
>   {
>       CodedBitstreamContext *ctx = *ctx_ptr;
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index 3a054aa8f3..635921b11e 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -236,6 +236,11 @@ extern const enum AVCodecID ff_cbs_all_codec_ids[];
>   int ff_cbs_init(CodedBitstreamContext **ctx,
>                   enum AVCodecID codec_id, void *log_ctx);
>   
> +/**
> + * Reset all internal state in a context.
> + */
> +void ff_cbs_flush(CodedBitstreamContext *ctx);
> +
>   /**
>    * Close a context and free all internal state.
>    */
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> index d991e1eedf..faa847aad3 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -117,6 +117,9 @@ typedef struct CodedBitstreamType {
>       int (*assemble_fragment)(CodedBitstreamContext *ctx,
>                                CodedBitstreamFragment *frag);
>   
> +    // Reset the codec internal state.
> +    void (*flush)(CodedBitstreamContext *ctx);
> +
>       // Free the codec internal state.
>       void (*close)(CodedBitstreamContext *ctx);
>   } CodedBitstreamType;
> 

This is a good idea!  Patches 1-4 LGTM.

Thanks,

- Mark
James Almer Sept. 30, 2020, 1:26 a.m. UTC | #3
On 9/29/2020 12:50 PM, Mark Thompson wrote:
> On 25/09/2020 15:43, James Almer wrote:
>> Used to reset the codec's private internal state.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/cbs.c          | 6 ++++++
>>   libavcodec/cbs.h          | 5 +++++
>>   libavcodec/cbs_internal.h | 3 +++
>>   3 files changed, 14 insertions(+)
>>
>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>> index 7c1aa005c2..c8c526ab12 100644
>> --- a/libavcodec/cbs.c
>> +++ b/libavcodec/cbs.c
>> @@ -112,6 +112,12 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
>>       return 0;
>>   }
>>   +void ff_cbs_flush(CodedBitstreamContext *ctx)
>> +{
>> +    if (ctx->codec && ctx->codec->flush)
>> +        ctx->codec->flush(ctx);
>> +}
>> +
>>   void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
>>   {
>>       CodedBitstreamContext *ctx = *ctx_ptr;
>> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
>> index 3a054aa8f3..635921b11e 100644
>> --- a/libavcodec/cbs.h
>> +++ b/libavcodec/cbs.h
>> @@ -236,6 +236,11 @@ extern const enum AVCodecID ff_cbs_all_codec_ids[];
>>   int ff_cbs_init(CodedBitstreamContext **ctx,
>>                   enum AVCodecID codec_id, void *log_ctx);
>>   +/**
>> + * Reset all internal state in a context.
>> + */
>> +void ff_cbs_flush(CodedBitstreamContext *ctx);
>> +
>>   /**
>>    * Close a context and free all internal state.
>>    */
>> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
>> index d991e1eedf..faa847aad3 100644
>> --- a/libavcodec/cbs_internal.h
>> +++ b/libavcodec/cbs_internal.h
>> @@ -117,6 +117,9 @@ typedef struct CodedBitstreamType {
>>       int (*assemble_fragment)(CodedBitstreamContext *ctx,
>>                                CodedBitstreamFragment *frag);
>>   +    // Reset the codec internal state.
>> +    void (*flush)(CodedBitstreamContext *ctx);
>> +
>>       // Free the codec internal state.
>>       void (*close)(CodedBitstreamContext *ctx);
>>   } CodedBitstreamType;
>>
> 
> This is a good idea!  Patches 1-4 LGTM.
> 
> Thanks,
> 
> - Mark

Pushed all four, thanks!
diff mbox series

Patch

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 7c1aa005c2..c8c526ab12 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -112,6 +112,12 @@  int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
     return 0;
 }
 
+void ff_cbs_flush(CodedBitstreamContext *ctx)
+{
+    if (ctx->codec && ctx->codec->flush)
+        ctx->codec->flush(ctx);
+}
+
 void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
 {
     CodedBitstreamContext *ctx = *ctx_ptr;
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 3a054aa8f3..635921b11e 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -236,6 +236,11 @@  extern const enum AVCodecID ff_cbs_all_codec_ids[];
 int ff_cbs_init(CodedBitstreamContext **ctx,
                 enum AVCodecID codec_id, void *log_ctx);
 
+/**
+ * Reset all internal state in a context.
+ */
+void ff_cbs_flush(CodedBitstreamContext *ctx);
+
 /**
  * Close a context and free all internal state.
  */
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index d991e1eedf..faa847aad3 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -117,6 +117,9 @@  typedef struct CodedBitstreamType {
     int (*assemble_fragment)(CodedBitstreamContext *ctx,
                              CodedBitstreamFragment *frag);
 
+    // Reset the codec internal state.
+    void (*flush)(CodedBitstreamContext *ctx);
+
     // Free the codec internal state.
     void (*close)(CodedBitstreamContext *ctx);
 } CodedBitstreamType;