Commit 0bd42ae7 authored by Michael Niedermayer's avatar Michael Niedermayer

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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 5955c63c 1c8c41ff
...@@ -118,6 +118,7 @@ easier to use. The changes are: ...@@ -118,6 +118,7 @@ easier to use. The changes are:
AVCodecContext deprecated. Codec private options should be used instead. AVCodecContext deprecated. Codec private options should be used instead.
- Properly working defaults in libx264 wrapper, support for native presets. - Properly working defaults in libx264 wrapper, support for native presets.
- Encrypted OMA files support - Encrypted OMA files support
- Discworld II BMV decoding support
version 0.8: version 0.8:
......
...@@ -71,6 +71,7 @@ library: ...@@ -71,6 +71,7 @@ library:
@item Brute Force & Ignorance @tab @tab X @item Brute Force & Ignorance @tab @tab X
@tab Used in the game Flash Traffic: City of Angels. @tab Used in the game Flash Traffic: City of Angels.
@item BWF @tab X @tab X @item BWF @tab X @tab X
@item Discworld II BMV @tab @tab X
@item Interplay C93 @tab @tab X @item Interplay C93 @tab @tab X
@tab Used in the game Cyberia from Interplay. @tab Used in the game Cyberia from Interplay.
@item Delphine Software International CIN @tab @tab X @item Delphine Software International CIN @tab @tab X
...@@ -386,6 +387,7 @@ following image formats are supported: ...@@ -386,6 +387,7 @@ following image formats are supported:
@tab AVS1-P2, JiZhun profile, encoding through external library libxavs @tab AVS1-P2, JiZhun profile, encoding through external library libxavs
@item Delphine Software International CIN video @tab @tab X @item Delphine Software International CIN video @tab @tab X
@tab Codec used in Delphine Software International games. @tab Codec used in Delphine Software International games.
@item Discworld II BMV Video @tab @tab X
@item Cinepak @tab @tab X @item Cinepak @tab @tab X
@item Cirrus Logic AccuPak @tab @tab X @item Cirrus Logic AccuPak @tab @tab X
@tab fourcc: CLJR @tab fourcc: CLJR
...@@ -624,6 +626,7 @@ following image formats are supported: ...@@ -624,6 +626,7 @@ following image formats are supported:
@tab decoding supported through external library libcelt @tab decoding supported through external library libcelt
@item Delphine Software International CIN audio @tab @tab X @item Delphine Software International CIN audio @tab @tab X
@tab Codec used in Delphine Software International games. @tab Codec used in Delphine Software International games.
@item Discworld II BMV Audio @tab @tab X
@item COOK @tab @tab X @item COOK @tab @tab X
@tab All versions except 5.1 are supported. @tab All versions except 5.1 are supported.
@item DCA (DTS Coherent Acoustics) @tab X @tab X @item DCA (DTS Coherent Acoustics) @tab X @tab X
......
...@@ -100,6 +100,8 @@ OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o ...@@ -100,6 +100,8 @@ OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o
OBJS-$(CONFIG_BINTEXT_DECODER) += bintext.o cga_data.o OBJS-$(CONFIG_BINTEXT_DECODER) += bintext.o cga_data.o
OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.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_C93_DECODER) += c93.o
OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \ OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \
mpeg12data.o mpegvideo.o mpeg12data.o mpegvideo.o
......
...@@ -84,6 +84,7 @@ void avcodec_register_all(void) ...@@ -84,6 +84,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (BFI, bfi); REGISTER_DECODER (BFI, bfi);
REGISTER_DECODER (BINK, bink); REGISTER_DECODER (BINK, bink);
REGISTER_ENCDEC (BMP, bmp); REGISTER_ENCDEC (BMP, bmp);
REGISTER_DECODER (BMV_VIDEO, bmv_video);
REGISTER_DECODER (C93, c93); REGISTER_DECODER (C93, c93);
REGISTER_DECODER (CAVS, cavs); REGISTER_DECODER (CAVS, cavs);
REGISTER_DECODER (CDGRAPHICS, cdgraphics); REGISTER_DECODER (CDGRAPHICS, cdgraphics);
...@@ -256,6 +257,7 @@ void avcodec_register_all(void) ...@@ -256,6 +257,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (ATRAC3, atrac3); REGISTER_DECODER (ATRAC3, atrac3);
REGISTER_DECODER (BINKAUDIO_DCT, binkaudio_dct); REGISTER_DECODER (BINKAUDIO_DCT, binkaudio_dct);
REGISTER_DECODER (BINKAUDIO_RDFT, binkaudio_rdft); REGISTER_DECODER (BINKAUDIO_RDFT, binkaudio_rdft);
REGISTER_DECODER (BMV_AUDIO, bmv_audio);
REGISTER_DECODER (COOK, cook); REGISTER_DECODER (COOK, cook);
REGISTER_ENCDEC (DCA, dca); REGISTER_ENCDEC (DCA, dca);
REGISTER_DECODER (DSICINAUDIO, dsicinaudio); REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
......
...@@ -220,6 +220,7 @@ enum CodecID { ...@@ -220,6 +220,7 @@ enum CodecID {
CODEC_ID_G729_DEPRECATED, CODEC_ID_G729_DEPRECATED,
#endif #endif
CODEC_ID_UTVIDEO_DEPRECATED, CODEC_ID_UTVIDEO_DEPRECATED,
CODEC_ID_BMV_VIDEO,
CODEC_ID_UTVIDEO = 0x800, CODEC_ID_UTVIDEO = 0x800,
CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'), CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
...@@ -363,6 +364,7 @@ enum CodecID { ...@@ -363,6 +364,7 @@ enum CodecID {
CODEC_ID_8SVX_EXP, CODEC_ID_8SVX_EXP,
CODEC_ID_8SVX_FIB, CODEC_ID_8SVX_FIB,
#endif #endif
CODEC_ID_BMV_AUDIO,
CODEC_ID_G729 = 0x15800, CODEC_ID_G729 = 0x15800,
CODEC_ID_G723_1= 0x15801, CODEC_ID_G723_1= 0x15801,
CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'), CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
......
This diff is collapsed.
...@@ -75,11 +75,12 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){ ...@@ -75,11 +75,12 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
for(i=0; i<128; i++){ for(i=0; i<128; i++){
int level= i-64; int level= i-64;
int run; int run;
if (!level)
continue;
for(run=0; run<64; run++){ for(run=0; run<64; run++){
int len, bits, code; int len, code;
int alevel= FFABS(level); int alevel= FFABS(level);
int sign= (level>>31)&1;
if (alevel > rl->max_level[0][run]) if (alevel > rl->max_level[0][run])
code= 111; /*rl->n*/ code= 111; /*rl->n*/
...@@ -87,25 +88,15 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){ ...@@ -87,25 +88,15 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
code= rl->index_run[0][run] + alevel - 1; code= rl->index_run[0][run] + alevel - 1;
if (code < 111 /* rl->n */) { if (code < 111 /* rl->n */) {
/* store the vlc & sign at once */ /* length of vlc and sign */
len= rl->table_vlc[code][1]+1; len= rl->table_vlc[code][1]+1;
bits= (rl->table_vlc[code][0]<<1) + sign;
} else { } else {
len= rl->table_vlc[111/*rl->n*/][1]+6; len= rl->table_vlc[111/*rl->n*/][1]+6;
bits= rl->table_vlc[111/*rl->n*/][0]<<6;
bits|= run;
if (alevel < 128) { if (alevel < 128) {
bits<<=8; len+=8; len += 8;
bits|= level & 0xff;
} else { } else {
bits<<=16; len+=16; len += 16;
bits|= level & 0xff;
if (level < 0) {
bits|= 0x8001 + level + 255;
} else {
bits|= level & 0xffff;
}
} }
} }
......
...@@ -266,7 +266,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) ...@@ -266,7 +266,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
for(i=0; i<NB_RL_TABLES; i++){ for(i=0; i<NB_RL_TABLES; i++){
int level; int level;
for(level=0; level<=MAX_LEVEL; level++){ for (level = 1; level <= MAX_LEVEL; level++) {
int run; int run;
for(run=0; run<=MAX_RUN; run++){ for(run=0; run<=MAX_RUN; run++){
int last; int last;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H #define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 28 #define LIBAVCODEC_VERSION_MINOR 29
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
...@@ -2402,9 +2402,9 @@ void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src, int32_t min ...@@ -2402,9 +2402,9 @@ void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src, int32_t min
int32_t max, unsigned int len); int32_t max, unsigned int len);
void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src, int32_t min, void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src, int32_t min,
int32_t max, unsigned int len); int32_t max, unsigned int len);
void ff_vector_clip_int32_sse2_int(int32_t *dst, const int32_t *src, int32_t min, void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src, int32_t min,
int32_t max, unsigned int len); int32_t max, unsigned int len);
void ff_vector_clip_int32_sse41 (int32_t *dst, const int32_t *src, int32_t min, void ff_vector_clip_int32_sse4 (int32_t *dst, const int32_t *src, int32_t min,
int32_t max, unsigned int len); int32_t max, unsigned int len);
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
...@@ -2858,7 +2858,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) ...@@ -2858,7 +2858,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->scalarproduct_int16 = ff_scalarproduct_int16_sse2; c->scalarproduct_int16 = ff_scalarproduct_int16_sse2;
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2; c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2;
if (mm_flags & AV_CPU_FLAG_ATOM) { if (mm_flags & AV_CPU_FLAG_ATOM) {
c->vector_clip_int32 = ff_vector_clip_int32_sse2_int; c->vector_clip_int32 = ff_vector_clip_int32_int_sse2;
} else { } else {
c->vector_clip_int32 = ff_vector_clip_int32_sse2; c->vector_clip_int32 = ff_vector_clip_int32_sse2;
} }
...@@ -2890,7 +2890,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) ...@@ -2890,7 +2890,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) { if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
#if HAVE_YASM #if HAVE_YASM
c->vector_clip_int32 = ff_vector_clip_int32_sse41; c->vector_clip_int32 = ff_vector_clip_int32_sse4;
#endif #endif
} }
......
...@@ -1055,9 +1055,14 @@ emu_edge mmx ...@@ -1055,9 +1055,14 @@ emu_edge mmx
; int32_t max, unsigned int len) ; int32_t max, unsigned int len)
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
%macro VECTOR_CLIP_INT32 4 ; %1 = number of xmm registers used
cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len ; %2 = number of inline load/process/store loops per asm loop
%ifidn %1, sse2 ; %3 = process 4*mmsize (%3=0) or 8*mmsize (%3=1) bytes per loop
; %4 = CLIPD function takes min/max as float instead of int (CLIPD_SSE2)
; %5 = suffix
%macro VECTOR_CLIP_INT32 4-5
cglobal vector_clip_int32%5, 5,5,%2, dst, src, min, max, len
%if %4
cvtsi2ss m4, minm cvtsi2ss m4, minm
cvtsi2ss m5, maxm cvtsi2ss m5, maxm
%else %else
...@@ -1068,12 +1073,12 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len ...@@ -1068,12 +1073,12 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len
SPLATD m5 SPLATD m5
.loop: .loop:
%assign %%i 1 %assign %%i 1
%rep %3 %rep %2
mova m0, [srcq+mmsize*0*%%i] mova m0, [srcq+mmsize*0*%%i]
mova m1, [srcq+mmsize*1*%%i] mova m1, [srcq+mmsize*1*%%i]
mova m2, [srcq+mmsize*2*%%i] mova m2, [srcq+mmsize*2*%%i]
mova m3, [srcq+mmsize*3*%%i] mova m3, [srcq+mmsize*3*%%i]
%if %4 %if %3
mova m7, [srcq+mmsize*4*%%i] mova m7, [srcq+mmsize*4*%%i]
mova m8, [srcq+mmsize*5*%%i] mova m8, [srcq+mmsize*5*%%i]
mova m9, [srcq+mmsize*6*%%i] mova m9, [srcq+mmsize*6*%%i]
...@@ -1083,7 +1088,7 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len ...@@ -1083,7 +1088,7 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len
CLIPD m1, m4, m5, m6 CLIPD m1, m4, m5, m6
CLIPD m2, m4, m5, m6 CLIPD m2, m4, m5, m6
CLIPD m3, m4, m5, m6 CLIPD m3, m4, m5, m6
%if %4 %if %3
CLIPD m7, m4, m5, m6 CLIPD m7, m4, m5, m6
CLIPD m8, m4, m5, m6 CLIPD m8, m4, m5, m6
CLIPD m9, m4, m5, m6 CLIPD m9, m4, m5, m6
...@@ -1093,7 +1098,7 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len ...@@ -1093,7 +1098,7 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len
mova [dstq+mmsize*1*%%i], m1 mova [dstq+mmsize*1*%%i], m1
mova [dstq+mmsize*2*%%i], m2 mova [dstq+mmsize*2*%%i], m2
mova [dstq+mmsize*3*%%i], m3 mova [dstq+mmsize*3*%%i], m3
%if %4 %if %3
mova [dstq+mmsize*4*%%i], m7 mova [dstq+mmsize*4*%%i], m7
mova [dstq+mmsize*5*%%i], m8 mova [dstq+mmsize*5*%%i], m8
mova [dstq+mmsize*6*%%i], m9 mova [dstq+mmsize*6*%%i], m9
...@@ -1101,25 +1106,26 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len ...@@ -1101,25 +1106,26 @@ cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len
%endif %endif
%assign %%i %%i+1 %assign %%i %%i+1
%endrep %endrep
add srcq, mmsize*4*(%3+%4) add srcq, mmsize*4*(%2+%3)
add dstq, mmsize*4*(%3+%4) add dstq, mmsize*4*(%2+%3)
sub lend, mmsize*(%3+%4) sub lend, mmsize*(%2+%3)
jg .loop jg .loop
REP_RET REP_RET
%endmacro %endmacro
INIT_MMX INIT_MMX mmx
%define SPLATD SPLATD_MMX %define SPLATD SPLATD_MMX
%define CLIPD CLIPD_MMX %define CLIPD CLIPD_MMX
VECTOR_CLIP_INT32 mmx, 0, 1, 0 VECTOR_CLIP_INT32 0, 1, 0, 0
INIT_XMM INIT_XMM sse2
%define SPLATD SPLATD_SSE2 %define SPLATD SPLATD_SSE2
VECTOR_CLIP_INT32 sse2_int, 6, 1, 0 VECTOR_CLIP_INT32 6, 1, 0, 0, _int
%define CLIPD CLIPD_SSE2 %define CLIPD CLIPD_SSE2
VECTOR_CLIP_INT32 sse2, 6, 2, 0 VECTOR_CLIP_INT32 6, 2, 0, 1
INIT_XMM sse4
%define CLIPD CLIPD_SSE41 %define CLIPD CLIPD_SSE41
%ifdef m8 %ifdef m8
VECTOR_CLIP_INT32 sse41, 11, 1, 1 VECTOR_CLIP_INT32 11, 1, 1, 0
%else %else
VECTOR_CLIP_INT32 sse41, 6, 1, 0 VECTOR_CLIP_INT32 6, 1, 0, 0
%endif %endif
...@@ -53,6 +53,7 @@ OBJS-$(CONFIG_BINK_DEMUXER) += bink.o ...@@ -53,6 +53,7 @@ OBJS-$(CONFIG_BINK_DEMUXER) += bink.o
OBJS-$(CONFIG_BINTEXT_DEMUXER) += bintext.o sauce.o OBJS-$(CONFIG_BINTEXT_DEMUXER) += bintext.o sauce.o
OBJS-$(CONFIG_BIT_DEMUXER) += bit.o OBJS-$(CONFIG_BIT_DEMUXER) += bit.o
OBJS-$(CONFIG_BIT_MUXER) += 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_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_DEMUXER) += cafdec.o caf.o mov.o riff.o isom.o
OBJS-$(CONFIG_CAF_MUXER) += cafenc.o caf.o riff.o isom.o OBJS-$(CONFIG_CAF_MUXER) += cafenc.o caf.o riff.o isom.o
......
...@@ -74,6 +74,7 @@ void av_register_all(void) ...@@ -74,6 +74,7 @@ void av_register_all(void)
REGISTER_DEMUXER (BINTEXT, bintext); REGISTER_DEMUXER (BINTEXT, bintext);
REGISTER_DEMUXER (BINK, bink); REGISTER_DEMUXER (BINK, bink);
REGISTER_MUXDEMUX (BIT, bit); REGISTER_MUXDEMUX (BIT, bit);
REGISTER_DEMUXER (BMV, bmv);
REGISTER_DEMUXER (C93, c93); REGISTER_DEMUXER (C93, c93);
REGISTER_MUXDEMUX (CAF, caf); REGISTER_MUXDEMUX (CAF, caf);
REGISTER_MUXDEMUX (CAVSVIDEO, cavsvideo); REGISTER_MUXDEMUX (CAVSVIDEO, cavsvideo);
......
...@@ -1860,8 +1860,8 @@ const AVClass *avformat_get_class(void); ...@@ -1860,8 +1860,8 @@ const AVClass *avformat_get_class(void);
* but recommended, since it avoids the overhead of implicitly * but recommended, since it avoids the overhead of implicitly
* doing the setup for each session. * doing the setup for each session.
* *
* Since the next major version bump, calling this function will become * Calling this function will become mandatory if using network
* mandatory if using network protocols. * protocols at some major version bump.
*/ */
int avformat_network_init(void); int avformat_network_init(void);
......
/*
* 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"
};
...@@ -317,9 +317,12 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) ...@@ -317,9 +317,12 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
currentpos = avio_tell(pb); currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0) if (seekhead->reserved_size > 0) {
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
return -1; currentpos = -1;
goto fail;
}
}
metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size); metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
for (i = 0; i < seekhead->num_entries; i++) { for (i = 0; i < seekhead->num_entries; i++) {
...@@ -343,6 +346,7 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) ...@@ -343,6 +346,7 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
currentpos = seekhead->filepos; currentpos = seekhead->filepos;
} }
fail:
av_free(seekhead->entries); av_free(seekhead->entries);
av_free(seekhead); av_free(seekhead);
......
...@@ -120,8 +120,15 @@ void ff_tls_deinit(void) ...@@ -120,8 +120,15 @@ void ff_tls_deinit(void)
avpriv_unlock_avformat(); avpriv_unlock_avformat();
} }
int ff_network_inited_globally;
int ff_network_init(void) 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 #if HAVE_WINSOCK2_H
WSADATA wsaData; WSADATA wsaData;
if (WSAStartup(MAKEWORD(1,1), &wsaData)) if (WSAStartup(MAKEWORD(1,1), &wsaData))
......
...@@ -56,6 +56,7 @@ int ff_neterrno(void); ...@@ -56,6 +56,7 @@ int ff_neterrno(void);
int ff_socket_nonblock(int socket, int enable); int ff_socket_nonblock(int socket, int enable);
extern int ff_network_inited_globally;
int ff_network_init(void); int ff_network_init(void);
void ff_network_close(void); void ff_network_close(void);
......
...@@ -524,7 +524,11 @@ rdt_new_context (void) ...@@ -524,7 +524,11 @@ rdt_new_context (void)
{ {
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext)); 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; return rdt;
} }
......
...@@ -975,4 +975,5 @@ AVInputFormat ff_rdt_demuxer = { ...@@ -975,4 +975,5 @@ AVInputFormat ff_rdt_demuxer = {
.long_name = NULL_IF_CONFIG_SMALL("RDT demuxer"), .long_name = NULL_IF_CONFIG_SMALL("RDT demuxer"),
.priv_data_size = sizeof(RMDemuxContext), .priv_data_size = sizeof(RMDemuxContext),
.read_close = rm_read_close, .read_close = rm_read_close,
.flags = AVFMT_NOFILE,
}; };
...@@ -172,8 +172,11 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler, ...@@ -172,8 +172,11 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
return; return;
codec->codec_id = handler->codec_id; codec->codec_id = handler->codec_id;
rtsp_st->dynamic_handler = handler; rtsp_st->dynamic_handler = handler;
if (handler->alloc) if (handler->alloc) {
rtsp_st->dynamic_protocol_context = 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>] */ /* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
......
...@@ -4188,6 +4188,7 @@ int avformat_network_init(void) ...@@ -4188,6 +4188,7 @@ int avformat_network_init(void)
{ {
#if CONFIG_NETWORK #if CONFIG_NETWORK
int ret; int ret;
ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0) if ((ret = ff_network_init()) < 0)
return ret; return ret;
ff_tls_init(); ff_tls_init();
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR 19 #define LIBAVFORMAT_VERSION_MINOR 20
#define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #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