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
6666 */
6767
6868 /* free everything allocated by pic_arrays_init() */
69−static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)
69+static void pic_arrays_free(HEVCLayerContext *l)
7070 {
7171 av_freep(&l->sao);
7272 av_freep(&l->deblock);
@@ -85,12 +85,12 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) · 12 unmodified lines
8585 av_freep(&l->horizontal_bs);
8686 av_freep(&l->vertical_bs);
8787
88− ff_refstruct_pool_uninit(&s->tab_mvf_pool);
89− ff_refstruct_pool_uninit(&s->rpl_tab_pool);
88+ ff_refstruct_pool_uninit(&l->tab_mvf_pool);
89+ ff_refstruct_pool_uninit(&l->rpl_tab_pool);
9090 }
9191
9292 /* allocate arrays that depend on frame dimensions */
93−static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps)
93+static int pic_arrays_init(HEVCLayerContext *l, const HEVCSPS *sps)
9494 {
9595 int log2_min_cb_size = sps->log2_min_cb_size;
9696 int width = sps->width;
@@ -132,15 +132,15 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s · 35 unmodified lines
132132 if (!l->horizontal_bs || !l->vertical_bs)
133133 goto fail;
134134
135− s->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);
137− if (!s->tab_mvf_pool || !s->rpl_tab_pool)
135+ l->tab_mvf_pool = ff_refstruct_pool_alloc(min_pu_size * sizeof(MvField), 0);
136+ l->rpl_tab_pool = ff_refstruct_pool_alloc(ctb_count * sizeof(RefPicListTab), 0);
137+ if (!l->tab_mvf_pool || !l->rpl_tab_pool)
138138 goto fail;
139139
140140 return 0;
141141
142142 fail:
143− pic_arrays_free(s, l);
143+ pic_arrays_free(l);
144144 return AVERROR(ENOMEM);
145145 }
146146
@@ -531,14 +531,14 @@ static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps) · 384 unmodified lines
531531 {
532532 int ret, i;
533533
534− pic_arrays_free(s, l);
534+ pic_arrays_free(l);
535535 s->ps.sps = NULL;
536536 ff_refstruct_unref(&s->vps);
537537
538538 if (!sps)
539539 return 0;
540540
541− ret = pic_arrays_init(s, l, sps);
541+ ret = pic_arrays_init(l, sps);
542542 if (ret < 0)
543543 goto fail;
544544
@@ -576,7 +576,7 @@ static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps) · 31 unmodified lines
576576 return 0;
577577
578578 fail:
579− pic_arrays_free(s, l);
579+ pic_arrays_free(l);
580580 for (i = 0; i < 3; i++) {
581581 av_freep(&s->sao_pixel_buffer_h[i]);
582582 av_freep(&s->sao_pixel_buffer_v[i]);
@@ -3529,7 +3529,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) · 2946 unmodified lines
35293529 int i;
35303530
35313531 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]);
35333533
35343534 ff_refstruct_unref(&s->vps);
35353535 ff_refstruct_unref(&s->pps);
libavcodec/hevc/hevcdec.h+3−3
@@ -465,6 +465,9 @@ typedef struct HEVCLayerContext { · 464 unmodified lines
465465
466466 uint8_t *horizontal_bs;
467467 uint8_t *vertical_bs;
468+
469+ struct FFRefStructPool *tab_mvf_pool;
470+ struct FFRefStructPool *rpl_tab_pool;
468471 } HEVCLayerContext;
469472
470473 typedef struct HEVCContext {
@@ -489,9 +492,6 @@ typedef struct HEVCContext { · 18 unmodified lines
489492 HEVCSEI sei;
490493 struct AVMD5 *md5_ctx;
491494
492− struct FFRefStructPool *tab_mvf_pool;
493− struct FFRefStructPool *rpl_tab_pool;
494−
495495 ///< candidate references for the current frame
496496 RefPicList rps[5];
497497
libavcodec/hevc/refs.c+2−2
@@ -95,11 +95,11 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) · 94 unmodified lines
9595 goto fail;
9696 frame->nb_rpl_elems = s->pkt.nb_nals;
9797
98− frame->tab_mvf = ff_refstruct_pool_get(s->tab_mvf_pool);
98+ frame->tab_mvf = ff_refstruct_pool_get(l->tab_mvf_pool);
9999 if (!frame->tab_mvf)
100100 goto fail;
101101
102− frame->rpl_tab = ff_refstruct_pool_get(s->rpl_tab_pool);
102+ frame->rpl_tab = ff_refstruct_pool_get(l->rpl_tab_pool);
103103 if (!frame->rpl_tab)
104104 goto fail;
105105 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