History

avcodec/mpegvideo: Only use a single ac_val pointer

The chroma pointers ac_val[1] and ac_val[2] are no longer used anywhere.

Andreas Rheinhardt committed 1 year ago

Commit dba10611 parent 4aca6b18 files · +19 −23Browse files

Showing the changes to libavcodec (8 of 8 files). Show all

Unified · Split

8 files
  1. libavcodec/ituh263dec.c +1 −1
  2. libavcodec/mpeg4video.c +5 −3
  3. libavcodec/mpeg4videodec.c +2 −4
  4. libavcodec/mpeg4videoenc.c +2 −2
  5. libavcodec/mpegvideo.c +3 −7
  6. libavcodec/mpegvideo.h +1 −1
  7. libavcodec/mpegvideo_enc.c +2 −2
  8. libavcodec/vc1_block.c +3 −3
libavcodec/ituh263dec.c+1−1
@@ -451,7 +451,7 @@ static void h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) · 450 unmodified lines
451451 int wrap, a, c, pred_dc, scale;
452452 const int xy = s->block_index[n];
453453 int16_t *const dc_val = s->dc_val[0] + xy;
454− int16_t *const ac_val = (s->ac_val[0] + xy)[0];
454+ int16_t *const ac_val = (s->ac_val + xy)[0];
455455
456456 /* find prediction */
457457 if (n < 4) {
libavcodec/mpeg4video.c+5−3
@@ -50,11 +50,13 @@ void ff_mpeg4_clean_buffers(MpegEncContext *s) · 49 unmodified lines
5050 l_xy = (2 * s->mb_y - 1) * l_wrap + s->mb_x * 2 - 1;
5151 c_wrap = s->mb_stride;
5252 int u_xy = 2 * mb_height * l_wrap + s->mb_y * c_wrap + s->mb_x - 1;
53+ int v_xy = u_xy + c_wrap * (mb_height + 1);
54+ int16_t (*ac_val)[16] = s->ac_val;
5355
5456 /* clean AC */
55− memset(s->ac_val[0] + l_xy, 0, (l_wrap * 2 + 1) * 16 * sizeof(int16_t));
56− memset(s->ac_val[0] + u_xy, 0, (c_wrap + 1) * 16 * sizeof(int16_t));
57− memset(s->ac_val[0] + u_xy + c_wrap * (mb_height + 1), 0, (c_wrap + 1) * 16 * sizeof(int16_t));
57+ memset(ac_val + l_xy, 0, (l_wrap * 2 + 1) * sizeof(*ac_val));
58+ memset(ac_val + u_xy, 0, (c_wrap + 1) * sizeof(*ac_val));
59+ memset(ac_val + v_xy, 0, (c_wrap + 1) * sizeof(*ac_val));
5860
5961 /* clean MV */
6062 // we can't clear the MVs as they might be needed by a B-frame
libavcodec/mpeg4videodec.c+2−4
@@ -326,7 +326,7 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) · 325 unmodified lines
326326 int8_t *const qscale_table = s->cur_pic.qscale_table;
327327
328328 /* find prediction */
329− ac_val = &s->ac_val[0][0][0] + s->block_index[n] * 16;
329+ ac_val = &s->ac_val[0][0] + s->block_index[n] * 16;
330330 ac_val1 = ac_val;
331331 if (s->ac_pred) {
332332 if (dir == 0) {
@@ -3785,9 +3785,7 @@ static av_cold void clear_context(MpegEncContext *s) · 3452 unmodified lines
37853785 s->block = NULL;
37863786 s->blocks = NULL;
37873787 s->ac_val_base = NULL;
3788− s->ac_val[0] =
3789− s->ac_val[1] =
3790− s->ac_val[2] =NULL;
3788+ s->ac_val = NULL;
37913789 memset(&s->sc, 0, sizeof(s->sc));
37923790
37933791 s->p_field_mv_table_base = NULL;
libavcodec/mpeg4videoenc.c+2−2
@@ -130,7 +130,7 @@ static inline void restore_ac_coeffs(MPVEncContext *const s, int16_t block[6][64 · 129 unmodified lines
130130 memcpy(s->c.block_last_index, zigzag_last_index, sizeof(int) * 6);
131131
132132 for (n = 0; n < 6; n++) {
133− int16_t *ac_val = &s->c.ac_val[0][0][0] + s->c.block_index[n] * 16;
133+ int16_t *ac_val = &s->c.ac_val[0][0] + s->c.block_index[n] * 16;
134134
135135 st[n] = s->c.intra_scantable.permutated;
136136 if (dir[n]) {
@@ -169,7 +169,7 @@ static inline int decide_ac_pred(MPVEncContext *const s, int16_t block[6][64], · 32 unmodified lines
169169 score -= get_block_rate(s, block[n], s->c.block_last_index[n],
170170 s->c.intra_scantable.permutated);
171171
172− ac_val = &s->c.ac_val[0][0][0] + s->c.block_index[n] * 16;
172+ ac_val = &s->c.ac_val[0][0] + s->c.block_index[n] * 16;
173173 ac_val1 = ac_val;
174174 if (dir[n]) {
175175 const int xy = s->c.mb_x + s->c.mb_y * s->c.mb_stride - s->c.mb_stride;
libavcodec/mpegvideo.c+3−7
@@ -129,9 +129,7 @@ static av_cold int init_duplicate_context(MpegEncContext *s) · 128 unmodified lines
129129 /* ac values */
130130 if (!FF_ALLOCZ_TYPED_ARRAY(s->ac_val_base, yc_size))
131131 return AVERROR(ENOMEM);
132− s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
133− s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
134− s->ac_val[2] = s->ac_val[1] + c_size;
132+ s->ac_val = s->ac_val_base + s->b8_stride + 1;
135133 }
136134
137135 return 0;
@@ -195,9 +193,7 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) · 57 unmodified lines
195193 COPY(start_mb_y);
196194 COPY(end_mb_y);
197195 COPY(ac_val_base);
198− COPY(ac_val[0]);
199− COPY(ac_val[1]);
200− COPY(ac_val[2]);
196+ COPY(ac_val);
201197 #undef COPY
202198 }
203199
@@ -502,7 +498,7 @@ void ff_clean_intra_table_entries(MpegEncContext *s) · 298 unmodified lines
502498 dc_val[uxy] =
503499 dc_val[vxy] = 1024;
504500 /* ac pred */
505− int16_t (*ac_val)[16] = s->ac_val[0];
501+ int16_t (*ac_val)[16] = s->ac_val;
506502 av_assume(!((uintptr_t)ac_val & 0xF));
507503 // Don't reset the upper-left luma block, as it will only ever be
508504 // referenced by blocks from the same macroblock.
libavcodec/mpegvideo.h+1−1
@@ -148,7 +148,7 @@ typedef struct MpegEncContext { · 147 unmodified lines
148148 uint8_t *coded_block_base;
149149 uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
150150 int16_t (*ac_val_base)[16];
151− int16_t (*ac_val[3])[16]; ///< used for MPEG-4 AC prediction, all 3 arrays must be continuous
151+ int16_t (*ac_val)[16]; ///< used for H.263 AIC, MPEG-4 AC prediction
152152 int mb_skipped; ///< MUST BE SET only during DECODING
153153 uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example)
154154 and used for B-frame encoding & decoding (contains skip table of next P-frame) */
libavcodec/mpegvideo_enc.c+2−2
@@ -3327,7 +3327,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 3326 unmodified lines
33273327 if(storecoefs){
33283328 for(i=0; i<6; i++){
33293329 dc[i] = s->c.dc_val[0][s->c.block_index[i]];
3330− memcpy(ac[i], s->c.ac_val[0][s->c.block_index[i]], sizeof(int16_t)*16);
3330+ memcpy(ac[i], s->c.ac_val[s->c.block_index[i]], sizeof(*s->c.ac_val));
33313331 }
33323332 }
33333333
@@ -3337,7 +3337,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 3 unmodified lines
33373337 if(storecoefs){
33383338 for(i=0; i<6; i++){
33393339 s->c.dc_val[0][s->c.block_index[i]] = dc[i];
3340− memcpy(s->c.ac_val[0][s->c.block_index[i]], ac[i], sizeof(int16_t)*16);
3340+ memcpy(s->c.ac_val[s->c.block_index[i]], ac[i], sizeof(*s->c.ac_val));
33413341 }
33423342 }
33433343 }
libavcodec/vc1_block.c+3−3
@@ -611,7 +611,7 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, · 610 unmodified lines
611611 /* Store the quantized DC coeff, used for prediction */
612612 block[0] = dcdiff * s->y_dc_scale;
613613
614− ac_val = s->ac_val[0][s->block_index[n]];
614+ ac_val = s->ac_val[s->block_index[n]];
615615 ac_val2 = ac_val;
616616 if (dc_pred_dir) // left
617617 ac_val -= 16;
@@ -750,7 +750,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, · 132 unmodified lines
750750
751751 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
752752
753− ac_val = s->ac_val[0][s->block_index[n]];
753+ ac_val = s->ac_val[s->block_index[n]];
754754 ac_val2 = ac_val;
755755 if (dc_pred_dir) // left
756756 ac_val -= 16;
@@ -938,7 +938,7 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, · 181 unmodified lines
938938 if (!a_avail) dc_pred_dir = 1;
939939 if (!c_avail) dc_pred_dir = 0;
940940 if (!a_avail && !c_avail) use_pred = 0;
941− ac_val = s->ac_val[0][s->block_index[n]];
941+ ac_val = s->ac_val[s->block_index[n]];
942942 ac_val2 = ac_val;
943943
944944 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);

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