summaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-08 02:03:14 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-08 02:03:14 +0100
commit0bd42ae72c0e88826b823d8106286d5abe2028e7 (patch)
treeda7087d1f67ea54580026e30dcedb4f58db6aba6 /libavformat
parent5955c63c36e9b822f1186cd45a8dec5056b9c575 (diff)
parent1c8c41ff079953d332f61a9d26656e4e36af606c (diff)
downloadffmpeg-streaming-0bd42ae72c0e88826b823d8106286d5abe2028e7.zip
ffmpeg-streaming-0bd42ae72c0e88826b823d8106286d5abe2028e7.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: avformat: Avoid a warning about mixed declarations and code BMV demuxer and decoder matroskaenc: Make sure the seekhead struct is freed even on seek failure mpeg12enc: Remove write-only variables. mpeg12enc: Don't set up run-level info for level 0. msmpeg4: Don't set up run-level info for level 0. avformat: Warn about using network functions without calling avformat_network_init avformat: Revise wording rdt: Set AVFMT_NOFILE on ff_rdt_demuxer rdt: Check the return value of avformat_open rtsp: Discard the dynamic handler, if it has an alloc function which failed dsputil: use cpuflags in x86 versions of vector_clip_int32() Conflicts: libavcodec/avcodec.h libavcodec/version.h libavformat/Makefile libavformat/allformats.c libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/Makefile1
-rw-r--r--libavformat/allformats.c1
-rw-r--r--libavformat/avformat.h4
-rw-r--r--libavformat/bmv.c136
-rw-r--r--libavformat/matroskaenc.c10
-rw-r--r--libavformat/network.c7
-rw-r--r--libavformat/network.h1
-rw-r--r--libavformat/rdt.c6
-rw-r--r--libavformat/rmdec.c1
-rw-r--r--libavformat/rtsp.c5
-rw-r--r--libavformat/utils.c1
-rw-r--r--libavformat/version.h2
12 files changed, 167 insertions, 8 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 420143d..32fac6a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -53,6 +53,7 @@ OBJS-$(CONFIG_BINK_DEMUXER) += bink.o
OBJS-$(CONFIG_BINTEXT_DEMUXER) += bintext.o sauce.o
OBJS-$(CONFIG_BIT_DEMUXER) += bit.o
OBJS-$(CONFIG_BIT_MUXER) += bit.o
+OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o
OBJS-$(CONFIG_C93_DEMUXER) += c93.o vocdec.o voc.o
OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o riff.o isom.o
OBJS-$(CONFIG_CAF_MUXER) += cafenc.o caf.o riff.o isom.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ced4b0a..23d568c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -74,6 +74,7 @@ void av_register_all(void)
REGISTER_DEMUXER (BINTEXT, bintext);
REGISTER_DEMUXER (BINK, bink);
REGISTER_MUXDEMUX (BIT, bit);
+ REGISTER_DEMUXER (BMV, bmv);
REGISTER_DEMUXER (C93, c93);
REGISTER_MUXDEMUX (CAF, caf);
REGISTER_MUXDEMUX (CAVSVIDEO, cavsvideo);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 0fcc38b..1b0229d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1860,8 +1860,8 @@ const AVClass *avformat_get_class(void);
* but recommended, since it avoids the overhead of implicitly
* doing the setup for each session.
*
- * Since the next major version bump, calling this function will become
- * mandatory if using network protocols.
+ * Calling this function will become mandatory if using network
+ * protocols at some major version bump.
*/
int avformat_network_init(void);
diff --git a/libavformat/bmv.c b/libavformat/bmv.c
new file mode 100644
index 0000000..fb41712
--- /dev/null
+++ b/libavformat/bmv.c
@@ -0,0 +1,136 @@
+/*
+ * Discworld II BMV demuxer
+ * Copyright (c) 2011 Konstantin Shishkov.
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+
+enum BMVFlags {
+ BMV_NOP = 0,
+ BMV_END,
+ BMV_DELTA,
+ BMV_INTRA,
+
+ BMV_AUDIO = 0x20,
+};
+
+typedef struct BMVContext {
+ uint8_t *packet;
+ int size;
+ int get_next;
+ int64_t audio_pos;
+} BMVContext;
+
+static int bmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+ AVStream *st, *ast;
+ BMVContext *c = s->priv_data;
+
+ st = avformat_new_stream(s, 0);
+ if (!st)
+ return AVERROR(ENOMEM);
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_BMV_VIDEO;
+ st->codec->width = 640;
+ st->codec->height = 429;
+ st->codec->pix_fmt = PIX_FMT_PAL8;
+ av_set_pts_info(st, 16, 1, 12);
+ ast = avformat_new_stream(s, 0);
+ if (!ast)
+ return AVERROR(ENOMEM);
+ ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codec->codec_id = CODEC_ID_BMV_AUDIO;
+ ast->codec->channels = 2;
+ ast->codec->sample_rate = 22050;
+ av_set_pts_info(ast, 16, 1, 22050);
+
+ c->get_next = 1;
+ c->audio_pos = 0;
+ return 0;
+}
+
+static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ BMVContext *c = s->priv_data;
+ int type;
+ void *tmp;
+
+ while (c->get_next) {
+ if (s->pb->eof_reached)
+ return AVERROR_EOF;
+ type = avio_r8(s->pb);
+ if (type == BMV_NOP)
+ continue;
+ if (type == BMV_END)
+ return AVERROR_EOF;
+ c->size = avio_rl24(s->pb);
+ if (!c->size)
+ return AVERROR_INVALIDDATA;
+ tmp = av_realloc(c->packet, c->size + 1);
+ if (!tmp)
+ return AVERROR(ENOMEM);
+ c->packet = tmp;
+ c->packet[0] = type;
+ if (avio_read(s->pb, c->packet + 1, c->size) != c->size)
+ return AVERROR(EIO);
+ if (type & BMV_AUDIO) {
+ int audio_size = c->packet[1] * 65 + 1;
+ if (audio_size >= c->size) {
+ av_log(s, AV_LOG_ERROR, "Reported audio size %d is bigger than packet size (%d)\n",
+ audio_size, c->size);
+ return AVERROR_INVALIDDATA;
+ }
+ if (av_new_packet(pkt, audio_size) < 0)
+ return AVERROR(ENOMEM);
+ memcpy(pkt->data, c->packet + 1, pkt->size);
+ pkt->stream_index = 1;
+ pkt->pts = c->audio_pos;
+ pkt->duration = c->packet[1] * 32;
+ c->audio_pos += pkt->duration;
+ c->get_next = 0;
+ return pkt->size;
+ } else
+ break;
+ }
+ if (av_new_packet(pkt, c->size + 1) < 0)
+ return AVERROR(ENOMEM);
+ pkt->stream_index = 0;
+ c->get_next = 1;
+ memcpy(pkt->data, c->packet, pkt->size);
+ return pkt->size;
+}
+
+static int bmv_read_close(AVFormatContext *s)
+{
+ BMVContext *c = s->priv_data;
+
+ av_freep(&c->packet);
+
+ return 0;
+}
+
+AVInputFormat ff_bmv_demuxer = {
+ .name = "bmv",
+ .long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV"),
+ .priv_data_size = sizeof(BMVContext),
+ .read_header = bmv_read_header,
+ .read_packet = bmv_read_packet,
+ .read_close = bmv_read_close,
+ .extensions = "bmv"
+};
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 131a749..f22e084 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -317,9 +317,12 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
currentpos = avio_tell(pb);
- if (seekhead->reserved_size > 0)
- if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)
- return -1;
+ if (seekhead->reserved_size > 0) {
+ if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
+ currentpos = -1;
+ goto fail;
+ }
+ }
metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
for (i = 0; i < seekhead->num_entries; i++) {
@@ -343,6 +346,7 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
currentpos = seekhead->filepos;
}
+fail:
av_free(seekhead->entries);
av_free(seekhead);
diff --git a/libavformat/network.c b/libavformat/network.c
index e5482a1..e27c64d 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -120,8 +120,15 @@ void ff_tls_deinit(void)
avpriv_unlock_avformat();
}
+int ff_network_inited_globally;
+
int ff_network_init(void)
{
+ if (!ff_network_inited_globally)
+ av_log(NULL, AV_LOG_WARNING, "Using network protocols without global "
+ "network initialization. Please use "
+ "avformat_network_init(), this will "
+ "become mandatory later.\n");
#if HAVE_WINSOCK2_H
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1,1), &wsaData))
diff --git a/libavformat/network.h b/libavformat/network.h
index cfbbd83..9f7b782 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -56,6 +56,7 @@ int ff_neterrno(void);
int ff_socket_nonblock(int socket, int enable);
+extern int ff_network_inited_globally;
int ff_network_init(void);
void ff_network_close(void);
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index 74f9c55..947ba80 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -524,7 +524,11 @@ rdt_new_context (void)
{
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
- avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
+ int ret = avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
+ if (ret < 0) {
+ av_free(rdt);
+ return NULL;
+ }
return rdt;
}
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index b73b51a..0d88e76 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -975,4 +975,5 @@ AVInputFormat ff_rdt_demuxer = {
.long_name = NULL_IF_CONFIG_SMALL("RDT demuxer"),
.priv_data_size = sizeof(RMDemuxContext),
.read_close = rm_read_close,
+ .flags = AVFMT_NOFILE,
};
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index b23100d..c53b728 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -172,8 +172,11 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
return;
codec->codec_id = handler->codec_id;
rtsp_st->dynamic_handler = handler;
- if (handler->alloc)
+ if (handler->alloc) {
rtsp_st->dynamic_protocol_context = handler->alloc();
+ if (!rtsp_st->dynamic_protocol_context)
+ rtsp_st->dynamic_handler = NULL;
+ }
}
/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 35a6ab8..f32f238 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4188,6 +4188,7 @@ int avformat_network_init(void)
{
#if CONFIG_NETWORK
int ret;
+ ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0)
return ret;
ff_tls_init();
diff --git a/libavformat/version.h b/libavformat/version.h
index bc427d3..954d87a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR 19
+#define LIBAVFORMAT_VERSION_MINOR 20
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
OpenPOWER on IntegriCloud