You've already forked FFmpeg
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:
@ -181,15 +181,15 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
|||||||
return 0;
|
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)
|
if (h->c.pict_type != AV_PICTURE_TYPE_B && !h->partitioned_frame && !h->c.er.error_occurred)
|
||||||
ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y);
|
ff_thread_progress_report(&h->c.cur_pic.ptr->progress, h->c.mb_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_slice(H263DecContext *const h)
|
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;
|
? (ER_AC_END | ER_AC_ERROR) : 0x7F;
|
||||||
const int mb_size = 16 >> h->c.avctx->lowres;
|
const int mb_size = 16 >> h->c.avctx->lowres;
|
||||||
int ret;
|
int ret;
|
||||||
@ -214,7 +214,7 @@ static int decode_slice(H263DecContext *const h)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h->c.partitioned_frame) {
|
if (h->partitioned_frame) {
|
||||||
const int qscale = h->c.qscale;
|
const int qscale = h->c.qscale;
|
||||||
|
|
||||||
if (CONFIG_MPEG4_DECODER && h->c.codec_id == AV_CODEC_ID_MPEG4)
|
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) {
|
if (++h->c.mb_x >= h->c.mb_width) {
|
||||||
h->c.mb_x = 0;
|
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);
|
ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
|
||||||
h->c.mb_y++;
|
h->c.mb_y++;
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ static int decode_slice(H263DecContext *const h)
|
|||||||
ff_h263_loop_filter(&h->c);
|
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);
|
ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
|
||||||
|
|
||||||
h->c.mb_x = 0;
|
h->c.mb_x = 0;
|
||||||
@ -551,7 +551,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
|
|||||||
return ret;
|
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);
|
s->pp_time, s->pb_time);
|
||||||
|
|
||||||
/* the second part of the wmv2 header contains the MB skip bits which
|
/* the second part of the wmv2 header contains the MB skip bits which
|
||||||
|
@ -73,6 +73,7 @@ typedef struct H263DecContext {
|
|||||||
int skipped_last_frame;
|
int skipped_last_frame;
|
||||||
int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5
|
int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5
|
||||||
int data_partitioning; ///< data partitioning flag from header
|
int data_partitioning; ///< data partitioning flag from header
|
||||||
|
int partitioned_frame; ///< is current frame partitioned
|
||||||
|
|
||||||
/* MSMPEG4 specific */
|
/* MSMPEG4 specific */
|
||||||
int slice_height; ///< in macroblocks
|
int slice_height; ///< in macroblocks
|
||||||
|
@ -391,7 +391,7 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
|
|||||||
|
|
||||||
while (v <= 0xFF) {
|
while (v <= 0xFF) {
|
||||||
if (h->c.pict_type == AV_PICTURE_TYPE_B ||
|
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;
|
break;
|
||||||
skip_bits(&h->gb, 8 + h->c.pict_type);
|
skip_bits(&h->gb, 8 + h->c.pict_type);
|
||||||
bits_count += 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
|
// FIXME add short header support
|
||||||
if (use_intra_dc_vlc) {
|
if (use_intra_dc_vlc) {
|
||||||
/* DC coef */
|
/* DC coef */
|
||||||
if (h->c.partitioned_frame) {
|
if (h->partitioned_frame) {
|
||||||
level = h->c.dc_val[h->c.block_index[n]];
|
level = h->c.dc_val[h->c.block_index[n]];
|
||||||
if (n < 4)
|
if (n < 4)
|
||||||
level = FASTDIV((level + (h->c.y_dc_scale >> 1)), h->c.y_dc_scale);
|
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.low_delay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h->c.partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
|
h->partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
|
||||||
if (h->c.partitioned_frame)
|
if (h->partitioned_frame)
|
||||||
h->decode_mb = mpeg4_decode_partitioned_mb;
|
h->decode_mb = mpeg4_decode_partitioned_mb;
|
||||||
else
|
else
|
||||||
h->decode_mb = mpeg4_decode_mb;
|
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)
|
if (get_bits_left(gb) <= 32)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
h->c.partitioned_frame = 0;
|
h->partitioned_frame = 0;
|
||||||
h->c.interlaced_dct = 0;
|
h->c.interlaced_dct = 0;
|
||||||
h->decode_mb = mpeg4_decode_studio_mb;
|
h->decode_mb = mpeg4_decode_studio_mb;
|
||||||
|
|
||||||
|
@ -1033,7 +1033,7 @@ static int mpeg4_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
mpeg4_encode_gop_header(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_bits32(&s->pb, VOP_STARTCODE); /* vop header */
|
||||||
put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */
|
put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */
|
||||||
|
@ -229,7 +229,6 @@ typedef struct MpegEncContext {
|
|||||||
uint16_t pb_field_time; ///< like above, just for interlaced
|
uint16_t pb_field_time; ///< like above, just for interlaced
|
||||||
int mcsel;
|
int mcsel;
|
||||||
int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
|
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
|
int low_delay; ///< no reordering needed / has no B-frames
|
||||||
|
|
||||||
/* MSMPEG4 specific */
|
/* MSMPEG4 specific */
|
||||||
|
@ -265,7 +265,7 @@ static void update_duplicate_context_after_me(MPVEncContext *const dst,
|
|||||||
COPY(lambda2);
|
COPY(lambda2);
|
||||||
COPY(c.frame_pred_frame_dct); // FIXME don't set in encode_header
|
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.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
|
#undef COPY
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2894,7 +2894,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
|
|||||||
static void write_slice_end(MPVEncContext *const s)
|
static void write_slice_end(MPVEncContext *const s)
|
||||||
{
|
{
|
||||||
if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4) {
|
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_merge_partitions(s);
|
||||||
|
|
||||||
ff_mpeg4_stuffing(&s->pb);
|
ff_mpeg4_stuffing(&s->pb);
|
||||||
@ -2907,7 +2907,7 @@ static void write_slice_end(MPVEncContext *const s)
|
|||||||
|
|
||||||
flush_put_bits(&s->pb);
|
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);
|
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[1] = 128 * 8 / 14;
|
||||||
s->c.last_dc[2] = 128 * 8 / 14;
|
s->c.last_dc[2] = 128 * 8 / 14;
|
||||||
#if CONFIG_MPEG4_ENCODER
|
#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);
|
av_assert1(s->c.codec_id == AV_CODEC_ID_MPEG4);
|
||||||
ff_mpeg4_init_partitions(s);
|
ff_mpeg4_init_partitions(s);
|
||||||
#endif
|
#endif
|
||||||
@ -3120,7 +3120,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
|
|||||||
if (s->c.start_mb_y != mb_y || mb_x != 0) {
|
if (s->c.start_mb_y != mb_y || mb_x != 0) {
|
||||||
write_slice_end(s);
|
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);
|
ff_mpeg4_init_partitions(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ typedef struct MPVEncContext {
|
|||||||
|
|
||||||
/* MPEG-4 specific */
|
/* MPEG-4 specific */
|
||||||
int data_partitioning; ///< data partitioning flag, set via option
|
int data_partitioning; ///< data partitioning flag, set via option
|
||||||
|
int partitioned_frame; ///< is current frame partitioned
|
||||||
int mpeg_quant;
|
int mpeg_quant;
|
||||||
PutBitContext tex_pb; ///< used for data partitioned VOPs
|
PutBitContext tex_pb; ///< used for data partitioned VOPs
|
||||||
PutBitContext pb2; ///< used for data partitioned VOPs
|
PutBitContext pb2; ///< used for data partitioned VOPs
|
||||||
|
Reference in New Issue
Block a user