/*
- * MPEG4 decoder.
+ * MPEG-4 decoder
* Copyright (c) 2000,2001 Fabrice Bellard
* Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at>
*
x = get_xbits(gb, length);
if (!(ctx->divx_version == 500 && ctx->divx_build == 413))
- check_marker(gb, "before sprite_trajectory");
+ check_marker(s->avctx, gb, "before sprite_trajectory");
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length > 0)
y = get_xbits(gb, length);
- check_marker(gb, "after sprite_trajectory");
+ check_marker(s->avctx, gb, "after sprite_trajectory");
ctx->sprite_traj[i][0] = d[i][0] = x;
ctx->sprite_traj[i][1] = d[i][1] = y;
}
while ((1 << alpha) < w)
alpha++;
while ((1 << beta) < h)
- beta++; /* typo in the mpeg4 std for the definition of w' and h' */
+ beta++; /* typo in the MPEG-4 std for the definition of w' and h' */
w2 = 1 << alpha;
h2 = 1 << beta;
/* sprite_ref[3][0] = (a >> 1) * (2 * vop_ref[3][0] + d[0][0] + d[1][0] + d[2][0] + d[3][0]);
* sprite_ref[3][1] = (a >> 1) * (2 * vop_ref[3][1] + d[0][1] + d[1][1] + d[2][1] + d[3][1]); */
- /* this is mostly identical to the mpeg4 std (and is totally unreadable
+ /* This is mostly identical to the MPEG-4 std (and is totally unreadable
* because of that...). Perhaps it should be reordered to be more readable.
* The idea behind this virtual_ref mess is to be able to use shifts later
* per pixel instead of divides so the distance between points is converted
}
static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) {
+ MpegEncContext *s = &ctx->m;
int len = FFMIN(ctx->time_increment_bits + 3, 15);
get_bits(gb, len);
if (get_bits1(gb))
get_bits(gb, len);
- check_marker(gb, "after new_pred");
+ check_marker(s->avctx, gb, "after new_pred");
return 0;
}
while (get_bits1(&s->gb) != 0)
time_incr++;
- check_marker(&s->gb, "before time_increment in video packed header");
+ check_marker(s->avctx, &s->gb, "before time_increment in video packed header");
skip_bits(&s->gb, ctx->time_increment_bits); /* time_increment */
- check_marker(&s->gb, "before vop_coding_type in video packed header");
+ check_marker(s->avctx, &s->gb, "before vop_coding_type in video packed header");
skip_bits(&s->gb, 2); /* vop coding type */
// FIXME not rect stuff here
ff_thread_await_progress(&s->next_picture_ptr->tf, s->mb_y, 0);
}
- /* if we skipped it in the future P Frame than skip it now too */
+ /* if we skipped it in the future P-frame than skip it now too */
s->mb_skipped = s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
if (s->mb_skipped) {
hours = get_bits(gb, 5);
minutes = get_bits(gb, 6);
- check_marker(gb, "in gop_header");
+ check_marker(s->avctx, gb, "in gop_header");
seconds = get_bits(gb, 6);
s->time_base = seconds + 60*(minutes + 60*hours);
s->low_delay = get_bits1(gb);
if (get_bits1(gb)) { /* vbv parameters */
get_bits(gb, 15); /* first_half_bitrate */
- check_marker(gb, "after first_half_bitrate");
+ check_marker(s->avctx, gb, "after first_half_bitrate");
get_bits(gb, 15); /* latter_half_bitrate */
- check_marker(gb, "after latter_half_bitrate");
+ check_marker(s->avctx, gb, "after latter_half_bitrate");
get_bits(gb, 15); /* first_half_vbv_buffer_size */
- check_marker(gb, "after first_half_vbv_buffer_size");
+ check_marker(s->avctx, gb, "after first_half_vbv_buffer_size");
get_bits(gb, 3); /* latter_half_vbv_buffer_size */
get_bits(gb, 11); /* first_half_vbv_occupancy */
- check_marker(gb, "after first_half_vbv_occupancy");
+ check_marker(s->avctx, gb, "after first_half_vbv_occupancy");
get_bits(gb, 15); /* latter_half_vbv_occupancy */
- check_marker(gb, "after latter_half_vbv_occupancy");
+ check_marker(s->avctx, gb, "after latter_half_vbv_occupancy");
}
} else {
/* is setting low delay flag only once the smartest thing to do?
- * low delay detection won't be overridden. */
+ * low delay detection will not be overridden. */
if (s->picture_number == 0) {
switch(s->vo_type) {
case SIMPLE_VO_TYPE:
skip_bits(gb, 4); /* video_object_layer_shape_extension */
}
- check_marker(gb, "before time_increment_resolution");
+ check_marker(s->avctx, gb, "before time_increment_resolution");
s->avctx->framerate.num = get_bits(gb, 16);
if (!s->avctx->framerate.num) {
if (ctx->time_increment_bits < 1)
ctx->time_increment_bits = 1;
- check_marker(gb, "before fixed_vop_rate");
+ check_marker(s->avctx, gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0) /* fixed_vop_rate */
s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits);
if (ctx->shape != BIN_ONLY_SHAPE) {
if (ctx->shape == RECT_SHAPE) {
- check_marker(gb, "before width");
+ check_marker(s->avctx, gb, "before width");
width = get_bits(gb, 13);
- check_marker(gb, "before height");
+ check_marker(s->avctx, gb, "before height");
height = get_bits(gb, 13);
- check_marker(gb, "after height");
+ check_marker(s->avctx, gb, "after height");
if (width && height && /* they should be non zero but who knows */
!(s->width && s->codec_tag == AV_RL32("MP4S"))) {
if (s->width && s->height &&
s->interlaced_dct = 0;
if (!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO, /* OBMC Disable */
- "MPEG4 OBMC not supported (very likely buggy encoder)\n");
+ "MPEG-4 OBMC not supported (very likely buggy encoder)\n");
if (vo_ver_id == 1)
ctx->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
else
ctx->vol_sprite_usage == GMC_SPRITE) {
if (ctx->vol_sprite_usage == STATIC_SPRITE) {
skip_bits(gb, 13); // sprite_width
- check_marker(gb, "after sprite_width");
+ check_marker(s->avctx, gb, "after sprite_width");
skip_bits(gb, 13); // sprite_height
- check_marker(gb, "after sprite_height");
+ check_marker(s->avctx, gb, "after sprite_height");
skip_bits(gb, 13); // sprite_left
- check_marker(gb, "after sprite_left");
+ check_marker(s->avctx, gb, "after sprite_left");
skip_bits(gb, 13); // sprite_top
- check_marker(gb, "after sprite_top");
+ check_marker(s->avctx, gb, "after sprite_top");
}
ctx->num_sprite_warping_points = get_bits(gb, 6);
if (ctx->num_sprite_warping_points > 3) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* intra_cae */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* inter_cae */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* no_update */
- ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* upampling */
+ ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* upsampling */
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* intra_blocks */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* inter4v_blocks */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* not coded blocks */
}
- if (!check_marker(gb, "in complexity estimation part 1")) {
+ if (!check_marker(s->avctx, gb, "in complexity estimation part 1")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel2 */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel4 */
}
- if (!check_marker(gb, "in complexity estimation part 2")) {
+ if (!check_marker(s->avctx, gb, "in complexity estimation part 2")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
while (get_bits1(gb) != 0)
time_incr++;
- check_marker(gb, "before time_increment");
+ check_marker(s->avctx, gb, "before time_increment");
if (ctx->time_increment_bits == 0 ||
!(show_bits(gb, ctx->time_increment_bits + 1) & 1)) {
if (s->pp_time <= s->pb_time ||
s->pp_time <= s->pp_time - s->pb_time ||
s->pp_time <= 0) {
- /* messed up order, maybe after seeking? skipping current b-frame */
+ /* messed up order, maybe after seeking? skipping current B-frame */
return FRAME_SKIPPED;
}
ff_mpeg4_init_direct_mv(s);
pts = AV_NOPTS_VALUE;
ff_dlog(s->avctx, "MPEG4 PTS: %"PRId64"\n", pts);
- check_marker(gb, "before vop_coded");
+ check_marker(s->avctx, gb, "before vop_coded");
/* vop coded */
if (get_bits1(gb) != 1) {
if (ctx->shape != RECT_SHAPE) {
if (ctx->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
skip_bits(gb, 13); /* width */
- check_marker(gb, "after width");
+ check_marker(s->avctx, gb, "after width");
skip_bits(gb, 13); /* height */
- check_marker(gb, "after height");
+ check_marker(s->avctx, gb, "after height");
skip_bits(gb, 13); /* hor_spat_ref */
- check_marker(gb, "after hor_spat_ref");
+ check_marker(s->avctx, gb, "after hor_spat_ref");
skip_bits(gb, 13); /* ver_spat_ref */
}
skip_bits1(gb); /* change_CR_disable */
s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision);
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR,
- "Error, header damaged or not MPEG4 header (qscale=0)\n");
+ "Error, header damaged or not MPEG-4 header (qscale=0)\n");
return AVERROR_INVALIDDATA; // makes no sense to continue, as there is nothing left from the image then
}
s->f_code = get_bits(gb, 3); /* fcode_for */
if (s->f_code == 0) {
av_log(s->avctx, AV_LOG_ERROR,
- "Error, header damaged or not MPEG4 header (f_code=0)\n");
+ "Error, header damaged or not MPEG-4 header (f_code=0)\n");
s->f_code = 1;
return AVERROR_INVALIDDATA; // makes no sense to continue, as there is nothing left from the image then
}
}
}
/* detect buggy encoders which don't set the low_delay flag
- * (divx4/xvid/opendivx). Note we cannot detect divx5 without b-frames
+ * (divx4/xvid/opendivx). Note we cannot detect divx5 without B-frames
* easily (although it's buggy too) */
if (s->vo_type == 0 && ctx->vol_control_parameters == 0 &&
ctx->divx_version == -1 && s->picture_number == 0) {
}
/**
- * Decode mpeg4 headers.
+ * Decode MPEG-4 headers.
* @return <0 if no VOP found (or a damaged one)
* FRAME_SKIPPED if a not coded VOP is found
* 0 if a VOP is found