diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-11 04:22:22 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-11 04:22:22 +0400 |
commit | a78f6b8cb98611a846a68f4bbb77e78fd5c175bf (patch) | |
tree | 45d4339cefc60f61310bd23b8d7cf7d0bf1f88b6 /libavformat | |
parent | 394d41ee30b0c4a38a8d33b65e28facfef15d465 (diff) | |
parent | f98ede7e610da644d3e5d553fc5d7102cf1ccde7 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (38 commits)
v210enc: remove redundant check for pix_fmt
wavpack: allow user to disable CRC checking
v210enc: Use Bytestream2 functions
cafdec: Check return value of avio_seek and avoid modifying state if it fails
yop: Check return value of avio_seek and avoid modifying state if it fails
tta: Check return value of avio_seek and avoid modifying state if it fails
tmv: Check return value of avio_seek and avoid modifying state if it fails
r3d: Check return value of avio_seek and avoid modifying state if it fails
nsvdec: Check return value of avio_seek and avoid modifying state if it fails
mpc8: Check return value of avio_seek and avoid modifying state if it fails
jvdec: Check return value of avio_seek and avoid modifying state if it fails
filmstripdec: Check return value of avio_seek and avoid modifying state if it fails
ffmdec: Check return value of avio_seek and avoid modifying state if it fails
dv: Check return value of avio_seek and avoid modifying state if it fails
bink: Check return value of avio_seek and avoid modifying state if it fails
Check AVCodec.pix_fmts in avcodec_open2()
svq3: Prevent illegal reads while parsing extradata.
remove ParseContext1
vc1: use ff_parse_close
mpegvideo parser: move specific fields into private context
...
Conflicts:
libavcodec/4xm.c
libavcodec/aacdec.c
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_cabac.c
libavcodec/h264_cavlc.c
libavcodec/mpeg4video_parser.c
libavcodec/svq3.c
libavcodec/v210enc.c
libavformat/cafdec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/cafdec.c | 21 | ||||
-rw-r--r-- | libavformat/dv.c | 13 | ||||
-rw-r--r-- | libavformat/rtpenc.c | 4 |
3 files changed, 27 insertions, 11 deletions
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 8545c534ec..7cdfd2bb0e 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -374,8 +374,7 @@ static int read_seek(AVFormatContext *s, int stream_index, { AVStream *st = s->streams[0]; CaffContext *caf = s->priv_data; - CaffContext caf2 = *caf; - int64_t pos; + int64_t pos, packet_cnt, frame_cnt; timestamp = FFMAX(timestamp, 0); @@ -384,20 +383,22 @@ static int read_seek(AVFormatContext *s, int stream_index, pos = caf->bytes_per_packet * timestamp / caf->frames_per_packet; if (caf->data_size > 0) pos = FFMIN(pos, caf->data_size); - caf->packet_cnt = pos / caf->bytes_per_packet; - caf->frame_cnt = caf->frames_per_packet * caf->packet_cnt; + packet_cnt = pos / caf->bytes_per_packet; + frame_cnt = caf->frames_per_packet * packet_cnt; } else if (st->nb_index_entries) { - caf->packet_cnt = av_index_search_timestamp(st, timestamp, flags); - caf->frame_cnt = st->index_entries[caf->packet_cnt].timestamp; - pos = st->index_entries[caf->packet_cnt].pos; + packet_cnt = av_index_search_timestamp(st, timestamp, flags); + frame_cnt = st->index_entries[packet_cnt].timestamp; + pos = st->index_entries[packet_cnt].pos; } else { return -1; } - if (avio_seek(s->pb, pos + caf->data_start, SEEK_SET) < 0) { - *caf = caf2; + if (avio_seek(s->pb, pos + caf->data_start, SEEK_SET) < 0) return -1; - } + + caf->packet_cnt = packet_cnt; + caf->frame_cnt = frame_cnt; + return 0; } diff --git a/libavformat/dv.c b/libavformat/dv.c index 7e034fb15c..72f152d6b9 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -99,6 +99,10 @@ static const uint8_t* dv_extract_pack(uint8_t* frame, enum dv_pack_type t) return frame[offs] == t ? &frame[offs] : NULL; } +static const int dv_audio_frequency[3] = { + 48000, 44100, 32000, +}; + /* * There's a couple of assumptions being made here: * 1. By default we silence erroneous (0x8000/16bit 0x800/12bit) audio samples. @@ -126,6 +130,9 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], if (quant > 1) return -1; /* unsupported quantization */ + if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency)) + return AVERROR_INVALIDDATA; + size = (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */ half_ch = sys->difseg_size / 2; @@ -209,6 +216,12 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) stype = (as_pack[3] & 0x1f); /* 0 - 2CH, 2 - 4CH, 3 - 8CH */ quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ + if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency)) { + av_log(c->fctx, AV_LOG_ERROR, + "Unrecognized audio sample rate index (%d)\n", freq); + return 0; + } + if (stype > 3) { av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype); c->ach = 0; diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index ac9b32cc0c..4b1ff1d889 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -108,8 +108,10 @@ static int rtp_write_header(AVFormatContext *s1) NTP_OFFSET_US; max_packet_size = s1->pb->max_packet_size; - if (max_packet_size <= 12) + if (max_packet_size <= 12) { + av_log(s1, AV_LOG_ERROR, "Max packet size %d too low\n", max_packet_size); return AVERROR(EIO); + } s->buf = av_malloc(max_packet_size); if (s->buf == NULL) { return AVERROR(ENOMEM); |