diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index d06f54cd8a..c3362e418f 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -68,6 +68,8 @@ typedef struct Mpeg4DecContext { int vol_sprite_usage; // reversible vlc int rvlc; + ///< could this stream contain resync markers + int resync_marker; } Mpeg4DecContext; /* dc encoding for mpeg4 */ diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index b7549fa04b..d5329ce7d8 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -109,12 +109,13 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) * check if the next stuff is a resync marker or the end. * @return 0 if not */ -static inline int mpeg4_is_resync(MpegEncContext *s) +static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) { + MpegEncContext *s = &ctx->m; int bits_count = get_bits_count(&s->gb); int v = show_bits(&s->gb, 16); - if (s->workaround_bugs & FF_BUG_NO_PADDING && !s->resync_marker) + if (s->workaround_bugs & FF_BUG_NO_PADDING && !ctx->resync_marker) return 0; while (v <= 0xFF) { @@ -1268,12 +1269,12 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64]) /* per-MB end of slice check */ if (--s->mb_num_left <= 0) { - if (mpeg4_is_resync(s)) + if (mpeg4_is_resync(ctx)) return SLICE_END; else return SLICE_NOEND; } else { - if (mpeg4_is_resync(s)) { + if (mpeg4_is_resync(ctx)) { const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1; if (s->cbp_table[xy + delta]) return SLICE_END; @@ -1632,7 +1633,7 @@ intra: end: /* per-MB end of slice check */ if (s->codec_id == AV_CODEC_ID_MPEG4) { - int next = mpeg4_is_resync(s); + int next = mpeg4_is_resync(ctx); if (next) { if (s->mb_x + s->mb_y*s->mb_width + 1 > next && (s->avctx->err_recognition & AV_EF_AGGRESSIVE)) { return -1; @@ -1968,7 +1969,7 @@ no_cplx_est: s->cplx_estimation_trash_b = 0; } - s->resync_marker = !get_bits1(gb); /* resync_marker_disabled */ + ctx->resync_marker = !get_bits1(gb); /* resync_marker_disabled */ s->data_partitioning = get_bits1(gb); if (s->data_partitioning) @@ -2315,7 +2316,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")), gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first, s->quarter_sample ? "q" : "h", - s->data_partitioning, s->resync_marker, + s->data_partitioning, ctx->resync_marker, s->num_sprite_warping_points, s->sprite_warping_accuracy, 1 - s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold, diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 468c82da7b..c0c675ffe2 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -615,7 +615,6 @@ typedef struct MpegEncContext { int low_latency_sprite; int data_partitioning; ///< data partitioning flag from header int partitioned_frame; ///< is current frame partitioned - int resync_marker; ///< could this stream contain resync markers int low_delay; ///< no reordering needed / has no b-frames int vo_type; int vol_control_parameters; ///< does the stream contain the low_delay flag, used to workaround buggy encoders diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index d54596661f..2fdb10fb1b 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -72,7 +72,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ pic_param->vol_fields.bits.quarter_sample = s->quarter_sample; pic_param->vol_fields.bits.data_partitioned = s->data_partitioning; pic_param->vol_fields.bits.reversible_vlc = ctx->rvlc; - pic_param->vol_fields.bits.resync_marker_disable = !s->resync_marker; + pic_param->vol_fields.bits.resync_marker_disable = !ctx->resync_marker; pic_param->no_of_sprite_warping_points = s->num_sprite_warping_points; for (i = 0; i < s->num_sprite_warping_points && i < 3; i++) { pic_param->sprite_trajectory_du[i] = s->sprite_traj[i][0]; diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 0eebb9cdc1..32a3843e9b 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -345,7 +345,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, render->info.vc1.range_mapuv = v->range_mapuv; /* Specific to simple/main profile only */ render->info.vc1.multires = v->multires; - render->info.vc1.syncmarker = v->s.resync_marker; + render->info.vc1.syncmarker = v->resync_marker; render->info.vc1.rangered = v->rangered | (v->rangeredfrm << 1); render->info.vc1.maxbframes = v->s.max_b_frames; @@ -383,9 +383,10 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, #endif /* (CONFIG_VC1_VDPAU_DECODER */ #if CONFIG_MPEG4_VDPAU_DECODER -void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, +void ff_vdpau_mpeg4_decode_picture(Mpeg4DecContext *ctx, const uint8_t *buf, int buf_size) { + MpegEncContext *s = &ctx->m; struct vdpau_render_state *render, *last, *next; int i; @@ -403,7 +404,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, render->info.mpeg4.vop_coding_type = 0; render->info.mpeg4.vop_fcode_forward = s->f_code; render->info.mpeg4.vop_fcode_backward = s->b_code; - render->info.mpeg4.resync_marker_disable = !s->resync_marker; + render->info.mpeg4.resync_marker_disable = !ctx->resync_marker; render->info.mpeg4.interlaced = !s->progressive_sequence; render->info.mpeg4.quant_type = s->mpeg_quant; render->info.mpeg4.quarter_sample = s->quarter_sample; diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h index 32969963c7..cc634111b4 100644 --- a/libavcodec/vdpau_internal.h +++ b/libavcodec/vdpau_internal.h @@ -32,6 +32,7 @@ #include "h264.h" #include "avcodec.h" +#include "mpeg4video.h" #include "mpegvideo.h" #include "version.h" @@ -95,7 +96,7 @@ void ff_vdpau_h264_picture_complete(H264Context *h); void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, int buf_size); -void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, +void ff_vdpau_mpeg4_decode_picture(Mpeg4DecContext *s, const uint8_t *buf, int buf_size); #endif /* AVCODEC_VDPAU_INTERNAL_H */ diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index 84683a4779..282796eafa 100644 --- a/libavcodec/vdpau_mpeg4.c +++ b/libavcodec/vdpau_mpeg4.c @@ -24,13 +24,15 @@ #include #include "avcodec.h" +#include "mpeg4video.h" #include "vdpau.h" #include "vdpau_internal.h" static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - MpegEncContext * const s = avctx->priv_data; + Mpeg4DecContext *ctx = avctx->priv_data; + MpegEncContext * const s = &ctx->m; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoMPEG4Part2 *info = &pic_ctx->info.mpeg4; @@ -62,7 +64,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, info->vop_time_increment_resolution = s->avctx->time_base.den; info->vop_fcode_forward = s->f_code; info->vop_fcode_backward = s->b_code; - info->resync_marker_disable = !s->resync_marker; + info->resync_marker_disable = !ctx->resync_marker; info->interlaced = !s->progressive_sequence; info->quant_type = s->mpeg_quant; info->quarter_sample = s->quarter_sample;