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

avcodec/mpegvideo: Move partitioned_frame to {H263Dec,MPVEnc}Context

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-06-22 14:54:43 +02:00
parent 0984724d1e
commit 60f51bdaac
7 changed files with 21 additions and 20 deletions

View File

@ -181,15 +181,15 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
return 0;
}
static void report_decode_progress(MpegEncContext *s)
static void report_decode_progress(H263DecContext *const h)
{
if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred)
ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y);
if (h->c.pict_type != AV_PICTURE_TYPE_B && !h->partitioned_frame && !h->c.er.error_occurred)
ff_thread_progress_report(&h->c.cur_pic.ptr->progress, h->c.mb_y);
}
static int decode_slice(H263DecContext *const h)
{
const int part_mask = h->c.partitioned_frame
const int part_mask = h->partitioned_frame
? (ER_AC_END | ER_AC_ERROR) : 0x7F;
const int mb_size = 16 >> h->c.avctx->lowres;
int ret;
@ -214,7 +214,7 @@ static int decode_slice(H263DecContext *const h)
return ret;
}
if (h->c.partitioned_frame) {
if (h->partitioned_frame) {
const int qscale = h->c.qscale;
if (CONFIG_MPEG4_DECODER && h->c.codec_id == AV_CODEC_ID_MPEG4)
@ -290,7 +290,7 @@ static int decode_slice(H263DecContext *const h)
if (++h->c.mb_x >= h->c.mb_width) {
h->c.mb_x = 0;
report_decode_progress(&h->c);
report_decode_progress(h);
ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
h->c.mb_y++;
}
@ -317,7 +317,7 @@ static int decode_slice(H263DecContext *const h)
ff_h263_loop_filter(&h->c);
}
report_decode_progress(&h->c);
report_decode_progress(h);
ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
h->c.mb_x = 0;
@ -551,7 +551,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
return ret;
}
ff_mpv_er_frame_start_ext(s, s->partitioned_frame,
ff_mpv_er_frame_start_ext(s, h->partitioned_frame,
s->pp_time, s->pb_time);
/* the second part of the wmv2 header contains the MB skip bits which

View File

@ -73,6 +73,7 @@ typedef struct H263DecContext {
int skipped_last_frame;
int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5
int data_partitioning; ///< data partitioning flag from header
int partitioned_frame; ///< is current frame partitioned
/* MSMPEG4 specific */
int slice_height; ///< in macroblocks

View File

@ -391,7 +391,7 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
while (v <= 0xFF) {
if (h->c.pict_type == AV_PICTURE_TYPE_B ||
(v >> (8 - h->c.pict_type) != 1) || h->c.partitioned_frame)
(v >> (8 - h->c.pict_type) != 1) || h->partitioned_frame)
break;
skip_bits(&h->gb, 8 + h->c.pict_type);
bits_count += 8 + h->c.pict_type;
@ -1395,7 +1395,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
// FIXME add short header support
if (use_intra_dc_vlc) {
/* DC coef */
if (h->c.partitioned_frame) {
if (h->partitioned_frame) {
level = h->c.dc_val[h->c.block_index[n]];
if (n < 4)
level = FASTDIV((level + (h->c.y_dc_scale >> 1)), h->c.y_dc_scale);
@ -3222,8 +3222,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
h->c.low_delay = 0;
}
h->c.partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
if (h->c.partitioned_frame)
h->partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
if (h->partitioned_frame)
h->decode_mb = mpeg4_decode_partitioned_mb;
else
h->decode_mb = mpeg4_decode_mb;
@ -3513,7 +3513,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
if (get_bits_left(gb) <= 32)
return 0;
h->c.partitioned_frame = 0;
h->partitioned_frame = 0;
h->c.interlaced_dct = 0;
h->decode_mb = mpeg4_decode_studio_mb;

View File

@ -1033,7 +1033,7 @@ static int mpeg4_encode_picture_header(MPVMainEncContext *const m)
mpeg4_encode_gop_header(m);
}
s->c.partitioned_frame = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B;
s->partitioned_frame = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B;
put_bits32(&s->pb, VOP_STARTCODE); /* vop header */
put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */

View File

@ -229,7 +229,6 @@ typedef struct MpegEncContext {
uint16_t pb_field_time; ///< like above, just for interlaced
int mcsel;
int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
int partitioned_frame; ///< is current frame partitioned
int low_delay; ///< no reordering needed / has no B-frames
/* MSMPEG4 specific */

View File

@ -265,7 +265,7 @@ static void update_duplicate_context_after_me(MPVEncContext *const dst,
COPY(lambda2);
COPY(c.frame_pred_frame_dct); // FIXME don't set in encode_header
COPY(c.progressive_frame); // FIXME don't set in encode_header
COPY(c.partitioned_frame); // FIXME don't set in encode_header
COPY(partitioned_frame); // FIXME don't set in encode_header
#undef COPY
}
@ -2894,7 +2894,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
static void write_slice_end(MPVEncContext *const s)
{
if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4) {
if (s->c.partitioned_frame)
if (s->partitioned_frame)
ff_mpeg4_merge_partitions(s);
ff_mpeg4_stuffing(&s->pb);
@ -2907,7 +2907,7 @@ static void write_slice_end(MPVEncContext *const s)
flush_put_bits(&s->pb);
if ((s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->c.partitioned_frame)
if ((s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->partitioned_frame)
s->misc_bits+= get_bits_diff(s);
}
@ -3024,7 +3024,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->c.last_dc[1] = 128 * 8 / 14;
s->c.last_dc[2] = 128 * 8 / 14;
#if CONFIG_MPEG4_ENCODER
} else if (s->c.partitioned_frame) {
} else if (s->partitioned_frame) {
av_assert1(s->c.codec_id == AV_CODEC_ID_MPEG4);
ff_mpeg4_init_partitions(s);
#endif
@ -3120,7 +3120,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
if (s->c.start_mb_y != mb_y || mb_x != 0) {
write_slice_end(s);
if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && s->c.partitioned_frame)
if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
}

View File

@ -162,6 +162,7 @@ typedef struct MPVEncContext {
/* MPEG-4 specific */
int data_partitioning; ///< data partitioning flag, set via option
int partitioned_frame; ///< is current frame partitioned
int mpeg_quant;
PutBitContext tex_pb; ///< used for data partitioned VOPs
PutBitContext pb2; ///< used for data partitioned VOPs