summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-07 21:27:57 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-07 21:27:57 +0000
commite0ca9721bcf07175121316cc4c779d55c9a9d867 (patch)
tree19d12d5b208af359d7f430ff844fda54b87f468c
parent0b3bd9698d07ea2a105d432fef5dc649de4e1f0b (diff)
downloadmpv-e0ca9721bcf07175121316cc4c779d55c9a9d867.tar.bz2
mpv-e0ca9721bcf07175121316cc4c779d55c9a9d867.tar.xz
codecs.conf support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@304 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--DOCS/codecs.conf81
-rw-r--r--Makefile6
-rw-r--r--cfg-mplayer.h4
-rw-r--r--codec-cfg.c110
-rw-r--r--codec-cfg.h8
-rw-r--r--dec_audio.c140
-rw-r--r--dll_init.c15
-rw-r--r--libvo/vo_x11.c11
-rw-r--r--mplayer.c246
-rw-r--r--stheader.h10
10 files changed, 296 insertions, 335 deletions
diff --git a/DOCS/codecs.conf b/DOCS/codecs.conf
index 5defd8c576..93beaa281d 100644
--- a/DOCS/codecs.conf
+++ b/DOCS/codecs.conf
@@ -2,6 +2,12 @@
; It is not functional yet! until we finish config loader,
; mplayer will use codecs.c!!!
+videocodec mpeg12
+ info "MPEG 1 or 2"
+ format 0x1
+ driver libmpeg2
+ out YV12
+
videocodec mpeg4
info "Microsoft MPEG-4 v1/v2"
comment "No postprocessing"
@@ -9,48 +15,48 @@ videocodec mpeg4
fourcc MP42,mp42
driver vfw
dll "mpg4c32.dll"
- out YUY2 noflip,yuvhack
- out RGB32,RGB24,RGB15
+ out YUY2 yuvhack
+ out BGR32,BGR24,BGR15
-videocodec divx
+videocodec divxds
info "DivX ;-) (MS MPEG-4 v3)"
comment "DivX rulez ;-)"
fourcc MP43,mp43 div3 ; fourcc mapping to div3
fourcc DIV5,div5 div3
fourcc DIV6,div6 div4
fourcc DIV3,div3,DIV4,div3
- driver vfw
- dll "divxc32.dll"
- out YUY2 noflip,yuvhack
- out RGB32,RGB24,RGB15
-
-videocodec divxds
+ driver dshow
+ dll "divx_c32.ax"
+ guid 0x82CCd3E0, 0xF71A, 0x11D0, 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa
+ out YUY2
+ out BGR32,BGR24,BGR16,BGR15
+
+videocodec divx
info "DivX ;-) (MS MPEG-4 v3)"
comment "DivX rulez ;-)"
fourcc MP43,mp43 div3 ; fourcc mapping to div3
fourcc DIV5,div5 div3
fourcc DIV6,div6 div4
fourcc DIV3,div3,DIV4,div3
- driver dshow
- dll "divx_c32.ax"
- guid 0x82CCd3E0, 0xF71A, 0x11D0, 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa
- out YUY2 noflip
- out RGB32,RGB24,RGB16,RGB15 noflip
-
+ driver vfw
+ dll "divxc32.dll"
+ out YUY2 yuvhack
+ out BGR32,BGR24,BGR15
+
videocodec odivx
info "OpenDivX (MPEG-4 v2)"
fourcc DIVX,divx
fourcc DIV1,div1 divx
driver odivx
- out YV12 noflip
+ out YV12
videocodec indeo5
info "Intel Indeo 5"
fourcc IV50,iv50
driver vfw
dll "ir50_32.dll"
- out YUY2 noflip
- out RGB32,RGB24,RGB15 noflip
+ out YUY2
+ out BGR32,BGR24,BGR15
videocodec indeo4
info "Intel Indeo 4.1"
@@ -58,7 +64,7 @@ videocodec indeo4
fourcc IV41,iv41
driver vfw
dll "ir41_32.dll"
- out RGB24,RGB15 flip
+ out BGR24,BGR15 flip
videocodec indeo3
info "Intel Indeo 3.1/3.2"
@@ -67,30 +73,30 @@ videocodec indeo3
fourcc IV32,iv32
driver vfw
dll "ir32_32.dll"
- out RGB24,RGB15 flip
+ out BGR24,BGR15 flip
videocodec cvid
info "Cinepak Video"
fourcc cvid
driver vfw
dll "msvidc32.dll"
- out YUY2 noflip
- out RGB24,RGB15 noflip
+ out YUY2
+ out BGR24,BGR15
videocodec cram
info "CRAM"
fourcc cram,CRAM
driver vfw
dll "msvidc32.dll"
- out RGB24,RGB15 noflip
+ out BGR24,BGR15
videocodec vcr2
info "ATI VCR-2"
fourcc VCR2
driver vfw
dll "ativcr2.dll"
- out YUY2 noflip
- out RGB32,RGB24,RGB15 noflip
+ out YUY2
+ out BGR32,BGR24,BGR15
videocodec i263
info "I263"
@@ -98,7 +104,7 @@ videocodec i263
fourcc I263,i263
driver vfw
dll "i263_32.drv"
- out RGB32,RGB24,RGB15 noflip
+ out BGR32,BGR24,BGR15
videocodec mjpeg
info "Motion JPEG"
@@ -106,8 +112,8 @@ videocodec mjpeg
driver vfw
dll "mcmjpg32.dll"
; dll "m3jpeg32.dll"
- out YUY2 noflip
- out RGB32,RGB24,RGB15 noflip
+ out YUY2
+ out BGR32,BGR24,BGR15
videocodec wmv1
info "Windows Media Video 7"
@@ -115,8 +121,8 @@ videocodec wmv1
driver dshow
dll "wmvds32.ax"
guid 0x4facbba1, 0xffd8, 0x4cd7, 0x82, 0x28, 0x61, 0xe2, 0xf6, 0x5c, 0xb1, 0xae
- out YUY2 noflip
- out RGB32,RGB24,RGB16,RGB15 noflip
+ out YUY2
+ out BGR32,BGR24,BGR16,BGR15
audiocodec divx
info "DivX audio (WMA)"
@@ -166,6 +172,21 @@ audiocodec msgsm
format 0x32
driver msgsm
+audiocodec alaw
+ info "aLaw"
+ format 0x6
+ driver alaw
+
+audiocodec pcm
+ info "Uncompressed PCM"
+ format 0x1
+ driver pcm
+
+audiocodec ac3
+ info "AC3"
+ format 0x2000
+ driver libac3
+
audiocodec voxware
info "VoxWare"
format 0x75
diff --git a/Makefile b/Makefile
index f6c798dc8b..d7a31f1255 100644
--- a/Makefile
+++ b/Makefile
@@ -22,8 +22,8 @@ PRG_CFG = codec-cfg
prefix = /usr/local
BINDIR = ${prefix}/bin
# BINDIR = /usr/local/bin
-SRCS = subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c
-OBJS = subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o
+SRCS = codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c
+OBJS = codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o
CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo # -Wall
A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
VO_LIBS = -Llibvo -lvo $(X_LIBS)
@@ -77,7 +77,7 @@ $(PRG_TV): .depend tvision.o $(OBJS) $(COMMONLIBS)
$(CC) $(CFLAGS) -o $(PRG_TV) tvision.o $(OBJS) -lm $(TERMCAP_LIB) $(VO_LIBS)
$(PRG_CFG): codec-cfg.c codec-cfg.h
- $(CC) $(CFLAGS) codec-cfg.c -o $(PRG_CFG) -DTESTING
+ $(CC) $(CFLAGS) -g codec-cfg.c -o $(PRG_CFG) -DTESTING
install: $(PRG)
install -g $(GROUP) -o $(OWNER) -m $(PERM) -s $(PRG) $(BINDIR)
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 00c0809b42..b99ecc77ea 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -34,8 +34,8 @@ struct config conf[]={
{"noni", &force_ni, CONF_TYPE_FLAG, 0, 1, 0},
{"aid", &audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
{"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
- {"auds", &avi_header.audio_codec, CONF_TYPE_STRING, 0, 0, 0},
- {"vids", &avi_header.video_codec, CONF_TYPE_STRING, 0, 0, 0},
+// {"auds", &avi_header.audio_codec, CONF_TYPE_STRING, 0, 0, 0},
+// {"vids", &avi_header.video_codec, CONF_TYPE_STRING, 0, 0, 0},
{"mc", &default_max_pts_correction, CONF_TYPE_FLOAT, CONF_RANGE, 0, 10},
{"fps", &force_fps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0},
{"afm", &audio_format, CONF_TYPE_INT, CONF_RANGE, 1, 6},
diff --git a/codec-cfg.c b/codec-cfg.c
index 6e56589f02..88c5cd5351 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -1,3 +1,9 @@
+
+//#define DEBUG
+#define PRINT_LINENUM
+// printf("%s(%d): ", cfgfile, line_num)
+
+
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -28,16 +34,17 @@
#define RET_EOL -2
#define RET_OK 0
-FILE *fp;
-int line_num = 0;
-int line_pos; /* line pos */
-int firstdef = 1;
-char *line;
-char *token;
+static FILE *fp;
+static int line_num = 0;
+static int line_pos; /* line pos */
+static int firstdef = 1;
+static char *line;
+static char *token;
-int nr_codecs = 0;
+static codecs_t *codecs=NULL;
+static int nr_codecs = 0;
-int get_token(void)
+static int get_token(void)
{
static int read_nextline = 1;
@@ -88,7 +95,7 @@ ret_eol:
return RET_EOL;
}
-int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
+static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
unsigned int *map)
{
int i;
@@ -133,7 +140,7 @@ int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
return 1;
}
-int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
+static int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
{
// printf("\n-----[%s][%s]-----\n",s,format);
@@ -153,7 +160,7 @@ int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
}
-int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
+static int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
unsigned char *outflags)
{
static char *fmtstr[] = {
@@ -229,7 +236,7 @@ int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
return 1;
}
-short get_driver(char *s,int audioflag)
+static short get_driver(char *s,int audioflag)
{
static char *audiodrv[] = {
"mp3lib",
@@ -256,13 +263,11 @@ short get_driver(char *s,int audioflag)
return 0;
}
-//#define DEBUG
codecs_t *parse_codec_cfg(char *cfgfile)
{
-#define PRINT_LINENUM printf("%s(%d): ", cfgfile, line_num)
- codecs_t *codecs = NULL; // array of codecs
+// codecs_t *codecs = NULL; // array of codecs
codecs_t *codec = NULL; // currect codec
int free_slots = 0;
int tmp, i;
@@ -309,10 +314,10 @@ codecs_t *parse_codec_cfg(char *cfgfile)
state = 0;
if (*token == 'a') { /* audiocodec */
- printf("audio");
+ //printf("audio");
codec->flags |= CODECS_FLAG_AUDIO;
} else if (*token == 'v') { /* videocodec */
- printf("video");
+ //printf("video");
codec->flags &= !CODECS_FLAG_AUDIO;
} else {
printf("itt valami nagyon el van baszva\n");
@@ -322,28 +327,28 @@ codecs_t *parse_codec_cfg(char *cfgfile)
goto parse_error_out;
codec->name = strdup(token);
state |= GOT_NAME;
- printf(" %s\n", codec->name);
+ //printf(" %s\n", codec->name);
} else if (!strcmp(token, "info")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("info");
+ //printf("info");
if (state & GOT_INFO || get_token() < 0)
goto parse_error_out;
codec->info = strdup(token);
state |= GOT_INFO;
- printf(" %s\n", codec->info);
+ //printf(" %s\n", codec->info);
} else if (!strcmp(token, "comment")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("comment");
+ //printf("comment");
if (get_token() < 0)
goto parse_error_out;
#if 1
if (!codec->comment)
codec->comment = strdup(token);
- printf(" %s\n", codec->comment);
+ //printf(" %s\n", codec->comment);
#else
add_comment(token, &codec->comment);
printf(" FIXMEEEEEEEEEEEEEEE\n");
@@ -352,11 +357,11 @@ codecs_t *parse_codec_cfg(char *cfgfile)
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("fourcc");
- if (codec->flags & CODECS_FLAG_AUDIO) {
- printf("\n'fourcc' in audiocodec definition!\n");
- goto err_out;
- }
+ //printf("fourcc");
+// if (codec->flags & CODECS_FLAG_AUDIO) {
+// printf("\n'fourcc' in audiocodec definition!\n");
+// goto err_out;
+// }
if (get_token() < 0)
goto parse_error_out;
param1 = strdup(token);
@@ -366,49 +371,49 @@ codecs_t *parse_codec_cfg(char *cfgfile)
codec->fourccmap))
goto err_out;
state |= GOT_FOURCC;
- printf(" %s: %s\n", param1, token);
+ //printf(" %s: %s\n", param1, token);
free(param1);
} else if (!strcmp(token, "format")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("format");
- if (!(codec->flags & CODECS_FLAG_AUDIO)) {
- printf("\n'format' in videocodec definition!\n");
- goto err_out;
- }
+ //printf("format");
+// if (!(codec->flags & CODECS_FLAG_AUDIO)) {
+// printf("\n'format' in videocodec definition!\n");
+// goto err_out;
+// }
if (get_token() < 0)
goto parse_error_out;
if (!add_to_format(token, codec->fourcc,codec->fourccmap))
goto err_out;
state |= GOT_FORMAT;
- printf(" %s\n", token);
+ //printf(" %s\n", token);
} else if (!strcmp(token, "driver")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("driver");
+ //printf("driver");
if (get_token() < 0)
goto parse_error_out;
if ((codec->driver = get_driver(token,codec->flags&CODECS_FLAG_AUDIO)) == -1)
goto err_out;
- printf(" %s\n", token);
+ //printf(" %s\n", token);
} else if (!strcmp(token, "dll")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("dll");
+ //printf("dll");
if (get_token() < 0)
goto parse_error_out;
codec->dll = strdup(token);
- printf(" %s\n", codec->dll);
+ //printf(" %s\n", codec->dll);
} else if (!strcmp(token, "guid")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("guid");
+ //printf("guid");
if (get_token() < 0) goto parse_error_out;
- printf("'%s'",token);
+ //printf("'%s'",token);
codec->guid.f1=strtoul(token,NULL,0);
if (get_token() < 0) goto parse_error_out;
codec->guid.f2=strtoul(token,NULL,0);
@@ -422,7 +427,7 @@ codecs_t *parse_codec_cfg(char *cfgfile)
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("out");
+ //printf("out");
if (get_token() < 0)
goto parse_error_out;
param1 = strdup(token);
@@ -430,16 +435,16 @@ codecs_t *parse_codec_cfg(char *cfgfile)
if (!add_to_out(param1, token, codec->outfmt,
codec->outflags))
goto err_out;
- printf(" %s: %s\n", param1, token);
+ //printf(" %s: %s\n", param1, token);
free(param1);
} else if (!strcmp(token, "flags")) {
if (!(state & GOT_NAME))
goto parse_error_out;
PRINT_LINENUM;
- printf("flags");
+ //printf("flags");
if (get_token() < 0)
goto parse_error_out;
- printf(" %s\n", token);
+ //printf(" %s\n", token);
} else
goto parse_error_out;
}
@@ -461,6 +466,23 @@ eof_out:
goto out;
}
+codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,int audioflag){
+ int i,j;
+ for(i=0;i<nr_codecs;i++){
+ codecs_t *c=&codecs[i];
+ if(!audioflag && (c->flags&CODECS_FLAG_AUDIO)) continue;
+ if(audioflag && !(c->flags&CODECS_FLAG_AUDIO)) continue;
+ for(j=0;j<CODECS_MAX_FOURCC;j++){
+ if(c->fourcc[j]==fourcc){
+ if(fourccmap) *fourccmap=c->fourccmap[j];
+ return c;
+ }
+ }
+ }
+ return NULL;
+}
+
+
#ifdef TESTING
int main(void)
{
diff --git a/codec-cfg.h b/codec-cfg.h
index 6e983fbace..a596d63335 100644
--- a/codec-cfg.h
+++ b/codec-cfg.h
@@ -15,14 +15,17 @@
#define CODECS_MAX_FOURCC 16
#define CODECS_MAX_OUTFMT 16
+// Global flags:
#define CODECS_FLAG_AUDIO (1<<0)
+#define CODECS_FLAG_SEEKABLE (1<<1)
+// Outfmt flags:
#define CODECS_FLAG_FLIP (1<<0)
#define CODECS_FLAG_NOFLIP (1<<1)
#define CODECS_FLAG_YUVHACK (1<<2)
-#warning nem kellene ket typedef GUID-nak...
+//#warning nem kellene ket typedef GUID-nak...
typedef struct {
unsigned long f1;
unsigned short f2;
@@ -44,6 +47,7 @@ typedef struct {
unsigned char outflags[CODECS_MAX_OUTFMT];
} codecs_t;
-codecs_t *parse_codec_cfg(char *cfgfile);
+codecs_t* parse_codec_cfg(char *cfgfile);
+codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,int audioflag);
#endif
diff --git a/dec_audio.c b/dec_audio.c
index c5e369da5c..780ce0be1a 100644
--- a/dec_audio.c
+++ b/dec_audio.c
@@ -1,51 +1,16 @@
-// FIXME: use codec.conf struct here!!!
-int detect_audio_format(sh_audio_t *sh_audio){
- int has_audio=0;
-// Decide audio format:
- switch(sh_audio->wf.wFormatTag){
- case 0:
- has_audio=0;break; // disable/no audio
- case 6:
- avi_header.audio_seekable=1;
- has_audio=5;break; // aLaw
- case 0x31:
- case 0x32:
- has_audio=6;break; // MS-GSM
- case 0x50:
-#ifdef DEFAULT_MPG123
- case 0x55:
-#endif
- avi_header.audio_seekable=1;
- has_audio=1;break; // MPEG
- case 0x01:
- avi_header.audio_seekable=1;
- has_audio=2;break; // PCM
- case 0x2000:
- avi_header.audio_seekable=1;
- has_audio=3;break; // AC3
- default:
- avi_header.audio_seekable=0;
- has_audio=4; // Win32/ACM
- }
- if(has_audio==4){
- if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name(sh_audio);
- if(avi_header.auds_guid) has_audio=7; // force DShow
- if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
- if(verbose) printf("win32 audio codec: '%s'\n",avi_header.audio_codec);
- }
- if(verbose) printf("detected audio format: %d\n",has_audio);
- return has_audio;
-}
-
int init_audio(sh_audio_t *sh_audio){
-int has_audio=sh_audio->codec.driver;
+
+int driver=sh_audio->codec->driver;
sh_audio->samplesize=2;
+sh_audio->samplerate=0;
sh_audio->pcm_bswap=0;
+
sh_audio->a_buffer_size=16384; // default size, maybe not enough for Win32/ACM
+sh_audio->a_buffer=NULL;
-if(has_audio==4){
+if(driver==4){
// Win32 ACM audio codec:
if(init_acm_audio_codec(sh_audio)){
sh_audio->channels=sh_audio->o_wf.nChannels;
@@ -54,69 +19,50 @@ if(has_audio==4){
sh_audio->a_buffer_size=sh_audio->audio_out_minsize+OUTBURST;
} else {
printf("Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n");
- if((sh_audio->wf.wFormatTag)==0x55){
- printf("Audio format is MP3 -> fallback to internal mp3lib/mpg123\n");
- has_audio=1; // fallback to mp3lib
- } else
- has_audio=0; // nosound
+ driver=0;
}
}
-if(has_audio==7){
+if(driver==7){
#ifndef USE_DIRECTSHOW
printf("Compiled without DirectShow support -> force nosound :(\n");
- has_audio=0;
+ driver=0;
#else
// Win32 DShow audio codec:
- WAVEFORMATEX *in_fmt=&sh_audio->wf;
- sh_audio->o_wf.nChannels=in_fmt->nChannels;
- sh_audio->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
- sh_audio->o_wf.nAvgBytesPerSec=2*sh_audio->o_wf.nSamplesPerSec*sh_audio->o_wf.nChannels;
- sh_audio->o_wf.wFormatTag=WAVE_FORMAT_PCM;
- sh_audio->o_wf.nBlockAlign=2*in_fmt->nChannels;
- sh_audio->o_wf.wBitsPerSample=16;
- sh_audio->o_wf.cbSize=0;
-
- if(!DS_AudioDecoder_Open(avi_header.audio_codec,avi_header.auds_guid,in_fmt)){
- sh_audio->channels=sh_audio->o_wf.nChannels;
- sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec;
+ printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate);
- sh_audio->audio_in_minsize=2*sh_audio->o_wf.nBlockAlign;
+ if(DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,&sh_audio->wf)){
+ printf("ERROR: Could not load/initialize Win32/DirctShow AUDIO codec: %s\n",sh_audio->codec->dll);
+ driver=0;
+ } else {
+ sh_audio->channels=sh_audio->wf.nChannels;
+ sh_audio->samplerate=sh_audio->wf.nSamplesPerSec;
+ sh_audio->audio_in_minsize=2*sh_audio->wf.nBlockAlign;
if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize;
sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
sh_audio->a_in_buffer_len=0;
-
- } else {
- printf("ERROR: Could not load/initialize Win32/DirctShow AUDIO codec: %s\n",avi_header.audio_codec);
- if((in_fmt->wFormatTag)==0x55){
- printf("Audio format is MP3 -> fallback to internal mp3lib/mpg123\n");
- has_audio=1; // fallback to mp3lib
- } else
- printf("Audio disabled! Try to upgrade your w32codec.zip package!!!\n");
- has_audio=0; // nosound
}
#endif
}
+if(!driver) return 0;
// allocate audio out buffer:
sh_audio->a_buffer=malloc(sh_audio->a_buffer_size);
memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size);
sh_audio->a_buffer_len=0;
-if(has_audio==4){
+switch(driver){
+case 4: {
int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,sh_audio->a_buffer_size);
if(ret<0){
- printf("ACM error %d -> switching to nosound...\n",ret);
- has_audio=0;
- } else {
- sh_audio->a_buffer_len=ret;
- printf("ACM decoding test: %d bytes\n",ret);
+ printf("ACM decoding error: %d\n",ret);
+ driver=0;
}
+ break;
}
-
-if(has_audio==2){
+case 2: {
// if(file_format==DEMUXER_TYPE_AVI){ // FIXME!!!!!!!
// AVI PCM Audio:
WAVEFORMATEX *h=&sh_audio->wf;
@@ -129,8 +75,9 @@ if(has_audio==2){
// sh_audio->samplerate=48000;
// sh_audio->pcm_bswap=1;
// }
-} else
-if(has_audio==3){
+ break;
+}
+case 3: {
// Dolby AC3 audio:
ac3_config.fill_buffer_callback = ac3_fill_buffer;
ac3_config.num_output_ch = 2;
@@ -146,22 +93,26 @@ if(has_audio==3){
if(sh_audio->ac3_frame){
sh_audio->samplerate=sh_audio->ac3_frame->sampling_rate;
sh_audio->channels=2;
- } else has_audio=0; // bad frame -> disable audio
-} else
-if(has_audio==5){
+ } else {
+ driver=0; // bad frame -> disable audio
+ }
+ break;
+}
+case 5: {
// aLaw audio codec:
Gen_aLaw_2_Signed(); // init table
sh_audio->channels=sh_audio->wf.nChannels;
sh_audio->samplerate=sh_audio->wf.nSamplesPerSec;
-} else
-if(has_audio==6){
+ break;
+}
+case 6: {
// MS-GSM audio codec:
GSM_Init();
sh_audio->channels=sh_audio->wf.nChannels;
sh_audio->samplerate=sh_audio->wf.nSamplesPerSec;
+ break;
}
-// must be here for Win32->mp3lib fallbacks
-if(has_audio==1){
+case 1: {
// MPEG Audio:
MP3_Init();
MP3_samplerate=MP3_channels=0;
@@ -170,23 +121,30 @@ if(has_audio==1){
// printf("]\n");
sh_audio->channels=2; // hack
sh_audio->samplerate=MP3_samplerate;
+ break;
+}
}
if(!sh_audio->channels || !sh_audio->samplerate){
printf("Unknown/missing audio format, using nosound\n");
- has_audio=0;
+ driver=0;
}
- sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize;
+ if(!driver){
+ if(sh_audio->a_buffer) free(sh_audio->a_buffer);
+ sh_audio->o_bps=0;
+ return 0;
+ }
- return has_audio;
+ sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize;
+ return driver;
}
// Audio decoding
int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int maxlen){
int len=-1;
- switch(sh_audio->codec.driver){
+ switch(sh_audio->codec->driver){
case 1: // MPEG layer 2 or 3
len=MP3_DecodeFrame(buf,-1);
sh_audio->channels=2; // hack
diff --git a/dll_init.c b/dll_init.c
index 62f62f0eea..232cb41db0 100644
--- a/dll_init.c
+++ b/dll_init.c
@@ -21,7 +21,7 @@ int init_acm_audio_codec(sh_audio_t *sh_audio){
sh_audio->o_wf.wBitsPerSample=16;
sh_audio->o_wf.cbSize=0;
- win32_codec_name = avi_header.audio_codec;
+ win32_codec_name = sh_audio->codec->dll;
ret=acmStreamOpen(&sh_audio->srcstream,(HACMDRIVER)NULL,
in_fmt,&sh_audio->o_wf,
NULL,0,0,0);
@@ -100,15 +100,16 @@ int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int len){
-int init_video_codec(int outfmt){
+int init_video_codec(){
HRESULT ret;
+ unsigned int outfmt=sh_video->codec->outfmt[sh_video->outfmtidx];
if(verbose) printf("======= Win32 (VFW) VIDEO Codec init =======\n");
memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
sh_video->o_bih.biSize = sizeof(BITMAPINFOHEADER);
- win32_codec_name = avi_header.video_codec;
+ win32_codec_name = sh_video->codec->dll;
sh_video->hic = ICOpen( 0x63646976, sh_video->bih.biCompression, ICMODE_FASTDECOMPRESS);
// sh_video->hic = ICOpen( 0x63646976, sh_video->bih.biCompression, ICMODE_DECOMPRESS);
if(!sh_video->hic){
@@ -142,12 +143,14 @@ int init_video_codec(int outfmt){
else
sh_video->o_bih.biBitCount=outfmt&0xFF;// //24;
+ if(sh_video->o_bih.biBitCount==15) ++sh_video->o_bih.biBitCount;
+
sh_video->o_bih.biSizeImage=sh_video->o_bih.biWidth*sh_video->o_bih.biHeight*(sh_video->o_bih.biBitCount/8);
- if(!avi_header.flipped)
+ if(!(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_FLIP))
sh_video->o_bih.biHeight=-sh_video->bih.biHeight; // flip image!
- if(outfmt==IMGFMT_YUY2 && !avi_header.yuv_hack_needed)
+ if(outfmt==IMGFMT_YUY2 && !(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_YUVHACK))
sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
// sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
@@ -205,7 +208,7 @@ int init_video_codec(int outfmt){
return 0;
}
- if(outfmt==IMGFMT_YUY2 && avi_header.yuv_hack_needed)
+ if(outfmt==IMGFMT_YUY2 && (sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_YUVHACK))
sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
// avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!!
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index 1e6294a99f..49c5c61f44 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -514,11 +514,16 @@ static uint32_t draw_frame( uint8_t *src[] )
static uint32_t query_format( uint32_t format )
{
if( !vo_init() ) return 0; // Can't open X11
- if( ( format&IMGFMT_BGR_MASK )==IMGFMT_BGR && ( format&0xFF )==vo_depthonscreen ) return 1;
+ if( ( format&IMGFMT_BGR_MASK )==IMGFMT_BGR ){
+ int bpp=format&0xFF;
+ if( bpp==vo_depthonscreen ) return 1;
+ if( bpp==15 && vo_depthonscreen==16) return 1; // built-in conversion
+ if( bpp==24 && vo_depthonscreen==32) return 1; // built-in conversion
+ }
switch( format )
- {
+ {
case IMGFMT_YV12: return 1;
- }
+ }
return 0;
}
diff --git a/mplayer.c b/mplayer.c
index 92b45062a3..6fe21f7ec3 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -51,13 +51,7 @@
#include "loader.h"
#include "wine/avifmt.h"
-typedef struct
-{
- long f1;
- short f2;
- short f3;
- char f4[8];
-} GUID;
+#include "codec-cfg.h"
#ifdef USE_DIRECTSHOW
#include "DirectShow/DS_VideoDec.h"
@@ -186,18 +180,6 @@ typedef struct {
int idx_offset; // ennyit kell hozzaadni az index offset ertekekhez
// video:
unsigned int bitrate;
- //===== This stuff will be removed when codec.conf reader is finished! =====
- // video codec info: (filled by codecs.c)
- char *video_codec;
- char yuv_supported; // 1 if codec support YUY2 output format
- char yuv_hack_needed; // requires for divx & mpeg4
- char no_32bpp_support; // requires for INDEO 3.x, 4.x
- char flipped; // image is upside-down
- GUID* vids_guid;
- // audio codec info: (filled by codecs.c)
- char *audio_codec;
- int audio_seekable;
- GUID* auds_guid;
} avi_header_t;
avi_header_t avi_header;
@@ -239,8 +221,6 @@ static const int frameratecode2framerate[16] = {
60*10000, 0,0,0,0,0,0,0
};
-#include "codecs.c"
-
//**************************************************************************//
// Audio codecs:
//**************************************************************************//
@@ -409,7 +389,7 @@ int stream_type;
stream_t* stream=NULL;
int file_format=DEMUXER_TYPE_UNKNOWN;
int has_audio=1; // audio 0=no 1=mpeg 2=pcm 3=ac3 4=ACM 5=alaw 6=msgsm 7=DShow
-int has_video=0; // video 0=no 1=mpeg 2=win32/VfW 3=OpenDivX 4=w32/DShow
+int has_video=1; // video 0=no 1=mpeg 2=win32/VfW 3=OpenDivX 4=w32/DShow
//
int audio_format=0; // override
#ifdef ALSA_TIMER
@@ -551,6 +531,11 @@ if(!filename){
}
}
+// check codec.conf
+if(!parse_codec_cfg(get_path("codecs.conf"))){
+ printf("Warning! Couldn't load codecs.conf!");
+}
+
if(vcd_track){
//============ Open VideoCD track ==============
@@ -600,7 +585,6 @@ if(file_format==DEMUXER_TYPE_UNKNOWN){
if(asf_check_header()){
printf("Detected ASF file format!\n");
file_format=DEMUXER_TYPE_ASF;
-// printf("!!! ASF files not (yet) supported !!!\n");exit(1);
}
}
//=============== Try to open as MPEG-PS file: =================
@@ -698,7 +682,6 @@ switch(file_format){
} else {
if(force_ni || abs(a_pos-v_pos)>0x100000){ // distance > 1MB
printf("Detected NON-INTERLEAVED AVI file-format!\n");
-// file_format=DEMUXER_TYPE_AVI_NI; // HACK!!!!
demuxer->type=DEMUXER_TYPE_AVI_NI; // HACK!!!!
pts_from_bps=1; // force BPS sync!
}
@@ -707,7 +690,6 @@ switch(file_format){
// no index
if(force_ni){
printf("Using NON-INTERLEAVED Broken AVI file-format!\n");
-// file_format=DEMUXER_TYPE_AVI_NI; // HACK!!!!
demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!!
avi_header.idx_pos_a=
avi_header.idx_pos_v=avi_header.movi_start;
@@ -719,11 +701,7 @@ switch(file_format){
printf("AVI: missing video stream!? contact the author, it may be a bug :(\n");
exit(1);
}
- has_video=2;
- // Decide audio format:
- if(audio_format)
- has_audio=audio_format; // override type
- else if(has_audio) has_audio=detect_audio_format(sh_audio);
+ sh_video->format=sh_video->bih.biCompression;
if(has_audio){
if(verbose) printf("AVI: Searching for audio stream (id:%d)\n",d_audio->id);
if(!ds_fill_buffer(d_audio)){
@@ -731,6 +709,7 @@ switch(file_format){
has_audio=0;
}
}
+ if(has_audio) sh_audio->format=sh_audio->wf.wFormatTag;
default_fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
break;
}
@@ -740,26 +719,12 @@ switch(file_format){
stream_reset(demuxer->stream);
stream_seek(demuxer->stream,avi_header.movi_start);
avi_header.idx_pos=0;
-#if 0
- if(avi_header.idx_size>0){
- // decide index format:
- if(avi_header.idx[0].dwChunkOffset<avi_header.movi_start)
- avi_header.idx_offset=avi_header.movi_start-4;
- else
- avi_header.idx_offset=0;
- if(verbose) printf("ASF index offset: %d\n",avi_header.idx_offset);
- }
-#endif
demuxer->endpos=avi_header.movi_end;
if(!ds_fill_buffer(d_video)){
printf("ASF: missing video stream!? contact the author, it may be a bug :(\n");
exit(1);
}
- has_video=2;
- // Decide audio format:
- if(audio_format)
- has_audio=audio_format; // override type
- else if(has_audio) has_audio=detect_audio_format(sh_audio);
+ sh_video->format=sh_video->bih.biCompression;
if(has_audio){
if(verbose) printf("ASF: Searching for audio stream (id:%d)\n",d_audio->id);
if(!ds_fill_buffer(d_audio)){
@@ -767,13 +732,26 @@ switch(file_format){
has_audio=0;
}
}
+ if(has_audio) sh_audio->format=sh_audio->wf.wFormatTag;
break;
}
case DEMUXER_TYPE_MPEG_ES: {
- demuxer->audio->type=0;
- has_audio=0; // ES streams has no audio channel
- has_video=1; // mpeg video
- break;
+ demuxer->audio->type=0;
+ // Find sequence_header first:
+ if(verbose) printf("Searching for sequence header... ");fflush(stdout);
+ while(1){
+ int i=sync_video_packet(d_video);
+ if(i==0x1B3) break; // found it!
+ if(!i || !skip_video_packet(d_video)){
+ if(verbose) printf("NONE :(\n");
+ printf("MPEG: FATAL: EOF while searching for sequence header\n");
+ exit(1);
+ }
+ }
+ if(verbose) printf("OK!\n");
+ sh_video->format=1; // mpeg video
+ has_audio=0; // ES streams has no audio channel
+ break;
}
case DEMUXER_TYPE_MPEG_PS: {
if(has_audio)
@@ -781,10 +759,27 @@ switch(file_format){