aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-22 01:10:24 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-22 01:10:24 +0200
commitec7f0b527c2f620003e041c7c41a3c9f82cf1536 (patch)
tree0d9e28b200a2080609656a5999953cc313c1d5b2 /libavformat
parentf36cea267381571488070d3d6b8290359f3f94d3 (diff)
parentd805b8f454f57451277a052cc1bda49e6caf6cd7 (diff)
downloadffmpeg-ec7f0b527c2f620003e041c7c41a3c9f82cf1536.tar.gz
Merge remote-tracking branch 'khirnov/release/0.7' into release/0.8
* khirnov/release/0.7: (64 commits) rv34: Check for invalid slice offsets rv34: Fix potential overreads rv34: Avoid NULL dereference on corrupted bitstream rv10: Reject slices that does not have the same type as the first one lavf: Fix context pointer in av_open_input_stream when avformat_open_input fails oggdec: fix out of bound write in the ogg demuxer Fixed size given to init_get_bits(). smacker: fix a few off by 1 errors Check for invalid VLC value in smacker decoder. Check and propagate errors when VLC trees cannot be built in smacker decoder. Fixed off by one packet size allocation in the smacker demuxer. Check for invalid packet size in the smacker demuxer. ape demuxer: fix segfault on memory allocation failure. xan: Add some buffer checks (cherry picked from commit 0872bb23b4bd2d94a8ba91070f706d1bc1c3ced8) Fixed size given to init_get_bits() in xan decoder. (cherry picked from commit 393d5031c6aaaf8c2dda4eb5d676974c349fae85) smacker demuxer: handle possible av_realloc() failure. Fixed segfault with wavpack decoder on corrupted decorrelation terms sub-blocks. cljr: init_get_bits size in bits instead of bytes (cherry picked from commit 0c1f5b93d9b97c4cc3684ba91a040e90bfc760d2) indeo2: fail if input buffer too small (cherry picked from commit b7ce4f1d1c3add86ece7ca595ea6c4a10b471055) indeo2: init_get_bits size in bits instead of bytes (cherry picked from commit 68ca330cbd479111db9cb7649d7530ad59f04cc8) ... Conflicts: ffmpeg.c libavdevice/alsa-audio.h libavformat/gxf.c libswscale/x86/swscale_template.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/adtsenc.c4
-rw-r--r--libavformat/flvenc.c2
-rw-r--r--libavformat/gxf.c25
-rw-r--r--libavformat/mpegts.c5
-rw-r--r--libavformat/mxfdec.c2
-rw-r--r--libavformat/mxfenc.c2
-rw-r--r--libavformat/utils.c5
7 files changed, 29 insertions, 16 deletions
diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index a03e128d96..43e719b5ea 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -59,6 +59,10 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf
av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n");
return -1;
}
+ if (get_bits(&gb, 1)) {
+ av_log(s, AV_LOG_ERROR, "Extension flag is not allowed in ADTS\n");
+ return -1;
+ }
if (!adts->channel_conf) {
init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index cea0d02e3c..d56b4284cb 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -179,7 +179,7 @@ static int flv_write_header(AVFormatContext *s)
AVCodecContext *audio_enc = NULL, *video_enc = NULL;
int i;
double framerate = 0.0;
- int metadata_size_pos, data_size;
+ int64_t metadata_size_pos, data_size;
AVDictionaryEntry *tag = NULL;
for(i=0; i<s->nb_streams; i++){
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index e278b9b846..145b4adf3f 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -264,7 +264,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
int map_len;
int len;
AVRational main_timebase = {0, 0};
- struct gxf_stream_info si;
+ struct gxf_stream_info *si = s->priv_data;
int i;
if (!parse_packet_header(pb, &pkt_type, &map_len) || pkt_type != PKT_MAP) {
av_log(s, AV_LOG_ERROR, "map packet not found\n");
@@ -282,7 +282,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
return 0;
}
map_len -= len;
- gxf_material_tags(pb, &len, &si);
+ gxf_material_tags(pb, &len, si);
avio_skip(pb, len);
map_len -= 2;
len = avio_rb16(pb); // length of track description
@@ -300,7 +300,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
track_id = avio_r8(pb);
track_len = avio_rb16(pb);
len -= track_len;
- gxf_track_tags(pb, &track_len, &si);
+ gxf_track_tags(pb, &track_len, si);
avio_skip(pb, track_len);
if (!(track_type & 0x80)) {
av_log(s, AV_LOG_ERROR, "invalid track type %x\n", track_type);
@@ -316,12 +316,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
if (idx < 0) continue;
st = s->streams[idx];
if (!main_timebase.num || !main_timebase.den) {
- main_timebase.num = si.frames_per_second.den;
- main_timebase.den = si.frames_per_second.num * 2;
+ main_timebase.num = si->frames_per_second.den;
+ main_timebase.den = si->frames_per_second.num * 2;
}
- st->start_time = si.first_field;
- if (si.first_field != AV_NOPTS_VALUE && si.last_field != AV_NOPTS_VALUE)
- st->duration = si.last_field - si.first_field;
+ st->start_time = si->first_field;
+ if (si->first_field != AV_NOPTS_VALUE && si->last_field != AV_NOPTS_VALUE)
+ st->duration = si->last_field - si->first_field;
}
if (len < 0)
av_log(s, AV_LOG_ERROR, "invalid track description length specified\n");
@@ -422,6 +422,8 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
AVIOContext *pb = s->pb;
GXFPktType pkt_type;
int pkt_len;
+ struct gxf_stream_info *si = s->priv_data;
+
while (!url_feof(pb)) {
AVStream *st;
int track_type, track_id, ret;
@@ -473,6 +475,11 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
avio_skip(pb, skip);
pkt->stream_index = stream_index;
pkt->dts = field_nr;
+
+ //set duration manually for DV or else lavf misdetects the frame rate
+ if (st->codec->codec_id == CODEC_ID_DVVIDEO)
+ pkt->duration = si->fields_per_frame;
+
return ret;
}
return AVERROR(EIO);
@@ -518,7 +525,7 @@ static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index,
AVInputFormat ff_gxf_demuxer = {
"gxf",
NULL_IF_CONFIG_SMALL("GXF format"),
- 0,
+ sizeof(struct gxf_stream_info),
gxf_probe,
gxf_header,
gxf_packet,
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 74c9ac931c..82f422161e 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1268,7 +1268,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
AVFormatContext *s = ts->stream;
MpegTSFilter *tss;
- int len, pid, cc, cc_ok, afc, is_start;
+ int len, pid, cc, expected_cc, cc_ok, afc, is_start;
const uint8_t *p, *p_end;
int64_t pos;
@@ -1286,7 +1286,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
/* continuity check (currently not used) */
cc = (packet[3] & 0xf);
- cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
+ expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : tss->last_cc;
+ cc_ok = (tss->last_cc < 0) || (expected_cc == cc);
tss->last_cc = cc;
/* skip adaptation field */
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8548c792f6..a69944d8d2 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -599,7 +599,7 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
default:
/* Private uid used by SONY C0023S01.mxf */
if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) {
- descriptor->extradata = av_malloc(size);
+ descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = size;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index c6532a3427..0f230cb224 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1539,7 +1539,7 @@ static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0
static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps)
{
return (0 << 31) | // color frame flag
- (0 << 30) | // drop frame flag
+ (drop << 30) | // drop frame flag
( ((frame % fps) / 10) << 28) | // tens of frames
( ((frame % fps) % 10) << 24) | // units of frames
(0 << 23) | // field phase (NTSC), b0 (PAL)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d24c7a0b5e..6f108fb7dd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -470,11 +470,12 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
else
ic->pb = pb;
- err = avformat_open_input(&ic, filename, fmt, &opts);
+ if ((err = avformat_open_input(&ic, filename, fmt, &opts)) < 0)
+ goto fail;
ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above
- *ic_ptr = ic;
fail:
+ *ic_ptr = ic;
av_dict_free(&opts);
return err;
}