aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-06 01:37:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-06 01:37:27 +0100
commitb404ab9e74d3bca12d5989c366f5cfd746279067 (patch)
treefdbba6fdf7a4694fe7b7ecda6401ea6a2e01f95e /libavformat
parenta448a5d1c4620aa58ec138fbffd46d18d42d53e0 (diff)
parent52401b82bd2ed30d4c4353cb084bf4ee679d0c22 (diff)
downloadffmpeg-b404ab9e74d3bca12d5989c366f5cfd746279067.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: mov: Don't av_malloc(0). avconv: only allocate 1 AVFrame per input stream avconv: fix memleaks due to not freeing the AVFrame for audio h264-fate: remove -strict 1 except where necessary (mr4/5-tandberg). misc Doxygen markup improvements doxygen: eliminate Qt-style doxygen syntax g722: Add a regression test for muxing/demuxing in wav g722: Change bits per sample to 4 g722dec: Signal skipping the lower bits via AVOptions instead of bits_per_coded_sample api-example: update to use avcodec_decode_audio4() avplay: use avcodec_decode_audio4() avplay: use a separate buffer for playing silence avformat: use avcodec_decode_audio4() in avformat_find_stream_info() avconv: use avcodec_decode_audio4() instead of avcodec_decode_audio3() mov: Allow empty stts atom. doc: document preferred Doxygen syntax and make patcheck detect it Conflicts: avconv.c ffplay.c libavcodec/mlpdec.c libavcodec/version.h libavformat/mov.c tests/codec-regression.sh tests/fate/h264.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h2
-rw-r--r--libavformat/matroskadec.c8
-rw-r--r--libavformat/mov.c10
-rw-r--r--libavformat/nuv.c2
-rw-r--r--libavformat/oggdec.c5
-rw-r--r--libavformat/utils.c31
6 files changed, 34 insertions, 24 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f1c701d03f..64252029d3 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -293,7 +293,7 @@ typedef struct AVFormatParameters {
#endif
} AVFormatParameters;
-//! Demuxer will use avio_open, no opened file should be provided by the caller.
+/// Demuxer will use avio_open, no opened file should be provided by the caller.
#define AVFMT_NOFILE 0x0001
#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */
#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1ceea51d99..4a0c2fa76c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -22,10 +22,10 @@
/**
* @file
* Matroska file demuxer
- * by Ronald Bultje <rbultje@ronald.bitfreak.net>
- * with a little help from Moritz Bunkus <moritz@bunkus.org>
- * totally reworked by Aurelien Jacobs <aurel@gnuage.org>
- * Specs available on the Matroska project page: http://www.matroska.org/.
+ * @author Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * @author with a little help from Moritz Bunkus <moritz@bunkus.org>
+ * @author totally reworked by Aurelien Jacobs <aurel@gnuage.org>
+ * @see specs available on the Matroska project page: http://www.matroska.org/
*/
#include <stdio.h>
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 40acf78a65..d55b08d8bc 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -957,6 +957,8 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
entries = avio_rb32(pb);
+ if (!entries)
+ return 0;
if (entries >= UINT_MAX/sizeof(int64_t))
return -1;
@@ -1398,6 +1400,8 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_dlog(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
+ if (!entries)
+ return 0;
if (entries >= UINT_MAX / sizeof(*sc->stsc_data))
return -1;
sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));
@@ -1513,6 +1517,8 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return -1;
}
+ if (!entries)
+ return 0;
if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / field_size)
return -1;
sc->sample_sizes = av_malloc(entries * sizeof(int));
@@ -1615,6 +1621,8 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_dlog(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
+ if (!entries)
+ return 0;
if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
return -1;
sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data));
@@ -1675,6 +1683,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
current_dts -= sc->dts_shift;
+ if (!sc->sample_count)
+ return;
if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries))
return;
st->index_entries = av_malloc(sc->sample_count*sizeof(*st->index_entries));
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index 349ff0c35d..c421ca98f4 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -47,7 +47,7 @@ static int nuv_probe(AVProbeData *p) {
return 0;
}
-//! little macro to sanitize packet size
+/// little macro to sanitize packet size
#define PKTSIZE(s) (s & 0xffffff)
/**
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 1602580348..ceb4091c6e 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -2,10 +2,9 @@
* Ogg bitstream support
* Luca Barbato <lu_zero@gentoo.org>
* Based on tcvp implementation
- *
*/
-/**
+/*
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård
Permission is hereby granted, free of charge, to any person
@@ -27,7 +26,7 @@
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-**/
+ */
#include <stdio.h>
#include "oggdec.h"
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1493f278ab..c8f93118f1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2209,10 +2209,10 @@ static int has_decode_delay_been_guessed(AVStream *st)
static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options)
{
- int16_t *samples;
AVCodec *codec;
- int got_picture, data_size, ret=0;
+ int got_picture, ret = 0;
AVFrame picture;
+ AVPacket pkt = *avpkt;
if(!st->codec->codec){
codec = avcodec_find_decoder(st->codec->codec_id);
@@ -2223,28 +2223,29 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
return ret;
}
- if(!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st) ||
- (!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF)) {
+ while (pkt.size > 0 && ret >= 0 &&
+ (!has_codec_parameters(st->codec) ||
+ !has_decode_delay_been_guessed(st) ||
+ (!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) {
+ got_picture = 0;
+ avcodec_get_frame_defaults(&picture);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- avcodec_get_frame_defaults(&picture);
ret = avcodec_decode_video2(st->codec, &picture,
- &got_picture, avpkt);
- if (got_picture)
- st->info->nb_decoded_frames++;
+ &got_picture, &pkt);
break;
case AVMEDIA_TYPE_AUDIO:
- data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE);
- samples = av_malloc(data_size);
- if (!samples)
- goto fail;
- ret = avcodec_decode_audio3(st->codec, samples,
- &data_size, avpkt);
- av_free(samples);
+ ret = avcodec_decode_audio4(st->codec, &picture, &got_picture, &pkt);
break;
default:
break;
}
+ if (ret >= 0) {
+ if (got_picture)
+ st->info->nb_decoded_frames++;
+ pkt.data += ret;
+ pkt.size -= ret;
+ }
}
fail:
return ret;