Commit f545e006 authored by Kostya Shishkov's avatar Kostya Shishkov Committed by Martin Storsjö

BMV demuxer and decoder

Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent 44729bc0
......@@ -99,6 +99,7 @@ easier to use. The changes are:
AVCodecContext deprecated. Codec private options should be used instead.
- Properly working defaults in libx264 wrapper, support for native presets.
- Encrypted OMA files support
- Discworld II BMV decoding support
version 0.7:
......
......@@ -67,6 +67,7 @@ library:
@item Brute Force & Ignorance @tab @tab X
@tab Used in the game Flash Traffic: City of Angels.
@item BWF @tab X @tab X
@item Discworld II BMV @tab @tab X
@item Interplay C93 @tab @tab X
@tab Used in the game Cyberia from Interplay.
@item Delphine Software International CIN @tab @tab X
......@@ -376,6 +377,7 @@ following image formats are supported:
@tab AVS1-P2, JiZhun profile, encoding through external library libxavs
@item Delphine Software International CIN video @tab @tab X
@tab Codec used in Delphine Software International games.
@item Discworld II BMV Video @tab @tab X
@item Cinepak @tab @tab X
@item Cirrus Logic AccuPak @tab @tab X
@tab fourcc: CLJR
......@@ -608,6 +610,7 @@ following image formats are supported:
@tab Used in Bink and Smacker files in many games.
@item Delphine Software International CIN audio @tab @tab X
@tab Codec used in Delphine Software International games.
@item Discworld II BMV Audio @tab @tab X
@item COOK @tab @tab X
@tab All versions except 5.1 are supported.
@item DCA (DTS Coherent Acoustics) @tab @tab X
......
......@@ -94,6 +94,8 @@ OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o wma.o
OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o
OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o
OBJS-$(CONFIG_BMV_VIDEO_DECODER) += bmv.o
OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmv.o
OBJS-$(CONFIG_C93_DECODER) += c93.o
OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \
mpeg12data.o mpegvideo.o
......
......@@ -81,6 +81,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (BFI, bfi);
REGISTER_DECODER (BINK, bink);
REGISTER_ENCDEC (BMP, bmp);
REGISTER_DECODER (BMV_VIDEO, bmv_video);
REGISTER_DECODER (C93, c93);
REGISTER_DECODER (CAVS, cavs);
REGISTER_DECODER (CDGRAPHICS, cdgraphics);
......@@ -242,6 +243,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (ATRAC3, atrac3);
REGISTER_DECODER (BINKAUDIO_DCT, binkaudio_dct);
REGISTER_DECODER (BINKAUDIO_RDFT, binkaudio_rdft);
REGISTER_DECODER (BMV_AUDIO, bmv_audio);
REGISTER_DECODER (COOK, cook);
REGISTER_DECODER (DCA, dca);
REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
......
......@@ -219,6 +219,7 @@ enum CodecID {
CODEC_ID_G729,
#endif
CODEC_ID_UTVIDEO,
CODEC_ID_BMV_VIDEO,
/* various PCM "codecs" */
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
......@@ -359,6 +360,7 @@ enum CodecID {
CODEC_ID_8SVX_EXP,
CODEC_ID_8SVX_FIB,
#endif
CODEC_ID_BMV_AUDIO,
/* subtitle codecs */
CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 16
#define LIBAVCODEC_VERSION_MINOR 17
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
......@@ -46,6 +46,7 @@ OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o
OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o
OBJS-$(CONFIG_BFI_DEMUXER) += bfi.o
OBJS-$(CONFIG_BINK_DEMUXER) += bink.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_CAVSVIDEO_DEMUXER) += cavsvideodec.o rawdec.o
......
......@@ -70,6 +70,7 @@ void av_register_all(void)
REGISTER_DEMUXER (BETHSOFTVID, bethsoftvid);
REGISTER_DEMUXER (BFI, bfi);
REGISTER_DEMUXER (BINK, bink);
REGISTER_DEMUXER (BMV, bmv);
REGISTER_DEMUXER (C93, c93);
REGISTER_DEMUXER (CAF, caf);
REGISTER_MUXDEMUX (CAVSVIDEO, cavsvideo);
......
/*
* 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"
};
......@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR 13
#define LIBAVFORMAT_VERSION_MINOR 14
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment