Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-25 15:34:06 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-09-25 17:15:16 +0400
commit46a35959d8c17f7ae272ca158d05e047d31e736c (patch)
tree2a999b2c04b33514efea0e2f75917e83a45e36e3 /libavformat
parent2089f933003b951b96b95e976bd34bbeffbd29f3 (diff)
parent7751e4693dd10ec98c20fbd9887233b575034272 (diff)
Merge commit '7751e4693dd10ec98c20fbd9887233b575034272'
* commit '7751e4693dd10ec98c20fbd9887233b575034272': ogg: check that the expected number of headers had been parsed libx264: change default to closed gop to match x264cli Use avcodec_free_frame() to free AVFrames. lavf: use a malloced AVFrame in try_decode_frame(). lavc: add avcodec_free_frame(). lavc: ensure extended_data is set properly on decoding lavc: initialize AVFrame.extended_data in avcodec_get_frame_defaults() lavc: use av_mallocz to allocate AVFrames. lavc: rename the argument of avcodec_alloc_frame/get_frame_defaults Conflicts: doc/APIchanges doc/examples/decoding_encoding.c libavcodec/utils.c libavcodec/version.h libavfilter/src_movie.c libavformat/oggdec.c libavformat/oggdec.h libavformat/oggparsetheora.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/oggdec.c1
-rw-r--r--libavformat/oggdec.h5
-rw-r--r--libavformat/oggparsecelt.c1
-rw-r--r--libavformat/oggparsedirac.c2
-rw-r--r--libavformat/oggparseflac.c6
-rw-r--r--libavformat/oggparseogm.c4
-rw-r--r--libavformat/oggparseskeleton.c1
-rw-r--r--libavformat/oggparsespeex.c3
-rw-r--r--libavformat/oggparsetheora.c3
-rw-r--r--libavformat/oggparsevorbis.c1
-rw-r--r--libavformat/utils.c28
11 files changed, 42 insertions, 13 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 926326a005..617bc3a986 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -485,6 +485,7 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
s->data_offset = FFMIN(s->data_offset, cur_os->sync_pos);
}
}else{
+ os->nb_header++;
os->pstart += os->psize;
os->psize = 0;
}
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index dd005fa61e..79d8179d9d 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -51,6 +51,10 @@ struct ogg_codec {
* 0 if granule is the end time of the associated packet.
*/
int granule_is_start;
+ /**
+ * Number of expected headers
+ */
+ int nb_header;
};
struct ogg_stream {
@@ -77,6 +81,7 @@ struct ogg_stream {
int keyframe_seek;
int got_start;
int got_data; ///< 1 if the stream got some data (non-initial packets), 0 otherwise
+ int nb_header; ///< set to the number of parsed headers
void *private;
};
diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c
index 053b74b74f..afc4392e2c 100644
--- a/libavformat/oggparsecelt.c
+++ b/libavformat/oggparsecelt.c
@@ -93,4 +93,5 @@ const struct ogg_codec ff_celt_codec = {
.magic = "CELT ",
.magicsize = 8,
.header = celt_header,
+ .nb_header = 2,
};
diff --git a/libavformat/oggparsedirac.c b/libavformat/oggparsedirac.c
index 2a9d9006e3..73bc495aa8 100644
--- a/libavformat/oggparsedirac.c
+++ b/libavformat/oggparsedirac.c
@@ -104,6 +104,7 @@ const struct ogg_codec ff_dirac_codec = {
.header = dirac_header,
.gptopts = dirac_gptopts,
.granule_is_start = 1,
+ .nb_header = 1,
};
const struct ogg_codec ff_old_dirac_codec = {
@@ -112,4 +113,5 @@ const struct ogg_codec ff_old_dirac_codec = {
.header = old_dirac_header,
.gptopts = old_dirac_gptopts,
.granule_is_start = 1,
+ .nb_header = 1,
};
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index 6edbd85653..3ff594e3c4 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -88,11 +88,13 @@ old_flac_header (AVFormatContext * s, int idx)
const struct ogg_codec ff_flac_codec = {
.magic = "\177FLAC",
.magicsize = 5,
- .header = flac_header
+ .header = flac_header,
+ .nb_header = 2,
};
const struct ogg_codec ff_old_flac_codec = {
.magic = "fLaC",
.magicsize = 4,
- .header = old_flac_header
+ .header = old_flac_header,
+ .nb_header = 0,
};
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index e60769efea..a3caac0e15 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -171,6 +171,7 @@ const struct ogg_codec ff_ogm_video_codec = {
.header = ogm_header,
.packet = ogm_packet,
.granule_is_start = 1,
+ .nb_header = 2,
};
const struct ogg_codec ff_ogm_audio_codec = {
@@ -179,6 +180,7 @@ const struct ogg_codec ff_ogm_audio_codec = {
.header = ogm_header,
.packet = ogm_packet,
.granule_is_start = 1,
+ .nb_header = 2,
};
const struct ogg_codec ff_ogm_text_codec = {
@@ -187,6 +189,7 @@ const struct ogg_codec ff_ogm_text_codec = {
.header = ogm_header,
.packet = ogm_packet,
.granule_is_start = 1,
+ .nb_header = 2,
};
const struct ogg_codec ff_ogm_old_codec = {
@@ -195,4 +198,5 @@ const struct ogg_codec ff_ogm_old_codec = {
.header = ogm_dshow_header,
.packet = ogm_packet,
.granule_is_start = 1,
+ .nb_header = 1,
};
diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c
index b0f55dd0b2..a9e4fc9ed0 100644
--- a/libavformat/oggparseskeleton.c
+++ b/libavformat/oggparseskeleton.c
@@ -89,4 +89,5 @@ const struct ogg_codec ff_skeleton_codec = {
.magic = "fishead",
.magicsize = 8,
.header = skeleton_header,
+ .nb_header = 0,
};
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index e4dfec5218..11b50d5905 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -122,5 +122,6 @@ const struct ogg_codec ff_speex_codec = {
.magic = "Speex ",
.magicsize = 8,
.header = speex_header,
- .packet = speex_packet
+ .packet = speex_packet,
+ .nb_header = 2,
};
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 7762c00475..4810357d03 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -192,5 +192,6 @@ const struct ogg_codec ff_theora_codec = {
.magicsize = 7,
.header = theora_header,
.packet = theora_packet,
- .gptopts = theora_gptopts
+ .gptopts = theora_gptopts,
+ .nb_header = 3,
};
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 38eb4b0b1c..09f5205fbb 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -367,4 +367,5 @@ const struct ogg_codec ff_vorbis_codec = {
.magicsize = 7,
.header = vorbis_header,
.packet = vorbis_packet,
+ .nb_header = 3,
};
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a48369fdfb..e5826c1181 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2346,10 +2346,13 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
{
const AVCodec *codec;
int got_picture = 1, ret = 0;
- AVFrame picture;
+ AVFrame *frame = avcodec_alloc_frame();
AVSubtitle subtitle;
AVPacket pkt = *avpkt;
+ if (!frame)
+ return AVERROR(ENOMEM);
+
if (!avcodec_is_open(st->codec) && !st->info->found_decoder) {
AVDictionary *thread_opt = NULL;
@@ -2358,7 +2361,8 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
if (!codec) {
st->info->found_decoder = -1;
- return -1;
+ ret = -1;
+ goto fail;
}
/* force thread count to 1 since the h264 decoder will not extract SPS
@@ -2369,14 +2373,16 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
av_dict_free(&thread_opt);
if (ret < 0) {
st->info->found_decoder = -1;
- return ret;
+ goto fail;
}
st->info->found_decoder = 1;
} else if (!st->info->found_decoder)
st->info->found_decoder = 1;
- if (st->info->found_decoder < 0)
- return -1;
+ if (st->info->found_decoder < 0) {
+ ret = -1;
+ goto fail;
+ }
while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
ret >= 0 &&
@@ -2384,14 +2390,14 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
!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);
+ avcodec_get_frame_defaults(frame);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- ret = avcodec_decode_video2(st->codec, &picture,
+ ret = avcodec_decode_video2(st->codec, frame,
&got_picture, &pkt);
break;
case AVMEDIA_TYPE_AUDIO:
- ret = avcodec_decode_audio4(st->codec, &picture, &got_picture, &pkt);
+ ret = avcodec_decode_audio4(st->codec, frame, &got_picture, &pkt);
break;
case AVMEDIA_TYPE_SUBTITLE:
ret = avcodec_decode_subtitle2(st->codec, &subtitle,
@@ -2409,8 +2415,12 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
ret = got_picture;
}
}
+
if(!pkt.data && !got_picture)
- return -1;
+ ret = -1;
+
+fail:
+ avcodec_free_frame(&frame);
return ret;
}