summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-28 01:07:11 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-28 01:07:11 +0100
commit1e19927f12a2a65954aabf38b584025beff15cc3 (patch)
tree33c88297cb164490ebe38b67cf353029d9fb83f2 /libavformat
parentca55606a5127a9ddb10e4c1971c56e3e69bfd864 (diff)
parent1f948745c3cbe45c4ccd5d8996fc885d826bf3ff (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: vc1: use an enum for Frame Coding Mode doc: cleanup filter section indeo3: error out if no motion vector is set. x86inc: Flag shufps as an floating-point instruction for the AVX emulation code. mpegaudio: do not use init_static_data() for initializing tables. musepack: fix signed shift overflow in mpc_read_packet() mov: Make format string match variable type. wmavoice: Make format string match variable type. vc1: select interlaced scan table by FCM element Generalize RIFF INFO tag support; support reading INFO tag in wav pthread: track thread existence in a separate variable. Conflicts: doc/filters.texi libavcodec/pthread.c libavformat/avi.c libavformat/riff.c libavformat/riff.h libavformat/wav.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/Makefile4
-rw-r--r--libavformat/avi.c45
-rw-r--r--libavformat/avi.h9
-rw-r--r--libavformat/avidec.c19
-rw-r--r--libavformat/avienc.c6
-rw-r--r--libavformat/mov.c4
-rw-r--r--libavformat/mpc.c6
-rw-r--r--libavformat/riff.c68
-rw-r--r--libavformat/riff.h6
-rw-r--r--libavformat/wav.c18
10 files changed, 107 insertions, 78 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3581a3d2d5..1e59a91dc2 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -43,8 +43,8 @@ OBJS-$(CONFIG_ASS_DEMUXER) += assdec.o
OBJS-$(CONFIG_ASS_MUXER) += assenc.o
OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o
OBJS-$(CONFIG_AU_MUXER) += au.o
-OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o riff.o avi.o
-OBJS-$(CONFIG_AVI_MUXER) += avienc.o riff.o avi.o
+OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o riff.o
+OBJS-$(CONFIG_AVI_MUXER) += avienc.o riff.o
OBJS-$(CONFIG_AVISYNTH) += avisynth.o
OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o
OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o
diff --git a/libavformat/avi.c b/libavformat/avi.c
deleted file mode 100644
index 705ad03ab0..0000000000
--- a/libavformat/avi.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * AVI common data
- * Copyright (c) 2010 Anton Khirnov
- *
- * 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 "avi.h"
-
-const AVMetadataConv ff_avi_metadata_conv[] = {
- { "IART", "artist" },
- { "ICMT", "comment" },
- { "ICOP", "copyright" },
- { "ICRD", "date" },
- { "IGNR", "genre" },
- { "ILNG", "language" },
- { "INAM", "title" },
- { "IPRD", "album" },
- { "IPRT", "track" },
- { "ISFT", "encoder" },
- { "ITCH", "encoded_by"},
- { "strn", "title" },
- { 0 },
-};
-
-const char ff_avi_tags[][5] = {
- "IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI",
- "IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD",
- "IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH",
- {0}
-};
diff --git a/libavformat/avi.h b/libavformat/avi.h
index b4e551971a..34da76f715 100644
--- a/libavformat/avi.h
+++ b/libavformat/avi.h
@@ -21,8 +21,6 @@
#ifndef AVFORMAT_AVI_H
#define AVFORMAT_AVI_H
-#include "metadata.h"
-
#define AVIF_HASINDEX 0x00000010 // Index at end of file?
#define AVIF_MUSTUSEINDEX 0x00000020
#define AVIF_ISINTERLEAVED 0x00000100
@@ -37,11 +35,4 @@
/* index flags */
#define AVIIF_INDEX 0x10
-extern const AVMetadataConv ff_avi_metadata_conv[];
-
-/**
- * A list of AVI info tags.
- */
-extern const char ff_avi_tags[][5];
-
#endif /* AVFORMAT_AVI_H */
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 158c6a6551..fd91c99b1c 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -99,6 +99,11 @@ static const char avi_headers[][8] = {
{ 0 }
};
+static const AVMetadataConv avi_metadata_conv[] = {
+ { "strn", "title" },
+ { 0 },
+};
+
static int avi_load_index(AVFormatContext *s);
static int guess_ni_flag(AVFormatContext *s);
@@ -287,15 +292,6 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
AV_DICT_DONT_STRDUP_VAL);
}
-static void avi_read_info(AVFormatContext *s, uint64_t end)
-{
- while (avio_tell(s->pb) < end) {
- uint32_t tag = avio_rl32(s->pb);
- uint32_t size = avio_rl32(s->pb);
- avi_read_tag(s, NULL, tag, size);
- }
-}
-
static const char months[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
@@ -408,7 +404,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto end_of_header;
}
else if (tag1 == MKTAG('I', 'N', 'F', 'O'))
- avi_read_info(s, list_end);
+ ff_read_riff_info(s, size - 4);
else if (tag1 == MKTAG('n', 'c', 'd', 't'))
avi_read_nikon(s, list_end);
@@ -778,7 +774,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
clean_index(s);
}
- ff_metadata_conv_ctx(s, NULL, ff_avi_metadata_conv);
+ ff_metadata_conv_ctx(s, NULL, avi_metadata_conv);
+ ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
return 0;
}
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index b4dc65c243..583305073f 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -378,9 +378,9 @@ static int avi_write_header(AVFormatContext *s)
list2 = ff_start_tag(pb, "LIST");
ffio_wfourcc(pb, "INFO");
- ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
- for (i = 0; *ff_avi_tags[i]; i++) {
- if ((t = av_dict_get(s->metadata, ff_avi_tags[i], NULL, AV_DICT_MATCH_CASE)))
+ ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL);
+ for (i = 0; *ff_riff_tags[i]; i++) {
+ if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE)))
avi_write_info_tag(s->pb, t->key, t->value);
}
ff_end_tag(pb, list2);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a30b6bb7d2..763e985f8f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -90,7 +90,7 @@ static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb,
avio_r8(pb);
avio_r8(pb);
- snprintf(buf, sizeof(buf), "%hu", avio_r8(pb));
+ snprintf(buf, sizeof(buf), "%d", avio_r8(pb));
av_dict_set(&c->fc->metadata, key, buf, 0);
return 0;
@@ -101,7 +101,7 @@ static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb,
{
char buf[16];
- snprintf(buf, sizeof(buf), "%hu", avio_r8(pb));
+ snprintf(buf, sizeof(buf), "%d", avio_r8(pb));
av_dict_set(&c->fc->metadata, key, buf, 0);
return 0;
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index f377e1f990..87d2abe1b5 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -117,7 +117,8 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MPCContext *c = s->priv_data;
int ret, size, size2, curbits, cur = c->curframe;
- int64_t tmp, pos;
+ unsigned tmp;
+ int64_t pos;
if (c->curframe >= c->fcount && c->fcount)
return -1;
@@ -134,8 +135,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
if(curbits <= 12){
size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
}else{
- tmp = (tmp << 32) | avio_rl32(s->pb);
- size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
+ size2 = (tmp << (curbits - 12) | avio_rl32(s->pb) >> (44 - curbits)) & 0xFFFFF;
}
curbits += 20;
avio_seek(s->pb, pos, SEEK_SET);
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 3acf80bb89..6c8d8abe40 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -357,6 +357,28 @@ const AVCodecGuid ff_codec_wav_guids[] = {
{CODEC_ID_NONE}
};
+const AVMetadataConv ff_riff_info_conv[] = {
+ { "IART", "artist" },
+ { "ICMT", "comment" },
+ { "ICOP", "copyright" },
+ { "ICRD", "date" },
+ { "IGNR", "genre" },
+ { "ILNG", "language" },
+ { "INAM", "title" },
+ { "IPRD", "album" },
+ { "IPRT", "track" },
+ { "ISFT", "encoder" },
+ { "ITCH", "encoded_by"},
+ { 0 },
+};
+
+const char ff_riff_tags[][5] = {
+ "IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI",
+ "IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD",
+ "IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH",
+ {0}
+};
+
#if CONFIG_MUXERS
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
@@ -656,3 +678,49 @@ enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
}
return CODEC_ID_NONE;
}
+
+int ff_read_riff_info(AVFormatContext *s, int64_t size)
+{
+ int64_t start, end, cur;
+ AVIOContext *pb = s->pb;
+
+ start = avio_tell(pb);
+ end = start + size;
+
+ while ((cur = avio_tell(pb)) >= 0 && cur <= end - 8 /* = tag + size */) {
+ uint32_t chunk_code;
+ int64_t chunk_size;
+ char key[5] = {0};
+ char *value;
+
+ chunk_code = avio_rl32(pb);
+ chunk_size = avio_rl32(pb);
+ if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) {
+ av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ chunk_size += (chunk_size & 1);
+
+ value = av_malloc(chunk_size + 1);
+ if (!value) {
+ av_log(s, AV_LOG_ERROR, "out of memory, unable to read INFO tag\n");
+ return AVERROR(ENOMEM);
+ }
+
+ AV_WL32(key, chunk_code);
+
+ if (avio_read(pb, value, chunk_size) != chunk_size) {
+ av_freep(key);
+ av_freep(value);
+ av_log(s, AV_LOG_ERROR, "premature end of file while reading INFO tag\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ value[chunk_size] = 0;
+
+ av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
+ }
+
+ return 0;
+}
diff --git a/libavformat/riff.h b/libavformat/riff.h
index 85caacbb69..67521e25cc 100644
--- a/libavformat/riff.h
+++ b/libavformat/riff.h
@@ -31,6 +31,10 @@
#include "libavcodec/avcodec.h"
#include "avio.h"
#include "internal.h"
+#include "metadata.h"
+
+extern const AVMetadataConv ff_riff_info_conv[];
+extern const char ff_riff_tags[][5];
int64_t ff_start_tag(AVIOContext *pb, const char *tag);
void ff_end_tag(AVIOContext *pb, int64_t start);
@@ -56,6 +60,8 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz
typedef uint8_t ff_asf_guid[16];
+int ff_read_riff_info(AVFormatContext *s, int64_t size);
+
#define FF_PRI_GUID \
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
#define FF_ARG_GUID(g) \
diff --git a/libavformat/wav.c b/libavformat/wav.c
index 22914c9ad5..20dd4c9f71 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -33,7 +33,6 @@
#include "pcm.h"
#include "riff.h"
#include "avio.h"
-#include "avio_internal.h"
#include "metadata.h"
typedef struct {
@@ -231,7 +230,7 @@ AVOutputFormat ff_wav_muxer = {
#if CONFIG_WAV_DEMUXER
-static int64_t next_tag(AVIOContext *pb, unsigned int *tag)
+static int64_t next_tag(AVIOContext *pb, uint32_t *tag)
{
*tag = avio_rl32(pb);
return avio_rl32(pb);
@@ -392,7 +391,7 @@ static int wav_read_header(AVFormatContext *s,
int64_t size, av_uninit(data_size);
int64_t sample_count=0;
int rf64;
- unsigned int tag;
+ uint32_t tag, list_type;
AVIOContext *pb = s->pb;
AVStream *st = NULL;
WAVContext *wav = s->priv_data;
@@ -504,6 +503,18 @@ static int wav_read_header(AVFormatContext *s,
avio_rl24(pb);
wav->smv_frames_per_jpeg = avio_rl24(pb);
goto break_loop;
+ case MKTAG('L', 'I', 'S', 'T'):
+ list_type = avio_rl32(pb);
+ if (size <= 4) {
+ av_log(s, AV_LOG_ERROR, "too short LIST");
+ return AVERROR_INVALIDDATA;
+ }
+ switch (list_type) {
+ case MKTAG('I', 'N', 'F', 'O'):
+ if ((ret = ff_read_riff_info(s, size - 4)) < 0)
+ return ret;
+ }
+ break;
}
/* seek to next tag unless we know that we'll run into EOF */
@@ -526,6 +537,7 @@ break_loop:
st->duration = sample_count;
ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
+ ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
return 0;
}