aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnatoly Nenashev <anatoly.nenashev@ovsoft.ru>2011-02-10 16:09:48 +0000
committerMans Rullgard <mans@mansr.com>2011-02-13 16:22:14 +0000
commit7a4abe5912405474039198823d451b2a38361c48 (patch)
tree5d3da001ab59dc034d003cd13e0e75803b9452a5
parent5d57846bba7010dc6ee65c3503dd06600e5441a5 (diff)
downloadffmpeg-7a4abe5912405474039198823d451b2a38361c48.tar.gz
mpeg4video: ignore broken GOP headers
Some MPEG4 cameras produce files with empty GOP headers. This patch makes the decoder ignore such broken headers and proceed with the following I-frame. Without this change, the following start code is missed resulting in the entire I-frame being skipped. Signed-off-by: Mans Rullgard <mans@mansr.com>
-rw-r--r--libavcodec/mpeg4videodec.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 673c4e865c..617dcb9f18 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1494,16 +1494,17 @@ end:
static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
int hours, minutes, seconds;
-
- hours= get_bits(gb, 5);
- minutes= get_bits(gb, 6);
- skip_bits1(gb);
- seconds= get_bits(gb, 6);
-
- s->time_base= seconds + 60*(minutes + 60*hours);
-
- skip_bits1(gb);
- skip_bits1(gb);
+ unsigned time_code = show_bits(gb, 18);
+
+ if (time_code & 0x40) { /* marker_bit */
+ hours = time_code >> 13;
+ minutes = time_code >> 7 & 0x3f;
+ seconds = time_code & 0x3f;
+ s->time_base = seconds + 60*(minutes + 60*hours);
+ skip_bits(gb, 20); /* time_code, closed_gov, broken_link */
+ } else {
+ av_log(s->avctx, AV_LOG_WARNING, "GOP header missing marker_bit\n");
+ }
return 0;
}