[vlc-devel] [vlc-commits] codec: aom: store frame private data locally
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jul 20 08:34:58 CEST 2018
Is this overriding the container PTS ? Because it shouldn't. It should
only set the PTS if it's unknown.
On 19/07/2018 17:15, Francois Cartegnie wrote:
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jul 19 16:21:05 2018 +0200| [135bdbbe75913a2a210a9273fe078eac705e56ac] | committer: Francois Cartegnie
>
> codec: aom: store frame private data locally
>
> fix leaks on error
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=135bdbbe75913a2a210a9273fe078eac705e56ac
> ---
>
> modules/codec/aom.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/modules/codec/aom.c b/modules/codec/aom.c
> index 70c0e26c56..c5cd4fc62c 100644
> --- a/modules/codec/aom.c
> +++ b/modules/codec/aom.c
> @@ -92,13 +92,21 @@ static void aom_err_msg(vlc_object_t *this, aom_codec_ctx_t *ctx,
> }
>
> #define AOM_ERR(this, ctx, msg) aom_err_msg(VLC_OBJECT(this), ctx, msg ": %s (%s)")
> +#define AOM_MAX_FRAMES_DEPTH 64
>
> /*****************************************************************************
> * decoder_sys_t: libaom decoder descriptor
> *****************************************************************************/
> +struct frame_priv_s
> +{
> + vlc_tick_t pts;
> +};
> +
> typedef struct
> {
> aom_codec_ctx_t ctx;
> + struct frame_priv_s frame_priv[AOM_MAX_FRAMES_DEPTH];
> + unsigned i_next_frame_priv;
> } decoder_sys_t;
>
> static const struct
> @@ -161,21 +169,15 @@ static int Decode(decoder_t *dec, block_t *block)
> }
>
> /* Associate packet PTS with decoded frame */
> - vlc_tick_t *pkt_pts = malloc(sizeof(*pkt_pts));
> - if (!pkt_pts) {
> - block_Release(block);
> - return VLCDEC_SUCCESS;
> - }
> -
> - *pkt_pts = (block->i_pts != VLC_TICK_INVALID) ? block->i_pts : block->i_dts;
> + struct frame_priv_s *priv = &p_sys->frame_priv[p_sys->i_next_frame_priv++ % AOM_MAX_FRAMES_DEPTH];
> + priv->pts = (block->i_pts != VLC_TICK_INVALID) ? block->i_pts : block->i_dts;
>
> aom_codec_err_t err;
> - err = aom_codec_decode(ctx, block->p_buffer, block->i_buffer, pkt_pts);
> + err = aom_codec_decode(ctx, block->p_buffer, block->i_buffer, priv);
>
> block_Release(block);
>
> if (err != AOM_CODEC_OK) {
> - free(pkt_pts);
> AOM_ERR(dec, ctx, "Failed to decode frame");
> if (err == AOM_CODEC_UNSUP_BITSTREAM)
> return VLCDEC_ECRITICAL;
> @@ -185,15 +187,11 @@ static int Decode(decoder_t *dec, block_t *block)
>
> const void *iter = NULL;
> struct aom_image *img = aom_codec_get_frame(ctx, &iter);
> - if (!img) {
> - free(pkt_pts);
> + if (!img)
> return VLCDEC_SUCCESS;
> - }
>
> /* fetches back the PTS */
> - pkt_pts = img->user_priv;
> - vlc_tick_t pts = *pkt_pts;
> - free(pkt_pts);
> + vlc_tick_t pts = ((struct frame_priv_s *) img->user_priv)->pts;
>
> dec->fmt_out.i_codec = FindVlcChroma(img);
> if (dec->fmt_out.i_codec == 0) {
> @@ -284,6 +282,8 @@ static int OpenDecoder(vlc_object_t *p_this)
> return VLC_ENOMEM;
> dec->p_sys = sys;
>
> + sys->i_next_frame_priv = 0;
> +
> struct aom_codec_dec_cfg deccfg = {
> .threads = __MIN(vlc_GetCPUCount(), 16),
> .allow_lowbitdepth = 1
> @@ -333,7 +333,6 @@ static void CloseDecoder(vlc_object_t *p_this)
> struct aom_image *img = aom_codec_get_frame(&sys->ctx, &iter);
> if (!img)
> break;
> - free(img->user_priv);
> }
>
> aom_codec_destroy(&sys->ctx);
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
More information about the vlc-devel
mailing list