diff mbox

[FFmpeg-devel,1/5] avcodec/hevc_ps: add a function to uninitialize parameter set buffers

Message ID 20180120211253.9676-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Jan. 20, 2018, 9:12 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/hevc_ps.c | 16 ++++++++++++++++
 libavcodec/hevc_ps.h |  2 ++
 2 files changed, 18 insertions(+)

Comments

James Almer Jan. 20, 2018, 9:20 p.m. UTC | #1
On 1/20/2018 6:12 PM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/hevc_ps.c | 16 ++++++++++++++++
>  libavcodec/hevc_ps.h |  2 ++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index a4f7ed60f7..b18457296b 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -1704,6 +1704,22 @@ err:
>      return ret;
>  }
>  
> +void ff_hevc_uninit_parameter_sets(HEVCParamSets *ps)

Might change this to ff_hevc_ps_uninit(), to use the naming scheme of
the similar h264 function.

> +{
> +    int i;
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(ps->vps_list); i++)
> +        av_buffer_unref(&ps->vps_list[i]);
> +    for (i = 0; i < FF_ARRAY_ELEMS(ps->sps_list); i++)
> +        av_buffer_unref(&ps->sps_list[i]);
> +    for (i = 0; i < FF_ARRAY_ELEMS(ps->pps_list); i++)
> +        av_buffer_unref(&ps->pps_list[i]);
> +
> +    ps->sps = NULL;
> +    ps->pps = NULL;
> +    ps->vps = NULL;
> +}
> +
>  int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type)
>  {
>      int max_poc_lsb  = 1 << sps->log2_max_poc_lsb;
> diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
> index 477ee4299a..871a58acc6 100644
> --- a/libavcodec/hevc_ps.h
> +++ b/libavcodec/hevc_ps.h
> @@ -421,6 +421,8 @@ int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
>  int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
>                             HEVCParamSets *ps);
>  
> +void ff_hevc_uninit_parameter_sets(HEVCParamSets *ps);
> +
>  int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
>                                    ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);
>  
>
Michael Niedermayer Jan. 21, 2018, 2:36 a.m. UTC | #2
On Sat, Jan 20, 2018 at 06:20:53PM -0300, James Almer wrote:
> On 1/20/2018 6:12 PM, James Almer wrote:
> > Signed-off-by: James Almer <jamrial@gmail.com>
> > ---
> >  libavcodec/hevc_ps.c | 16 ++++++++++++++++
> >  libavcodec/hevc_ps.h |  2 ++
> >  2 files changed, 18 insertions(+)
> > 
> > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> > index a4f7ed60f7..b18457296b 100644
> > --- a/libavcodec/hevc_ps.c
> > +++ b/libavcodec/hevc_ps.c
> > @@ -1704,6 +1704,22 @@ err:
> >      return ret;
> >  }
> >  
> > +void ff_hevc_uninit_parameter_sets(HEVCParamSets *ps)
> 
> Might change this to ff_hevc_ps_uninit(), to use the naming scheme of
> the similar h264 function.

LGTM either way

[...]
James Almer Jan. 21, 2018, 4:01 a.m. UTC | #3
On 1/20/2018 11:36 PM, Michael Niedermayer wrote:
> On Sat, Jan 20, 2018 at 06:20:53PM -0300, James Almer wrote:
>> On 1/20/2018 6:12 PM, James Almer wrote:
>>> Signed-off-by: James Almer <jamrial@gmail.com>
>>> ---
>>>  libavcodec/hevc_ps.c | 16 ++++++++++++++++
>>>  libavcodec/hevc_ps.h |  2 ++
>>>  2 files changed, 18 insertions(+)
>>>
>>> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
>>> index a4f7ed60f7..b18457296b 100644
>>> --- a/libavcodec/hevc_ps.c
>>> +++ b/libavcodec/hevc_ps.c
>>> @@ -1704,6 +1704,22 @@ err:
>>>      return ret;
>>>  }
>>>  
>>> +void ff_hevc_uninit_parameter_sets(HEVCParamSets *ps)
>>
>> Might change this to ff_hevc_ps_uninit(), to use the naming scheme of
>> the similar h264 function.
> 
> LGTM either way

Changed and pushed, thanks.
diff mbox

Patch

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a4f7ed60f7..b18457296b 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1704,6 +1704,22 @@  err:
     return ret;
 }
 
+void ff_hevc_uninit_parameter_sets(HEVCParamSets *ps)
+{
+    int i;
+
+    for (i = 0; i < FF_ARRAY_ELEMS(ps->vps_list); i++)
+        av_buffer_unref(&ps->vps_list[i]);
+    for (i = 0; i < FF_ARRAY_ELEMS(ps->sps_list); i++)
+        av_buffer_unref(&ps->sps_list[i]);
+    for (i = 0; i < FF_ARRAY_ELEMS(ps->pps_list); i++)
+        av_buffer_unref(&ps->pps_list[i]);
+
+    ps->sps = NULL;
+    ps->pps = NULL;
+    ps->vps = NULL;
+}
+
 int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type)
 {
     int max_poc_lsb  = 1 << sps->log2_max_poc_lsb;
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 477ee4299a..871a58acc6 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -421,6 +421,8 @@  int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
 int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
                            HEVCParamSets *ps);
 
+void ff_hevc_uninit_parameter_sets(HEVCParamSets *ps);
+
 int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
                                   ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);