History

avcodec/h263dec: Don't use MpegEncContext.block

Instead add the necessary blocks directly to H263DecContext (only six are needed, not 12 as ff_mpv_common_init() currently allocates).

Andreas Rheinhardt committed 1 year ago

Commit 77add261 parent b2be3427 files · +26 −23Browse files

Unified · Split

7 files
  1. libavcodec/h263dec.c +2 −2
  2. libavcodec/h263dec.h +3 −0
  3. libavcodec/ituh263dec.c +4 −4
  4. libavcodec/mpeg4videodec.c +7 −7
  5. libavcodec/msmpeg4dec.c +4 −4
  6. libavcodec/rv10.c +1 −1
  7. libavcodec/wmv2dec.c +5 −5
libavcodec/h263dec.c+2−2
@@ -272,7 +272,7 @@ static int decode_slice(H263DecContext *const h) · 271 unmodified lines
272272 if (ret < 0) {
273273 const int xy = h->c.mb_x + h->c.mb_y * h->c.mb_stride;
274274 if (ret == SLICE_END) {
275− ff_mpv_reconstruct_mb(&h->c, h->c.block);
275+ ff_mpv_reconstruct_mb(&h->c, h->block);
276276 if (h->c.loop_filter)
277277 ff_h263_loop_filter(&h->c);
278278
@@ -305,7 +305,7 @@ static int decode_slice(H263DecContext *const h) · 26 unmodified lines
305305 return AVERROR_INVALIDDATA;
306306 }
307307
308− ff_mpv_reconstruct_mb(&h->c, h->c.block);
308+ ff_mpv_reconstruct_mb(&h->c, h->block);
309309 if (h->c.loop_filter)
310310 ff_h263_loop_filter(&h->c);
311311 }
libavcodec/h263dec.h+3−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222
2323 #include "mpegvideo.h"
2424 #include "vlc.h"
25+#include "libavutil/mem_internal.h"
2526
2627 /**
2728 * Return value for header parsers if frame is not coded.
@@ -47,6 +48,8 @@ typedef struct H263DecContext { · 19 unmodified lines
4748 MPVContext c;
4849
4950 int (*decode_mb)(struct H263DecContext *h);
51+
52+ DECLARE_ALIGNED_32(int16_t, block)[6][64];
5053 } H263DecContext;
5154
5255 int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code);
libavcodec/ituh263dec.c+4−4
@@ -808,7 +808,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 807 unmodified lines
808808 }
809809 }while(cbpc == 20);
810810
811− h->c.bdsp.clear_blocks(h->c.block[0]);
811+ h->c.bdsp.clear_blocks(h->block[0]);
812812
813813 dquant = cbpc & 8;
814814 h->c.mb_intra = ((cbpc & 4) != 0);
@@ -910,7 +910,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 95 unmodified lines
910910
911911 h->c.mb_intra = IS_INTRA(mb_type);
912912 if(HAS_CBP(mb_type)){
913− h->c.bdsp.clear_blocks(h->c.block[0]);
913+ h->c.bdsp.clear_blocks(h->block[0]);
914914 cbpc = get_vlc2(&h->c.gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
915915 if (h->c.mb_intra) {
916916 dquant = IS_QUANT(mb_type);
@@ -1012,7 +1012,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 95 unmodified lines
10121012 }
10131013 }while(cbpc == 8);
10141014
1015− h->c.bdsp.clear_blocks(h->c.block[0]);
1015+ h->c.bdsp.clear_blocks(h->block[0]);
10161016
10171017 dquant = cbpc & 4;
10181018 h->c.mb_intra = 1;
@@ -1051,7 +1051,7 @@ intra: · 32 unmodified lines
10511051
10521052 /* decode each block */
10531053 for (i = 0; i < 6; i++) {
1054− if (h263_decode_block(h, h->c.block[i], i, cbp&32) < 0)
1054+ if (h263_decode_block(h, h->block[i], i, cbp&32) < 0)
10551055 return -1;
10561056 cbp+=cbp;
10571057 }
libavcodec/mpeg4videodec.c+7−7
@@ -1708,10 +1708,10 @@ static int mpeg4_decode_partitioned_mb(H263DecContext *const h) · 1707 unmodified lines
17081708
17091709 if (!IS_SKIP(mb_type)) {
17101710 int i;
1711− h->c.bdsp.clear_blocks(h->c.block[0]);
1711+ h->c.bdsp.clear_blocks(h->block[0]);
17121712 /* decode each block */
17131713 for (i = 0; i < 6; i++) {
1714− if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32, h->c.mb_intra,
1714+ if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32, h->c.mb_intra,
17151715 use_intra_dc_vlc, ctx->rvlc) < 0) {
17161716 av_log(h->c.avctx, AV_LOG_ERROR,
17171717 "texture corrupted at %d %d %d\n",
@@ -1792,7 +1792,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 74 unmodified lines
17921792 h->c.mb_intra = ((cbpc & 4) != 0);
17931793 if (h->c.mb_intra)
17941794 goto intra;
1795− h->c.bdsp.clear_blocks(h->c.block[0]);
1795+ h->c.bdsp.clear_blocks(h->block[0]);
17961796
17971797 if (h->c.pict_type == AV_PICTURE_TYPE_S &&
17981798 ctx->vol_sprite_usage == GMC_SPRITE && (cbpc & 16) == 0)
@@ -1936,7 +1936,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 137 unmodified lines
19361936 if (modb2) {
19371937 cbp = 0;
19381938 } else {
1939− h->c.bdsp.clear_blocks(h->c.block[0]);
1939+ h->c.bdsp.clear_blocks(h->block[0]);
19401940 cbp = get_bits(&h->c.gb, 6);
19411941 }
19421942
@@ -2073,10 +2073,10 @@ intra: · 130 unmodified lines
20732073 if (!h->c.progressive_sequence)
20742074 h->c.interlaced_dct = get_bits1(&h->c.gb);
20752075
2076− h->c.bdsp.clear_blocks(h->c.block[0]);
2076+ h->c.bdsp.clear_blocks(h->block[0]);
20772077 /* decode each block */
20782078 for (i = 0; i < 6; i++) {
2079− if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32,
2079+ if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32,
20802080 1, use_intra_dc_vlc, 0) < 0)
20812081 return AVERROR_INVALIDDATA;
20822082 cbp += cbp;
@@ -2086,7 +2086,7 @@ intra: · 3 unmodified lines
20862086
20872087 /* decode each block */
20882088 for (i = 0; i < 6; i++) {
2089− if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32, 0, 0, 0) < 0)
2089+ if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32, 0, 0, 0) < 0)
20902090 return AVERROR_INVALIDDATA;
20912091 cbp += cbp;
20922092 }
libavcodec/msmpeg4dec.c+4−4
@@ -201,9 +201,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 200 unmodified lines
201201 *mb_type_ptr = MB_TYPE_INTRA;
202202 }
203203
204− h->c.bdsp.clear_blocks(h->c.block[0]);
204+ h->c.bdsp.clear_blocks(h->block[0]);
205205 for (i = 0; i < 6; i++) {
206− if (ff_msmpeg4_decode_block(ms, h->c.block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
206+ if (ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
207207 {
208208 av_log(h->c.avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n",
209209 h->c.mb_x, h->c.mb_y, i);
@@ -292,9 +292,9 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h) · 82 unmodified lines
292292 }
293293 }
294294
295− h->c.bdsp.clear_blocks(h->c.block[0]);
295+ h->c.bdsp.clear_blocks(h->block[0]);
296296 for (i = 0; i < 6; i++) {
297− if (ff_msmpeg4_decode_block(ms, h->c.block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
297+ if (ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
298298 {
299299 av_log(h->c.avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n",
300300 h->c.mb_x, h->c.mb_y, i);
libavcodec/rv10.c+1−1
@@ -516,7 +516,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 515 unmodified lines
516516 }
517517 if (h->c.pict_type != AV_PICTURE_TYPE_B)
518518 ff_h263_update_motion_val(&h->c);
519− ff_mpv_reconstruct_mb(&h->c, h->c.block);
519+ ff_mpv_reconstruct_mb(&h->c, h->block);
520520 if (h->c.loop_filter)
521521 ff_h263_loop_filter(&h->c);
522522
libavcodec/wmv2dec.c+5−5
@@ -500,7 +500,7 @@ static int wmv2_decode_mb(H263DecContext *const h) · 499 unmodified lines
500500 wmv2_pred_motion(w, &mx, &my);
501501
502502 if (cbp) {
503− h->c.bdsp.clear_blocks(h->c.block[0]);
503+ h->c.bdsp.clear_blocks(h->block[0]);
504504 if (ms->per_mb_rl_table) {
505505 ms->rl_table_index = decode012(&h->c.gb);
506506 ms->rl_chroma_table_index = ms->rl_table_index;
@@ -522,7 +522,7 @@ static int wmv2_decode_mb(H263DecContext *const h) · 15 unmodified lines
522522 h->c.mv[0][0][1] = my;
523523
524524 for (i = 0; i < 6; i++) {
525− if ((ret = wmv2_decode_inter_block(w, h->c.block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
525+ if ((ret = wmv2_decode_inter_block(w, h->block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
526526 av_log(h->c.avctx, AV_LOG_ERROR,
527527 "\nerror while decoding inter block: %d x %d (%d)\n",
528528 h->c.mb_x, h->c.mb_y, i);
@@ -547,9 +547,9 @@ static int wmv2_decode_mb(H263DecContext *const h) · 18 unmodified lines
547547 ms->rl_chroma_table_index = ms->rl_table_index;
548548 }
549549
550− h->c.bdsp.clear_blocks(h->c.block[0]);
550+ h->c.bdsp.clear_blocks(h->block[0]);
551551 for (i = 0; i < 6; i++) {
552− ret = ff_msmpeg4_decode_block(ms, h->c.block[i], i, (cbp >> (5 - i)) & 1, NULL);
552+ ret = ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL);
553553 if (ret < 0) {
554554 av_log(h->c.avctx, AV_LOG_ERROR,
555555 "\nerror while decoding intra block: %d x %d (%d)\n",
@@ -580,7 +580,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx) · 24 unmodified lines
580580
581581 decode_ext_header(w);
582582
583− return ff_intrax8_common_init(avctx, &w->x8, h->c.block[0],
583+ return ff_intrax8_common_init(avctx, &w->x8, h->block[0],
584584 s->mb_width, s->mb_height);
585585 }
586586

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