History

lavc/hevcdec: move HEVCContext.{tab_mvf,rpl_tab}_pool to HEVCLayerContext

pic_arrays_{init,free}() no longer access HEVCContext

Anton Khirnov committed 2 years ago

Commit 6fcf0041 parent 4f87ff73 files · +17 −17Browse files

Unified · Split

3 files
  1. libavcodec/hevc/hevcdec.c +12 −12
  2. libavcodec/hevc/hevcdec.h +3 −3
  3. libavcodec/hevc/refs.c +2 −2
libavcodec/hevc/hevcdec.c+12−12
@@ -66,7 +66,7 @@ static const uint8_t hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, · 65 unmodified lines
66 */66 */
67 67
68/* free everything allocated by pic_arrays_init() */68/* free everything allocated by pic_arrays_init() */
69static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)69static void pic_arrays_free(HEVCLayerContext *l)
70{70{
71 av_freep(&l->sao);71 av_freep(&l->sao);
72 av_freep(&l->deblock);72 av_freep(&l->deblock);
@@ -85,12 +85,12 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) · 12 unmodified lines
85 av_freep(&l->horizontal_bs);85 av_freep(&l->horizontal_bs);
86 av_freep(&l->vertical_bs);86 av_freep(&l->vertical_bs);
87 87
88 ff_refstruct_pool_uninit(&s->tab_mvf_pool);88 ff_refstruct_pool_uninit(&l->tab_mvf_pool);
89 ff_refstruct_pool_uninit(&s->rpl_tab_pool);89 ff_refstruct_pool_uninit(&l->rpl_tab_pool);
90}90}
91 91
92/* allocate arrays that depend on frame dimensions */92/* allocate arrays that depend on frame dimensions */
93static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps)93static int pic_arrays_init(HEVCLayerContext *l, const HEVCSPS *sps)
94{94{
95 int log2_min_cb_size = sps->log2_min_cb_size;95 int log2_min_cb_size = sps->log2_min_cb_size;
96 int width = sps->width;96 int width = sps->width;
@@ -132,15 +132,15 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s · 35 unmodified lines
132 if (!l->horizontal_bs || !l->vertical_bs)132 if (!l->horizontal_bs || !l->vertical_bs)
133 goto fail;133 goto fail;
134 134
135 s->tab_mvf_pool = ff_refstruct_pool_alloc(min_pu_size * sizeof(MvField), 0);135 l->tab_mvf_pool = ff_refstruct_pool_alloc(min_pu_size * sizeof(MvField), 0);
136 s->rpl_tab_pool = ff_refstruct_pool_alloc(ctb_count * sizeof(RefPicListTab), 0);136 l->rpl_tab_pool = ff_refstruct_pool_alloc(ctb_count * sizeof(RefPicListTab), 0);
137 if (!s->tab_mvf_pool || !s->rpl_tab_pool)137 if (!l->tab_mvf_pool || !l->rpl_tab_pool)
138 goto fail;138 goto fail;
139 139
140 return 0;140 return 0;
141 141
142fail:142fail:
143 pic_arrays_free(s, l);143 pic_arrays_free(l);
144 return AVERROR(ENOMEM);144 return AVERROR(ENOMEM);
145}145}
146 146
@@ -531,14 +531,14 @@ static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps) · 384 unmodified lines
531{531{
532 int ret, i;532 int ret, i;
533 533
534 pic_arrays_free(s, l);534 pic_arrays_free(l);
535 s->ps.sps = NULL;535 s->ps.sps = NULL;
536 ff_refstruct_unref(&s->vps);536 ff_refstruct_unref(&s->vps);
537 537
538 if (!sps)538 if (!sps)
539 return 0;539 return 0;
540 540
541 ret = pic_arrays_init(s, l, sps);541 ret = pic_arrays_init(l, sps);
542 if (ret < 0)542 if (ret < 0)
543 goto fail;543 goto fail;
544 544
@@ -576,7 +576,7 @@ static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps) · 31 unmodified lines
576 return 0;576 return 0;
577 577
578fail:578fail:
579 pic_arrays_free(s, l);579 pic_arrays_free(l);
580 for (i = 0; i < 3; i++) {580 for (i = 0; i < 3; i++) {
581 av_freep(&s->sao_pixel_buffer_h[i]);581 av_freep(&s->sao_pixel_buffer_h[i]);
582 av_freep(&s->sao_pixel_buffer_v[i]);582 av_freep(&s->sao_pixel_buffer_v[i]);
@@ -3529,7 +3529,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) · 2946 unmodified lines
3529 int i;3529 int i;
3530 3530
3531 for (int i = 0; i < FF_ARRAY_ELEMS(s->layers); i++)3531 for (int i = 0; i < FF_ARRAY_ELEMS(s->layers); i++)
3532 pic_arrays_free(s, &s->layers[i]);3532 pic_arrays_free(&s->layers[i]);
3533 3533
3534 ff_refstruct_unref(&s->vps);3534 ff_refstruct_unref(&s->vps);
3535 ff_refstruct_unref(&s->pps);3535 ff_refstruct_unref(&s->pps);
libavcodec/hevc/hevcdec.h+3−3
@@ -465,6 +465,9 @@ typedef struct HEVCLayerContext { · 464 unmodified lines
465 465
466 uint8_t *horizontal_bs;466 uint8_t *horizontal_bs;
467 uint8_t *vertical_bs;467 uint8_t *vertical_bs;
468
469 struct FFRefStructPool *tab_mvf_pool;
470 struct FFRefStructPool *rpl_tab_pool;
468} HEVCLayerContext;471} HEVCLayerContext;
469 472
470typedef struct HEVCContext {473typedef struct HEVCContext {
@@ -489,9 +492,6 @@ typedef struct HEVCContext { · 18 unmodified lines
489 HEVCSEI sei;492 HEVCSEI sei;
490 struct AVMD5 *md5_ctx;493 struct AVMD5 *md5_ctx;
491 494
492 struct FFRefStructPool *tab_mvf_pool;
493 struct FFRefStructPool *rpl_tab_pool;
494
495 ///< candidate references for the current frame495 ///< candidate references for the current frame
496 RefPicList rps[5];496 RefPicList rps[5];
497 497
libavcodec/hevc/refs.c+2−2
@@ -95,11 +95,11 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) · 94 unmodified lines
95 goto fail;95 goto fail;
96 frame->nb_rpl_elems = s->pkt.nb_nals;96 frame->nb_rpl_elems = s->pkt.nb_nals;
97 97
98 frame->tab_mvf = ff_refstruct_pool_get(s->tab_mvf_pool);98 frame->tab_mvf = ff_refstruct_pool_get(l->tab_mvf_pool);
99 if (!frame->tab_mvf)99 if (!frame->tab_mvf)
100 goto fail;100 goto fail;
101 101
102 frame->rpl_tab = ff_refstruct_pool_get(s->rpl_tab_pool);102 frame->rpl_tab = ff_refstruct_pool_get(l->rpl_tab_pool);
103 if (!frame->rpl_tab)103 if (!frame->rpl_tab)
104 goto fail;104 goto fail;
105 frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;105 frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t