Commit 6c98398b authored by Clément Bœsch's avatar Clément Bœsch

lavc/get_bits: add a logging context to check_marker()

Based on d338abb6
parent 7475a935
...@@ -398,11 +398,12 @@ static inline unsigned int show_bits_long(GetBitContext *s, int n) ...@@ -398,11 +398,12 @@ static inline unsigned int show_bits_long(GetBitContext *s, int n)
} }
} }
static inline int check_marker(GetBitContext *s, const char *msg) static inline int check_marker(void *logctx, GetBitContext *s, const char *msg)
{ {
int bit = get_bits1(s); int bit = get_bits1(s);
if (!bit) if (!bit)
av_log(NULL, AV_LOG_INFO, "Marker bit missing at %d of %d %s\n", get_bits_count(s) - 1, s->size_in_bits, msg); av_log(logctx, AV_LOG_INFO, "Marker bit missing at %d of %d %s\n",
get_bits_count(s) - 1, s->size_in_bits, msg);
return bit; return bit;
} }
......
...@@ -39,7 +39,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s) ...@@ -39,7 +39,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
} }
s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */ s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
if (check_marker(&s->gb, "after picture_number") != 1) { if (check_marker(s->avctx, &s->gb, "after picture_number") != 1) {
return -1; /* marker */ return -1; /* marker */
} }
if (get_bits1(&s->gb) != 0) { if (get_bits1(&s->gb) != 0) {
...@@ -95,7 +95,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s) ...@@ -95,7 +95,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
if(format == 6){ if(format == 6){
int ar = get_bits(&s->gb, 4); int ar = get_bits(&s->gb, 4);
skip_bits(&s->gb, 9); // display width skip_bits(&s->gb, 9); // display width
check_marker(&s->gb, "in dimensions"); check_marker(s->avctx, &s->gb, "in dimensions");
skip_bits(&s->gb, 9); // display height skip_bits(&s->gb, 9); // display height
if(ar == 15){ if(ar == 15){
s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8); // aspect ratio - width s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8); // aspect ratio - width
......
...@@ -175,17 +175,17 @@ static int h263_decode_gob_header(MpegEncContext *s) ...@@ -175,17 +175,17 @@ static int h263_decode_gob_header(MpegEncContext *s)
return -1; return -1;
if(s->h263_slice_structured){ if(s->h263_slice_structured){
if(check_marker(&s->gb, "before MBA")==0) if(check_marker(s->avctx, &s->gb, "before MBA")==0)
return -1; return -1;
ff_h263_decode_mba(s); ff_h263_decode_mba(s);
if(s->mb_num > 1583) if(s->mb_num > 1583)
if(check_marker(&s->gb, "after MBA")==0) if(check_marker(s->avctx, &s->gb, "after MBA")==0)
return -1; return -1;
s->qscale = get_bits(&s->gb, 5); /* SQUANT */ s->qscale = get_bits(&s->gb, 5); /* SQUANT */
if(check_marker(&s->gb, "after SQUANT")==0) if(check_marker(s->avctx, &s->gb, "after SQUANT")==0)
return -1; return -1;
skip_bits(&s->gb, 2); /* GFID */ skip_bits(&s->gb, 2); /* GFID */
}else{ }else{
...@@ -904,7 +904,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) ...@@ -904,7 +904,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
s->picture_number= (s->picture_number&~0xFF) + i; s->picture_number= (s->picture_number&~0xFF) + i;
/* PTYPE starts here */ /* PTYPE starts here */
if (check_marker(&s->gb, "in PTYPE") != 1) { if (check_marker(s->avctx, &s->gb, "in PTYPE") != 1) {
return -1; return -1;
} }
if (get_bits1(&s->gb) != 0) { if (get_bits1(&s->gb) != 0) {
...@@ -1025,7 +1025,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) ...@@ -1025,7 +1025,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
6-14 - reserved 6-14 - reserved
*/ */
width = (get_bits(&s->gb, 9) + 1) * 4; width = (get_bits(&s->gb, 9) + 1) * 4;
check_marker(&s->gb, "in dimensions"); check_marker(s->avctx, &s->gb, "in dimensions");
height = get_bits(&s->gb, 9) * 4; height = get_bits(&s->gb, 9) * 4;
ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height); ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
...@@ -1120,13 +1120,13 @@ int ff_h263_decode_picture_header(MpegEncContext *s) ...@@ -1120,13 +1120,13 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if(s->h263_slice_structured){ if(s->h263_slice_structured){
if (check_marker(&s->gb, "SEPB1") != 1) { if (check_marker(s->avctx, &s->gb, "SEPB1") != 1) {
return -1; return -1;
} }
ff_h263_decode_mba(s); ff_h263_decode_mba(s);
if (check_marker(&s->gb, "SEPB2") != 1) { if (check_marker(s->avctx, &s->gb, "SEPB2") != 1) {
return -1; return -1;
} }
} }
......
...@@ -767,7 +767,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) ...@@ -767,7 +767,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
s->last_mv[0][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[0][1],
s->last_mv[0][0][1]); s->last_mv[0][0][1]);
check_marker(&s->gb, "after concealment_motion_vectors"); check_marker(s->avctx, &s->gb, "after concealment_motion_vectors");
} else { } else {
/* reset mv prediction */ /* reset mv prediction */
memset(s->last_mv, 0, sizeof(s->last_mv)); memset(s->last_mv, 0, sizeof(s->last_mv));
...@@ -1439,7 +1439,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) ...@@ -1439,7 +1439,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
s->height |= (vert_size_ext << 12); s->height |= (vert_size_ext << 12);
bit_rate_ext = get_bits(&s->gb, 12); /* XXX: handle it */ bit_rate_ext = get_bits(&s->gb, 12); /* XXX: handle it */
s->bit_rate += (bit_rate_ext << 18) * 400LL; s->bit_rate += (bit_rate_ext << 18) * 400LL;
check_marker(&s->gb, "after bit rate extension"); check_marker(s->avctx, &s->gb, "after bit rate extension");
s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10;
s->low_delay = get_bits1(&s->gb); s->low_delay = get_bits1(&s->gb);
...@@ -2130,7 +2130,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, ...@@ -2130,7 +2130,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->frame_rate_index = 1; s->frame_rate_index = 1;
} }
s->bit_rate = get_bits(&s->gb, 18) * 400LL; s->bit_rate = get_bits(&s->gb, 18) * 400LL;
if (check_marker(&s->gb, "in sequence header") == 0) { if (check_marker(s->avctx, &s->gb, "in sequence header") == 0) {
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
......
...@@ -196,13 +196,13 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g ...@@ -196,13 +196,13 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
x = get_xbits(gb, length); x = get_xbits(gb, length);
if (!(ctx->divx_version == 500 && ctx->divx_build == 413)) 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); length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length > 0) if (length > 0)
y = get_xbits(gb, length); 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][0] = d[i][0] = x;
ctx->sprite_traj[i][1] = d[i][1] = y; ctx->sprite_traj[i][1] = d[i][1] = y;
} }
...@@ -381,12 +381,13 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g ...@@ -381,12 +381,13 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
} }
static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) { static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) {
MpegEncContext *s = &ctx->m;
int len = FFMIN(ctx->time_increment_bits + 3, 15); int len = FFMIN(ctx->time_increment_bits + 3, 15);
get_bits(gb, len); get_bits(gb, len);
if (get_bits1(gb)) if (get_bits1(gb))
get_bits(gb, len); get_bits(gb, len);
check_marker(gb, "after new_pred"); check_marker(s->avctx, gb, "after new_pred");
return 0; return 0;
} }
...@@ -445,9 +446,9 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx) ...@@ -445,9 +446,9 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
while (get_bits1(&s->gb) != 0) while (get_bits1(&s->gb) != 0)
time_incr++; 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 */ 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 */ skip_bits(&s->gb, 2); /* vop coding type */
// FIXME not rect stuff here // FIXME not rect stuff here
...@@ -1685,7 +1686,7 @@ static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -1685,7 +1686,7 @@ static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb)
hours = get_bits(gb, 5); hours = get_bits(gb, 5);
minutes = get_bits(gb, 6); minutes = get_bits(gb, 6);
check_marker(gb, "in gop_header"); check_marker(s->avctx, gb, "in gop_header");
seconds = get_bits(gb, 6); seconds = get_bits(gb, 6);
s->time_base = seconds + 60*(minutes + 60*hours); s->time_base = seconds + 60*(minutes + 60*hours);
...@@ -1740,16 +1741,16 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1740,16 +1741,16 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
s->low_delay = get_bits1(gb); s->low_delay = get_bits1(gb);
if (get_bits1(gb)) { /* vbv parameters */ if (get_bits1(gb)) { /* vbv parameters */
get_bits(gb, 15); /* first_half_bitrate */ 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 */ 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 */ 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, 3); /* latter_half_vbv_buffer_size */
get_bits(gb, 11); /* first_half_vbv_occupancy */ 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 */ 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 { } else {
/* is setting low delay flag only once the smartest thing to do? /* is setting low delay flag only once the smartest thing to do?
...@@ -1774,7 +1775,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1774,7 +1775,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
skip_bits(gb, 4); /* video_object_layer_shape_extension */ 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); s->avctx->framerate.num = get_bits(gb, 16);
if (!s->avctx->framerate.num) { if (!s->avctx->framerate.num) {
...@@ -1786,7 +1787,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1786,7 +1787,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
if (ctx->time_increment_bits < 1) if (ctx->time_increment_bits < 1)
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 */ if (get_bits1(gb) != 0) /* fixed_vop_rate */
s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits); s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits);
...@@ -1799,11 +1800,11 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1799,11 +1800,11 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
if (ctx->shape != BIN_ONLY_SHAPE) { if (ctx->shape != BIN_ONLY_SHAPE) {
if (ctx->shape == RECT_SHAPE) { if (ctx->shape == RECT_SHAPE) {
check_marker(gb, "before width"); check_marker(s->avctx, gb, "before width");
width = get_bits(gb, 13); width = get_bits(gb, 13);
check_marker(gb, "before height"); check_marker(s->avctx, gb, "before height");
height = get_bits(gb, 13); 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 */ if (width && height && /* they should be non zero but who knows */
!(s->width && s->codec_tag == AV_RL32("MP4S"))) { !(s->width && s->codec_tag == AV_RL32("MP4S"))) {
if (s->width && s->height && if (s->width && s->height &&
...@@ -1831,13 +1832,13 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1831,13 +1832,13 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
ctx->vol_sprite_usage == GMC_SPRITE) { ctx->vol_sprite_usage == GMC_SPRITE) {
if (ctx->vol_sprite_usage == STATIC_SPRITE) { if (ctx->vol_sprite_usage == STATIC_SPRITE) {
skip_bits(gb, 13); // sprite_width 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 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 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 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); ctx->num_sprite_warping_points = get_bits(gb, 6);
if (ctx->num_sprite_warping_points > 3) { if (ctx->num_sprite_warping_points > 3) {
...@@ -1970,7 +1971,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1970,7 +1971,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* inter4v_blocks */ ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* inter4v_blocks */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* not coded 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)); skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est; goto no_cplx_est;
} }
...@@ -1988,7 +1989,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -1988,7 +1989,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel2 */ ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel2 */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel4 */ 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)); skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est; goto no_cplx_est;
} }
...@@ -2262,7 +2263,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -2262,7 +2263,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
while (get_bits1(gb) != 0) while (get_bits1(gb) != 0)
time_incr++; time_incr++;
check_marker(gb, "before time_increment"); check_marker(s->avctx, gb, "before time_increment");
if (ctx->time_increment_bits == 0 || if (ctx->time_increment_bits == 0 ||
!(show_bits(gb, ctx->time_increment_bits + 1) & 1)) { !(show_bits(gb, ctx->time_increment_bits + 1) & 1)) {
...@@ -2341,7 +2342,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -2341,7 +2342,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
pts = AV_NOPTS_VALUE; pts = AV_NOPTS_VALUE;
ff_dlog(s->avctx, "MPEG4 PTS: %"PRId64"\n", pts); 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 */ /* vop coded */
if (get_bits1(gb) != 1) { if (get_bits1(gb) != 1) {
...@@ -2366,11 +2367,11 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) ...@@ -2366,11 +2367,11 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
if (ctx->shape != RECT_SHAPE) { if (ctx->shape != RECT_SHAPE) {
if (ctx->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) { if (ctx->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
skip_bits(gb, 13); /* width */ skip_bits(gb, 13); /* width */
check_marker(gb, "after width"); check_marker(s->avctx, gb, "after width");
skip_bits(gb, 13); /* height */ skip_bits(gb, 13); /* height */
check_marker(gb, "after height"); check_marker(s->avctx, gb, "after height");
skip_bits(gb, 13); /* hor_spat_ref */ 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_bits(gb, 13); /* ver_spat_ref */
} }
skip_bits1(gb); /* change_CR_disable */ skip_bits1(gb); /* change_CR_disable */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment