1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

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).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-06-19 20:04:45 +02:00
parent b2be342ab6
commit 77add26918
7 changed files with 26 additions and 23 deletions

View File

@ -272,7 +272,7 @@ static int decode_slice(H263DecContext *const h)
if (ret < 0) {
const int xy = h->c.mb_x + h->c.mb_y * h->c.mb_stride;
if (ret == SLICE_END) {
ff_mpv_reconstruct_mb(&h->c, h->c.block);
ff_mpv_reconstruct_mb(&h->c, h->block);
if (h->c.loop_filter)
ff_h263_loop_filter(&h->c);
@ -305,7 +305,7 @@ static int decode_slice(H263DecContext *const h)
return AVERROR_INVALIDDATA;
}
ff_mpv_reconstruct_mb(&h->c, h->c.block);
ff_mpv_reconstruct_mb(&h->c, h->block);
if (h->c.loop_filter)
ff_h263_loop_filter(&h->c);
}

View File

@ -22,6 +22,7 @@
#include "mpegvideo.h"
#include "vlc.h"
#include "libavutil/mem_internal.h"
/**
* Return value for header parsers if frame is not coded.
@ -47,6 +48,8 @@ typedef struct H263DecContext {
MPVContext c;
int (*decode_mb)(struct H263DecContext *h);
DECLARE_ALIGNED_32(int16_t, block)[6][64];
} H263DecContext;
int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code);

View File

@ -808,7 +808,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
}
}while(cbpc == 20);
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
dquant = cbpc & 8;
h->c.mb_intra = ((cbpc & 4) != 0);
@ -910,7 +910,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
h->c.mb_intra = IS_INTRA(mb_type);
if(HAS_CBP(mb_type)){
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
cbpc = get_vlc2(&h->c.gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
if (h->c.mb_intra) {
dquant = IS_QUANT(mb_type);
@ -1012,7 +1012,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
}
}while(cbpc == 8);
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
dquant = cbpc & 4;
h->c.mb_intra = 1;
@ -1051,7 +1051,7 @@ intra:
/* decode each block */
for (i = 0; i < 6; i++) {
if (h263_decode_block(h, h->c.block[i], i, cbp&32) < 0)
if (h263_decode_block(h, h->block[i], i, cbp&32) < 0)
return -1;
cbp+=cbp;
}

View File

@ -1708,10 +1708,10 @@ static int mpeg4_decode_partitioned_mb(H263DecContext *const h)
if (!IS_SKIP(mb_type)) {
int i;
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
/* decode each block */
for (i = 0; i < 6; i++) {
if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32, h->c.mb_intra,
if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32, h->c.mb_intra,
use_intra_dc_vlc, ctx->rvlc) < 0) {
av_log(h->c.avctx, AV_LOG_ERROR,
"texture corrupted at %d %d %d\n",
@ -1792,7 +1792,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
h->c.mb_intra = ((cbpc & 4) != 0);
if (h->c.mb_intra)
goto intra;
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
if (h->c.pict_type == AV_PICTURE_TYPE_S &&
ctx->vol_sprite_usage == GMC_SPRITE && (cbpc & 16) == 0)
@ -1936,7 +1936,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
if (modb2) {
cbp = 0;
} else {
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
cbp = get_bits(&h->c.gb, 6);
}
@ -2073,10 +2073,10 @@ intra:
if (!h->c.progressive_sequence)
h->c.interlaced_dct = get_bits1(&h->c.gb);
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
/* decode each block */
for (i = 0; i < 6; i++) {
if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32,
if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32,
1, use_intra_dc_vlc, 0) < 0)
return AVERROR_INVALIDDATA;
cbp += cbp;
@ -2086,7 +2086,7 @@ intra:
/* decode each block */
for (i = 0; i < 6; i++) {
if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32, 0, 0, 0) < 0)
if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32, 0, 0, 0) < 0)
return AVERROR_INVALIDDATA;
cbp += cbp;
}

View File

@ -201,9 +201,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
*mb_type_ptr = MB_TYPE_INTRA;
}
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
for (i = 0; i < 6; i++) {
if (ff_msmpeg4_decode_block(ms, h->c.block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
if (ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
{
av_log(h->c.avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n",
h->c.mb_x, h->c.mb_y, i);
@ -292,9 +292,9 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h)
}
}
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
for (i = 0; i < 6; i++) {
if (ff_msmpeg4_decode_block(ms, h->c.block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
if (ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
{
av_log(h->c.avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n",
h->c.mb_x, h->c.mb_y, i);

View File

@ -516,7 +516,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
}
if (h->c.pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(&h->c);
ff_mpv_reconstruct_mb(&h->c, h->c.block);
ff_mpv_reconstruct_mb(&h->c, h->block);
if (h->c.loop_filter)
ff_h263_loop_filter(&h->c);

View File

@ -500,7 +500,7 @@ static int wmv2_decode_mb(H263DecContext *const h)
wmv2_pred_motion(w, &mx, &my);
if (cbp) {
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
if (ms->per_mb_rl_table) {
ms->rl_table_index = decode012(&h->c.gb);
ms->rl_chroma_table_index = ms->rl_table_index;
@ -522,7 +522,7 @@ static int wmv2_decode_mb(H263DecContext *const h)
h->c.mv[0][0][1] = my;
for (i = 0; i < 6; i++) {
if ((ret = wmv2_decode_inter_block(w, h->c.block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
if ((ret = wmv2_decode_inter_block(w, h->block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
av_log(h->c.avctx, AV_LOG_ERROR,
"\nerror while decoding inter block: %d x %d (%d)\n",
h->c.mb_x, h->c.mb_y, i);
@ -547,9 +547,9 @@ static int wmv2_decode_mb(H263DecContext *const h)
ms->rl_chroma_table_index = ms->rl_table_index;
}
h->c.bdsp.clear_blocks(h->c.block[0]);
h->c.bdsp.clear_blocks(h->block[0]);
for (i = 0; i < 6; i++) {
ret = ff_msmpeg4_decode_block(ms, h->c.block[i], i, (cbp >> (5 - i)) & 1, NULL);
ret = ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL);
if (ret < 0) {
av_log(h->c.avctx, AV_LOG_ERROR,
"\nerror while decoding intra block: %d x %d (%d)\n",
@ -580,7 +580,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
decode_ext_header(w);
return ff_intrax8_common_init(avctx, &w->x8, h->c.block[0],
return ff_intrax8_common_init(avctx, &w->x8, h->block[0],
s->mb_width, s->mb_height);
}