aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorrogerdpack <rogerpack2005@gmail.com>2013-01-15 19:09:15 -0700
committerrogerdpack <rogerpack2005@gmail.com>2013-01-15 19:09:15 -0700
commitc540312ac3b58e0bbd751844fc2c47c6e3713cf5 (patch)
treefcf92b1c0f1772b379828125c2555a47d1c81c6b /libavformat
parent47e88486b4b3b3de992b07f89dfaedf410a8bd5e (diff)
parent2b20397e1fbe52db800ef5deb810f7bc2602f248 (diff)
downloadffmpeg-c540312ac3b58e0bbd751844fc2c47c6e3713cf5.tar.gz
Merge remote-tracking branch 'origin/master' into combined
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/asfdec.c2
-rw-r--r--libavformat/au.c28
-rw-r--r--libavformat/avisynth.c2
-rw-r--r--libavformat/bink.c1
-rw-r--r--libavformat/flvdec.c4
-rw-r--r--libavformat/loasdec.c1
-rw-r--r--libavformat/matroska.c1
-rw-r--r--libavformat/matroskaenc.c9
-rw-r--r--libavformat/movenc.c3
-rw-r--r--libavformat/mvi.c1
-rw-r--r--libavformat/oggenc.c2
-rw-r--r--libavformat/oggparsevorbis.c8
-rw-r--r--libavformat/r3d.c7
-rw-r--r--libavformat/rtp.c2
-rw-r--r--libavformat/segment.c4
-rw-r--r--libavformat/yuv4mpeg.c68
16 files changed, 74 insertions, 69 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 5c2cf8b9b0..465d9e5792 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -943,7 +943,7 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
av_dlog(asf, "key:%d stream:%d seq:%d offset:%d replic_size:%d\n",
asf->packet_key_frame, asf->stream_index, asf->packet_seq,
asf->packet_frag_offset, asf->packet_replic_size);
- if (rsize+asf->packet_replic_size > asf->packet_size_left) {
+ if (rsize+(int64_t)asf->packet_replic_size > asf->packet_size_left) {
av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size);
return AVERROR_INVALIDDATA;
}
diff --git a/libavformat/au.c b/libavformat/au.c
index b3a793d7ff..db2ab27558 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -151,11 +151,21 @@ AVInputFormat ff_au_demuxer = {
#include "rawenc.h"
-/* AUDIO_FILE header */
-static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
+static int au_write_header(AVFormatContext *s)
{
- if (!enc->codec_tag)
+ AVIOContext *pb = s->pb;
+ AVCodecContext *enc = s->streams[0]->codec;
+
+ if (s->nb_streams != 1) {
+ av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
+ return AVERROR(EINVAL);
+ }
+
+ enc->codec_tag = ff_codec_get_tag(codec_au_tags, enc->codec_id);
+ if (!enc->codec_tag) {
+ av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
+ }
ffio_wfourcc(pb, ".snd"); /* magic number */
avio_wb32(pb, AU_HEADER_SIZE); /* header size */
@@ -164,18 +174,6 @@ static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
avio_wb32(pb, enc->sample_rate);
avio_wb32(pb, enc->channels);
avio_wb64(pb, 0); /* annotation field */
-
- return 0;
-}
-
-static int au_write_header(AVFormatContext *s)
-{
- AVIOContext *pb = s->pb;
- int ret;
-
- if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0)
- return ret;
-
avio_flush(pb);
return 0;
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index e5d9b7626f..1e4dee1b00 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -226,7 +226,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts,
}
AVInputFormat ff_avisynth_demuxer = {
- .name = "avs",
+ .name = "avisynth",
.long_name = NULL_IF_CONFIG_SMALL("AVISynth"),
.priv_data_size = sizeof(AVISynthContext),
.read_header = avisynth_read_header,
diff --git a/libavformat/bink.c b/libavformat/bink.c
index c77a8f84e7..887f70a512 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -112,6 +112,7 @@ static int read_header(AVFormatContext *s)
return AVERROR(EIO);
}
avpriv_set_pts_info(vst, 64, fps_den, fps_num);
+ vst->avg_frame_rate = av_inv_q(vst->time_base);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO;
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 09a77c4852..b57929eda1 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -713,13 +713,13 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
st = s->streams[i];
if (stream_type == FLV_STREAM_TYPE_AUDIO) {
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- flv_same_audio_codec(st->codec, flags)) {
+ (s->audio_codec_id || flv_same_audio_codec(st->codec, flags))) {
break;
}
} else
if (stream_type == FLV_STREAM_TYPE_VIDEO) {
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
- flv_same_video_codec(st->codec, flags)) {
+ (s->video_codec_id || flv_same_video_codec(st->codec, flags))) {
break;
}
} else if (stream_type == FLV_STREAM_TYPE_DATA) {
diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c
index 2a06fe12a7..d3a8dbd6cd 100644
--- a/libavformat/loasdec.c
+++ b/libavformat/loasdec.c
@@ -55,7 +55,6 @@ static int loas_probe(AVProbeData *p)
if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
else if(max_frames>100)return AVPROBE_SCORE_MAX/2;
else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
- else if(max_frames>=1) return 1;
else return 0;
}
diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 394a62f9d3..519f881e89 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -66,6 +66,7 @@ const CodecTags ff_mkv_codec_tags[]={
{"S_ASS" , AV_CODEC_ID_SSA},
{"S_SSA" , AV_CODEC_ID_SSA},
{"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE},
+ {"S_DVBSUB" , AV_CODEC_ID_DVB_SUBTITLE},
{"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE},
{"V_DIRAC" , AV_CODEC_ID_DIRAC},
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index c167c015fe..204d1b2394 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -530,7 +530,7 @@ static int mkv_write_tracks(AVFormatContext *s)
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
ebml_master tracks;
- int i, j, ret;
+ int i, j, ret, default_stream_exists = 0;
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb));
if (ret < 0) return ret;
@@ -538,6 +538,10 @@ static int mkv_write_tracks(AVFormatContext *s)
tracks = start_ebml_master(pb, MATROSKA_ID_TRACKS, 0);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
+ default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT;
+ }
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
AVCodecContext *codec = st->codec;
ebml_master subinfo, track;
int native_id = 0;
@@ -570,8 +574,9 @@ static int mkv_write_tracks(AVFormatContext *s)
tag = av_dict_get(st->metadata, "language", NULL, 0);
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und");
- if (st->disposition)
+ if (default_stream_exists) {
put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT));
+ }
if (st->disposition & AV_DISPOSITION_FORCED)
put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, 1);
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1b851c03dd..08015b545c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -356,8 +356,7 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
else
avio_w8(pb, 0x11); // flags (= Visualstream)
- avio_w8(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
- avio_wb16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
+ avio_wb24(pb, track->enc->rc_buffer_size >> 3); // Buffersize DB
avg_bitrate = compute_avg_bitrate(track);
// maxbitrate (FIXME should be max rate in any 1 sec window)
diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index 9184927a2f..6b74597f07 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -89,6 +89,7 @@ static int read_header(AVFormatContext *s)
ast->codec->bit_rate = ast->codec->sample_rate * 8;
avpriv_set_pts_info(vst, 64, msecs_per_frame, 1000000);
+ vst->avg_frame_rate = av_inv_q(vst->time_base);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_MOTIONPIXELS;
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 31e28413e9..3d4519c1ac 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -402,7 +402,7 @@ static int ogg_build_opus_headers(AVCodecContext *avctx,
static int ogg_write_header(AVFormatContext *s)
{
OGGContext *ogg = s->priv_data;
- OGGStreamContext *oggstream;
+ OGGStreamContext *oggstream = NULL;
int i, j;
if (ogg->pref_size)
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 16bcaefd4d..0b52bc7c17 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -173,11 +173,15 @@ static unsigned int
fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv,
uint8_t **buf)
{
- int i,offset, len;
+ int i,offset, len, buf_len;
unsigned char *ptr;
len = priv->len[0] + priv->len[1] + priv->len[2];
- ptr = *buf = av_mallocz(len + len/255 + 64);
+ buf_len = len + len/255 + 64;
+ ptr = *buf = av_realloc(NULL, buf_len);
+ if (!*buf)
+ return 0;
+ memset(*buf, '\0', buf_len);
ptr[0] = 2;
offset = 1;
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 35da81eff1..3b3ecce3d9 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -285,6 +285,10 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
dts = avio_rb32(s->pb);
st->codec->sample_rate = avio_rb32(s->pb);
+ if (st->codec->sample_rate < 0) {
+ av_log(s, AV_LOG_ERROR, "negative sample rate\n");
+ return AVERROR_INVALIDDATA;
+ }
samples = avio_rb32(s->pb);
@@ -312,7 +316,8 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
pkt->stream_index = 1;
pkt->dts = dts;
- pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
+ if (st->codec->sample_rate)
+ pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
av_dlog(s, "pkt dts %"PRId64" duration %d samples %d sample rate %d\n",
pkt->dts, pkt->duration, samples, st->codec->sample_rate);
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index b76e521a8c..c4dcf6ae8d 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <libavutil/opt.h>
+#include "libavutil/opt.h"
#include "avformat.h"
#include "rtp.h"
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 7d7222922c..9c271eb3a8 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -219,8 +219,8 @@ static int segment_list_open(AVFormatContext *s)
avio_printf(seg->list_pb, "#EXTM3U\n");
avio_printf(seg->list_pb, "#EXT-X-VERSION:3\n");
avio_printf(seg->list_pb, "#EXT-X-MEDIA-SEQUENCE:%d\n", seg->segment_list_entries->index);
- avio_printf(seg->list_pb, "#EXT-X-ALLOWCACHE:%d\n",
- !!(seg->list_flags & SEGMENT_LIST_FLAG_CACHE));
+ avio_printf(seg->list_pb, "#EXT-X-ALLOW-CACHE:%s\n",
+ seg->list_flags & SEGMENT_LIST_FLAG_CACHE ? "YES" : "NO");
for (entry = seg->segment_list_entries; entry; entry = entry->next)
max_duration = FFMAX(max_duration, entry->end_time - entry->start_time);
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
index ff039bd37a..f34a4afce1 100644
--- a/libavformat/yuv4mpeg.c
+++ b/libavformat/yuv4mpeg.c
@@ -28,11 +28,6 @@
#define Y4M_FRAME_MAGIC "FRAME"
#define Y4M_LINE_MAX 256
-struct frame_attributes {
- int interlaced_frame;
- int top_field_first;
-};
-
#if CONFIG_YUV4MPEGPIPE_MUXER
static int yuv4_generate_header(AVFormatContext *s, char* buf)
{
@@ -58,6 +53,13 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
inter = 'p'; /* progressive is the default */
if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame)
inter = st->codec->coded_frame->top_field_first ? 't' : 'b';
+ if (st->codec->field_order == AV_FIELD_PROGRESSIVE) {
+ inter = 'p';
+ } else if (st->codec->field_order == AV_FIELD_TB || st->codec->field_order == AV_FIELD_TT) {
+ inter = 't';
+ } else if (st->codec->field_order == AV_FIELD_BT || st->codec->field_order == AV_FIELD_BB) {
+ inter = 'b';
+ }
switch (st->codec->pix_fmt) {
case AV_PIX_FMT_GRAY8:
@@ -319,7 +321,7 @@ static int yuv4_read_header(AVFormatContext *s)
{
char header[MAX_YUV4_HEADER + 10]; // Include headroom for
// the longest option
- char *tokstart, *tokend, *header_end;
+ char *tokstart, *tokend, *header_end, interlaced = '?';
int i;
AVIOContext *pb = s->pb;
int width = -1, height = -1, raten = 0,
@@ -327,7 +329,6 @@ static int yuv4_read_header(AVFormatContext *s)
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE;
enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;
AVStream *st;
- struct frame_attributes *s1 = s->priv_data;
for (i = 0; i < MAX_YUV4_HEADER; i++) {
header[i] = avio_r8(pb);
@@ -343,8 +344,6 @@ static int yuv4_read_header(AVFormatContext *s)
if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))
return -1;
- s1->interlaced_frame = 0;
- s1->top_field_first = 0;
header_end = &header[i + 1]; // Include space
for (tokstart = &header[strlen(Y4M_MAGIC) + 1];
tokstart < header_end; tokstart++) {
@@ -425,28 +424,7 @@ static int yuv4_read_header(AVFormatContext *s)
tokstart++;
break;
case 'I': // Interlace type
- switch (*tokstart++){
- case '?':
- break;
- case 'p':
- s1->interlaced_frame = 0;
- break;
- case 't':
- s1->interlaced_frame = 1;
- s1->top_field_first = 1;
- break;
- case 'b':
- s1->interlaced_frame = 1;
- s1->top_field_first = 0;
- break;
- case 'm':
- av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "
- "interlaced and non-interlaced frames.\n");
- return -1;
- default:
- av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");
- return -1;
- }
+ interlaced = *tokstart++;
break;
case 'F': // Frame rate
sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown
@@ -547,6 +525,27 @@ static int yuv4_read_header(AVFormatContext *s)
st->sample_aspect_ratio = (AVRational){ aspectn, aspectd };
st->codec->chroma_sample_location = chroma_sample_location;
+ switch (interlaced){
+ case 'p':
+ st->codec->field_order = AV_FIELD_PROGRESSIVE;
+ break;
+ case 't':
+ st->codec->field_order = AV_FIELD_TB;
+ break;
+ case 'b':
+ st->codec->field_order = AV_FIELD_BT;
+ break;
+ case 'm':
+ av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "
+ "interlaced and non-interlaced frames.\n");
+ case '?':
+ st->codec->field_order = AV_FIELD_UNKNOWN;
+ break;
+ default:
+ av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");
+ return AVERROR(EINVAL);
+ }
+
return 0;
}
@@ -556,7 +555,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
char header[MAX_FRAME_HEADER+1];
int packet_size, width, height, ret;
AVStream *st = s->streams[0];
- struct frame_attributes *s1 = s->priv_data;
for (i = 0; i < MAX_FRAME_HEADER; i++) {
header[i] = avio_r8(s->pb);
@@ -588,11 +586,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
else if (ret != packet_size)
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
- if (st->codec->coded_frame) {
- st->codec->coded_frame->interlaced_frame = s1->interlaced_frame;
- st->codec->coded_frame->top_field_first = s1->top_field_first;
- }
-
pkt->stream_index = 0;
return 0;
}
@@ -610,7 +603,6 @@ static int yuv4_probe(AVProbeData *pd)
AVInputFormat ff_yuv4mpegpipe_demuxer = {
.name = "yuv4mpegpipe",
.long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe"),
- .priv_data_size = sizeof(struct frame_attributes),
.read_probe = yuv4_probe,
.read_header = yuv4_read_header,
.read_packet = yuv4_read_packet,