Instead add the necessary blocks directly to H263DecContext (only six are needed, not 12 as ff_mpv_common_init() currently allocates).
Unified · Split
| @@ -272,7 +272,7 @@ static int decode_slice(H263DecContext *const h) · 271 unmodified lines | ||
| 272 | 272 | if (ret < 0) { |
| 273 | 273 | const int xy = h->c.mb_x + h->c.mb_y * h->c.mb_stride; |
| 274 | 274 | if (ret == SLICE_END) { |
| 275 | − ff_mpv_reconstruct_mb(&h->c, h->c.block); | |
| 275 | + ff_mpv_reconstruct_mb(&h->c, h->block); | |
| 276 | 276 | if (h->c.loop_filter) |
| 277 | 277 | ff_h263_loop_filter(&h->c); |
| 278 | 278 | |
| @@ -305,7 +305,7 @@ static int decode_slice(H263DecContext *const h) · 26 unmodified lines | ||
| 305 | 305 | return AVERROR_INVALIDDATA; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | − ff_mpv_reconstruct_mb(&h->c, h->c.block); | |
| 308 | + ff_mpv_reconstruct_mb(&h->c, h->block); | |
| 309 | 309 | if (h->c.loop_filter) |
| 310 | 310 | ff_h263_loop_filter(&h->c); |
| 311 | 311 | } |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "mpegvideo.h" |
| 24 | 24 | #include "vlc.h" |
| 25 | +#include "libavutil/mem_internal.h" | |
| 25 | 26 | |
| 26 | 27 | /** |
| 27 | 28 | * Return value for header parsers if frame is not coded. |
| @@ -47,6 +48,8 @@ typedef struct H263DecContext { · 19 unmodified lines | ||
| 47 | 48 | MPVContext c; |
| 48 | 49 | |
| 49 | 50 | int (*decode_mb)(struct H263DecContext *h); |
| 51 | + | |
| 52 | + DECLARE_ALIGNED_32(int16_t, block)[6][64]; | |
| 50 | 53 | } H263DecContext; |
| 51 | 54 | |
| 52 | 55 | int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code); |
| @@ -808,7 +808,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 807 unmodified lines | ||
| 808 | 808 | } |
| 809 | 809 | }while(cbpc == 20); |
| 810 | 810 | |
| 811 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 811 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 812 | 812 | |
| 813 | 813 | dquant = cbpc & 8; |
| 814 | 814 | h->c.mb_intra = ((cbpc & 4) != 0); |
| @@ -910,7 +910,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 95 unmodified lines | ||
| 910 | 910 | |
| 911 | 911 | h->c.mb_intra = IS_INTRA(mb_type); |
| 912 | 912 | if(HAS_CBP(mb_type)){ |
| 913 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 913 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 914 | 914 | cbpc = get_vlc2(&h->c.gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1); |
| 915 | 915 | if (h->c.mb_intra) { |
| 916 | 916 | dquant = IS_QUANT(mb_type); |
| @@ -1012,7 +1012,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 95 unmodified lines | ||
| 1012 | 1012 | } |
| 1013 | 1013 | }while(cbpc == 8); |
| 1014 | 1014 | |
| 1015 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 1015 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 1016 | 1016 | |
| 1017 | 1017 | dquant = cbpc & 4; |
| 1018 | 1018 | h->c.mb_intra = 1; |
| @@ -1051,7 +1051,7 @@ intra: · 32 unmodified lines | ||
| 1051 | 1051 | |
| 1052 | 1052 | /* decode each block */ |
| 1053 | 1053 | 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) | |
| 1055 | 1055 | return -1; |
| 1056 | 1056 | cbp+=cbp; |
| 1057 | 1057 | } |
| @@ -1708,10 +1708,10 @@ static int mpeg4_decode_partitioned_mb(H263DecContext *const h) · 1707 unmodified lines | ||
| 1708 | 1708 | |
| 1709 | 1709 | if (!IS_SKIP(mb_type)) { |
| 1710 | 1710 | int i; |
| 1711 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 1711 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 1712 | 1712 | /* decode each block */ |
| 1713 | 1713 | 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, | |
| 1715 | 1715 | use_intra_dc_vlc, ctx->rvlc) < 0) { |
| 1716 | 1716 | av_log(h->c.avctx, AV_LOG_ERROR, |
| 1717 | 1717 | "texture corrupted at %d %d %d\n", |
| @@ -1792,7 +1792,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 74 unmodified lines | ||
| 1792 | 1792 | h->c.mb_intra = ((cbpc & 4) != 0); |
| 1793 | 1793 | if (h->c.mb_intra) |
| 1794 | 1794 | goto intra; |
| 1795 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 1795 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 1796 | 1796 | |
| 1797 | 1797 | if (h->c.pict_type == AV_PICTURE_TYPE_S && |
| 1798 | 1798 | ctx->vol_sprite_usage == GMC_SPRITE && (cbpc & 16) == 0) |
| @@ -1936,7 +1936,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 137 unmodified lines | ||
| 1936 | 1936 | if (modb2) { |
| 1937 | 1937 | cbp = 0; |
| 1938 | 1938 | } else { |
| 1939 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 1939 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 1940 | 1940 | cbp = get_bits(&h->c.gb, 6); |
| 1941 | 1941 | } |
| 1942 | 1942 | |
| @@ -2073,10 +2073,10 @@ intra: · 130 unmodified lines | ||
| 2073 | 2073 | if (!h->c.progressive_sequence) |
| 2074 | 2074 | h->c.interlaced_dct = get_bits1(&h->c.gb); |
| 2075 | 2075 | |
| 2076 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 2076 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 2077 | 2077 | /* decode each block */ |
| 2078 | 2078 | 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, | |
| 2080 | 2080 | 1, use_intra_dc_vlc, 0) < 0) |
| 2081 | 2081 | return AVERROR_INVALIDDATA; |
| 2082 | 2082 | cbp += cbp; |
| @@ -2086,7 +2086,7 @@ intra: · 3 unmodified lines | ||
| 2086 | 2086 | |
| 2087 | 2087 | /* decode each block */ |
| 2088 | 2088 | 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) | |
| 2090 | 2090 | return AVERROR_INVALIDDATA; |
| 2091 | 2091 | cbp += cbp; |
| 2092 | 2092 | } |
| @@ -201,9 +201,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 200 unmodified lines | ||
| 201 | 201 | *mb_type_ptr = MB_TYPE_INTRA; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 204 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 205 | 205 | 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) | |
| 207 | 207 | { |
| 208 | 208 | av_log(h->c.avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", |
| 209 | 209 | h->c.mb_x, h->c.mb_y, i); |
| @@ -292,9 +292,9 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h) · 82 unmodified lines | ||
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 295 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 296 | 296 | 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) | |
| 298 | 298 | { |
| 299 | 299 | av_log(h->c.avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", |
| 300 | 300 | h->c.mb_x, h->c.mb_y, i); |
| @@ -516,7 +516,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 515 unmodified lines | ||
| 516 | 516 | } |
| 517 | 517 | if (h->c.pict_type != AV_PICTURE_TYPE_B) |
| 518 | 518 | 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); | |
| 520 | 520 | if (h->c.loop_filter) |
| 521 | 521 | ff_h263_loop_filter(&h->c); |
| 522 | 522 | |
| @@ -500,7 +500,7 @@ static int wmv2_decode_mb(H263DecContext *const h) · 499 unmodified lines | ||
| 500 | 500 | wmv2_pred_motion(w, &mx, &my); |
| 501 | 501 | |
| 502 | 502 | if (cbp) { |
| 503 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 503 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 504 | 504 | if (ms->per_mb_rl_table) { |
| 505 | 505 | ms->rl_table_index = decode012(&h->c.gb); |
| 506 | 506 | ms->rl_chroma_table_index = ms->rl_table_index; |
| @@ -522,7 +522,7 @@ static int wmv2_decode_mb(H263DecContext *const h) · 15 unmodified lines | ||
| 522 | 522 | h->c.mv[0][0][1] = my; |
| 523 | 523 | |
| 524 | 524 | 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) { | |
| 526 | 526 | av_log(h->c.avctx, AV_LOG_ERROR, |
| 527 | 527 | "\nerror while decoding inter block: %d x %d (%d)\n", |
| 528 | 528 | h->c.mb_x, h->c.mb_y, i); |
| @@ -547,9 +547,9 @@ static int wmv2_decode_mb(H263DecContext *const h) · 18 unmodified lines | ||
| 547 | 547 | ms->rl_chroma_table_index = ms->rl_table_index; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | − h->c.bdsp.clear_blocks(h->c.block[0]); | |
| 550 | + h->c.bdsp.clear_blocks(h->block[0]); | |
| 551 | 551 | 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); | |
| 553 | 553 | if (ret < 0) { |
| 554 | 554 | av_log(h->c.avctx, AV_LOG_ERROR, |
| 555 | 555 | "\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 | ||
| 580 | 580 | |
| 581 | 581 | decode_ext_header(w); |
| 582 | 582 | |
| 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], | |
| 584 | 584 | s->mb_width, s->mb_height); |
| 585 | 585 | } |
| 586 | 586 | |