aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-21 19:41:08 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-21 19:41:08 +0100
commita12dec46995929622aae45e7f68c0f989110be56 (patch)
tree3ae0c8da6675d0e515a95c0a7b6c899a50ee8f13 /libavformat
parent87ae12009ea489c5c34e953b2b0194a8ba669fb2 (diff)
parent661ee45f8881bb551eb403472e60c38a7c2818aa (diff)
downloadffmpeg-a12dec46995929622aae45e7f68c0f989110be56.tar.gz
Merge branch 'release/0.8' into release/0.7
* release/0.8: (31 commits) svq1dec: call avcodec_set_dimensions() after dimensions changed. Fixes NGS00148 vp3dec: Check coefficient index in vp3_dequant() Fixes NGS00145 qdm2dec: fix buffer overflow. Fixes NGS00144 h264: Fix invalid interlaced progressive MB combinations for direct mode prediction. Fixes Ticket312 mpegvideo: dont use ff_mspel_motion() for vc1 Fixes Ticket655 imgutils: Fix illegal read. ac3probe: Detect Sonic Foundry Soft Encode AC3 as raw AC3. Our ac3 code chain can handle it fine. More ideal would be to write a demuxer that actually extracts what can be from the additional headers and uses it for whatever it can be used for. mjpeg: support mpo Fixes stereoscopic_photo.mpo Add a version bump and APIchanges entry for avcodec_open2 and avformat_find_stream_info. lavf: fix multiplication overflow in avformat_find_stream_info() lavf: fix invalid reads in avformat_find_stream_info() lavf: add avformat_find_stream_info() lavc: fix parentheses placement in avcodec_open2(). lavc: introduce avcodec_open2() as a replacement for avcodec_open(). rawdec: use a default sample rate if none is specified. Fixes "ffmpeg -f s16le -i /dev/zero" rawdec: add check on sample_rate qdm2dec: check remaining input bits in the mainloop of qdm2_fft_decode_tones() This is neccessary but likely not sufficient to prevent out of array reads. cinepak: check strip_size wma: Check channel number before init. Fixes Ticket240 Do not try to read 16bit gray png files with alpha channel. ... Conflicts: libavcodec/version.h libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/Makefile1
-rw-r--r--libavformat/ac3dec.c2
-rw-r--r--libavformat/avformat.h27
-rw-r--r--libavformat/rawdec.c8
-rw-r--r--libavformat/rtpdec.c5
-rw-r--r--libavformat/rtpdec_formats.h4
-rw-r--r--libavformat/rtpdec_g726.c94
-rw-r--r--libavformat/utils.c20
-rw-r--r--libavformat/version.h2
9 files changed, 155 insertions, 8 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 05f524690b..7f24959883 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -248,6 +248,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \
rtpdec.o \
rtpdec_amr.o \
rtpdec_asf.o \
+ rtpdec_g726.o \
rtpdec_h263.o \
rtpdec_h264.o \
rtpdec_latm.o \
diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c
index fcf99363ee..92e468da43 100644
--- a/libavformat/ac3dec.c
+++ b/libavformat/ac3dec.c
@@ -40,6 +40,8 @@ static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
+ if(!memcmp(buf2, "\x1\x10\0\0\0\0\0\0", 8))
+ buf2+=16;
init_get_bits(&gbc, buf2, 54);
if(ff_ac3_parse_header(&gbc, &hdr) < 0)
break;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 063dcb5cf0..2587629723 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1238,6 +1238,7 @@ AVFormatContext *avformat_alloc_output_context(const char *format,
int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat,
const char *format_name, const char *filename);
+#if FF_API_FORMAT_PARAMETERS
/**
* Read packets of a media file to get stream information. This
* is useful for file formats with no headers such as MPEG. This
@@ -1250,8 +1251,34 @@ int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oforma
* @return >=0 if OK, AVERROR_xxx on error
* @todo Let the user decide somehow what information is needed so that
* we do not waste time getting stuff the user does not need.
+ *
+ * @deprecated use avformat_find_stream_info.
*/
int av_find_stream_info(AVFormatContext *ic);
+#endif
+
+/**
+ * Read packets of a media file to get stream information. This
+ * is useful for file formats with no headers such as MPEG. This
+ * function also computes the real framerate in case of MPEG-2 repeat
+ * frame mode.
+ * The logical file position is not changed by this function;
+ * examined packets may be buffered for later processing.
+ *
+ * @param ic media file handle
+ * @param options If non-NULL, an ic.nb_streams long array of pointers to
+ * dictionaries, where i-th member contains options for
+ * codec corresponding to i-th stream.
+ * On return each dictionary will be filled with options that were not found.
+ * @return >=0 if OK, AVERROR_xxx on error
+ *
+ * @note this function isn't guaranteed to open all the codecs, so
+ * options being non-empty at return is a perfectly normal behavior.
+ *
+ * @todo Let the user decide somehow what information is needed so that
+ * we do not waste time getting stuff the user does not need.
+ */
+int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
/**
* Find the "best" stream in the file.
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index a4e009b7e0..76e05237ca 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -59,6 +59,12 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (s1->sample_rate)
st->codec->sample_rate = s1->sample_rate;
+ if (st->codec->sample_rate <= 0) {
+ av_log(s, AV_LOG_WARNING, "Invalid sample rate %d specified using default of 44100\n",
+ st->codec->sample_rate);
+ st->codec->sample_rate= 44100;
+ }
+
if (s1->channels)
st->codec->channels = s1->channels;
@@ -246,7 +252,7 @@ AVInputFormat ff_gsm_demuxer = {
#endif
#if CONFIG_MJPEG_DEMUXER
-FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg", CODEC_ID_MJPEG)
+FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg,mpo", CODEC_ID_MJPEG)
#endif
#if CONFIG_MLP_DEMUXER
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 130a78d0d1..db96a46849 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -82,6 +82,11 @@ void av_register_rtp_dynamic_payload_handlers(void)
ff_register_dynamic_payload_handler(&ff_qt_rtp_vid_handler);
ff_register_dynamic_payload_handler(&ff_quicktime_rtp_aud_handler);
ff_register_dynamic_payload_handler(&ff_quicktime_rtp_vid_handler);
+
+ ff_register_dynamic_payload_handler(&ff_g726_16_dynamic_handler);
+ ff_register_dynamic_payload_handler(&ff_g726_24_dynamic_handler);
+ ff_register_dynamic_payload_handler(&ff_g726_32_dynamic_handler);
+ ff_register_dynamic_payload_handler(&ff_g726_40_dynamic_handler);
}
RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
index 16f5a9d3e4..afd047be21 100644
--- a/libavformat/rtpdec_formats.h
+++ b/libavformat/rtpdec_formats.h
@@ -33,6 +33,10 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p);
extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler;
extern RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler;
+extern RTPDynamicProtocolHandler ff_g726_16_dynamic_handler;
+extern RTPDynamicProtocolHandler ff_g726_24_dynamic_handler;
+extern RTPDynamicProtocolHandler ff_g726_32_dynamic_handler;
+extern RTPDynamicProtocolHandler ff_g726_40_dynamic_handler;
extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler;
extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
diff --git a/libavformat/rtpdec_g726.c b/libavformat/rtpdec_g726.c
new file mode 100644
index 0000000000..cde832b21a
--- /dev/null
+++ b/libavformat/rtpdec_g726.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2011 Miroslav Slugeň <Thunder.m@seznam.cz>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rtpdec_formats.h"
+
+static int g726_16_parse_sdp_line(AVFormatContext *s, int st_index,
+ PayloadContext *data, const char *line)
+{
+ AVStream *stream = s->streams[st_index];
+ AVCodecContext *codec = stream->codec;
+
+ codec->bit_rate = 16000;
+
+ return 0;
+}
+
+static int g726_24_parse_sdp_line(AVFormatContext *s, int st_index,
+ PayloadContext *data, const char *line)
+{
+ AVStream *stream = s->streams[st_index];
+ AVCodecContext *codec = stream->codec;
+
+ codec->bit_rate = 24000;
+
+ return 0;
+}
+
+static int g726_32_parse_sdp_line(AVFormatContext *s, int st_index,
+ PayloadContext *data, const char *line)
+{
+ AVStream *stream = s->streams[st_index];
+ AVCodecContext *codec = stream->codec;
+
+ codec->bit_rate = 32000;
+
+ return 0;
+}
+
+static int g726_40_parse_sdp_line(AVFormatContext *s, int st_index,
+ PayloadContext *data, const char *line)
+{
+ AVStream *stream = s->streams[st_index];
+ AVCodecContext *codec = stream->codec;
+
+ codec->bit_rate = 40000;
+
+ return 0;
+}
+
+RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = {
+ .enc_name = "G726-16",
+ .codec_type = AVMEDIA_TYPE_AUDIO,
+ .codec_id = CODEC_ID_ADPCM_G726,
+ .parse_sdp_a_line = g726_16_parse_sdp_line,
+};
+
+RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = {
+ .enc_name = "G726-24",
+ .codec_type = AVMEDIA_TYPE_AUDIO,
+ .codec_id = CODEC_ID_ADPCM_G726,
+ .parse_sdp_a_line = g726_24_parse_sdp_line,
+};
+
+RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = {
+ .enc_name = "G726-32",
+ .codec_type = AVMEDIA_TYPE_AUDIO,
+ .codec_id = CODEC_ID_ADPCM_G726,
+ .parse_sdp_a_line = g726_32_parse_sdp_line,
+};
+
+RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = {
+ .enc_name = "G726-40",
+ .codec_type = AVMEDIA_TYPE_AUDIO,
+ .codec_id = CODEC_ID_ADPCM_G726,
+ .parse_sdp_a_line = g726_40_parse_sdp_line,
+};
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 96ceae9a63..d11b1365a2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2190,7 +2190,7 @@ static int has_decode_delay_been_guessed(AVStream *st)
st->codec_info_nb_frames >= 6 + st->codec->has_b_frames;
}
-static int try_decode_frame(AVStream *st, AVPacket *avpkt)
+static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options)
{
int16_t *samples;
AVCodec *codec;
@@ -2201,7 +2201,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt)
codec = avcodec_find_decoder(st->codec->codec_id);
if (!codec)
return -1;
- ret = avcodec_open(st->codec, codec);
+ ret = avcodec_open2(st->codec, codec, options);
if (ret < 0)
return ret;
}
@@ -2320,12 +2320,20 @@ static int tb_unreliable(AVCodecContext *c){
return 0;
}
+#if FF_API_FORMAT_PARAMETERS
int av_find_stream_info(AVFormatContext *ic)
{
+ return avformat_find_stream_info(ic, NULL);
+}
+#endif
+
+int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
+{
int i, count, ret, read_size, j;
AVStream *st;
AVPacket pkt1, *pkt;
int64_t old_offset = avio_tell(ic->pb);
+ int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
@@ -2362,12 +2370,12 @@ int av_find_stream_info(AVFormatContext *ic)
/* Ensure that subtitle_header is properly set. */
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
- avcodec_open(st->codec, codec);
+ avcodec_open2(st->codec, codec, options ? &options[i] : NULL);
//try to just open decoders, in case this is enough to get parameters
if(!has_codec_parameters(st->codec)){
if (codec && !st->codec->codec)
- avcodec_open(st->codec, codec);
+ avcodec_open2(st->codec, codec, options ? &options[i] : NULL);
}
}
@@ -2477,7 +2485,7 @@ int av_find_stream_info(AVFormatContext *ic)
for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) {
int framerate= get_std_framerate(i);
int ticks= lrintf(dur*framerate/(1001*12));
- double error= dur - ticks*1001*12/(double)framerate;
+ double error = dur - (double)ticks*1001*12 / framerate;
st->info->duration_error[i] += error*error;
}
st->info->duration_count++;
@@ -2503,7 +2511,7 @@ int av_find_stream_info(AVFormatContext *ic)
it takes longer and uses more memory. For MPEG-4, we need to
decompress for QuickTime. */
if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st))
- try_decode_frame(st, pkt);
+ try_decode_frame(st, pkt, (options && i < orig_nb_streams )? &options[i] : NULL);
st->codec_info_nb_frames++;
count++;
diff --git a/libavformat/version.h b/libavformat/version.h
index 65a3fd298e..24e247aa19 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 110
+#define LIBAVFORMAT_VERSION_MINOR 111
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \