annotate libmpcodecs/ad_dvdpcm.c @ 13567:8f75b26e847c

synced with 1.765
author paszczi
date Tue, 05 Oct 2004 20:35:34 +0000
parents 97a6f049c9f8
children f67d20c01332
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
1 #include <stdio.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
2 #include <stdlib.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
3 #include <unistd.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
4
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
5 #include "config.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
6 #include "ad_internal.h"
13236
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
7 #include "../libaf/af_format.h"
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
8
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
9 static ad_info_t info =
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
10 {
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
11 "Uncompressed DVD/VOB LPCM audio decoder",
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
12 "dvdpcm",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
13 "Nick Kurshev",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
14 "A'rpi",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
15 ""
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
16 };
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
17
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
18 LIBAD_EXTERN(dvdpcm)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
19
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
20 static int init(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
21 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
22 /* DVD PCM Audio:*/
7670
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
23 if(sh->codecdata_len==3){
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
24 // we have LPCM header:
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
25 unsigned char h=sh->codecdata[1];
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
26 sh->channels=1+(h&7);
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
27 switch((h>>4)&3){
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
28 case 0: sh->samplerate=48000;break;
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
29 case 1: sh->samplerate=96000;break;
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
30 case 2: sh->samplerate=44100;break;
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
31 case 3: sh->samplerate=32000;break;
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
32 }
13236
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
33 switch ((h >> 6) & 3) {
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
34 case 0:
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
35 sh->sample_format = AFMT_S16_BE;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
36 sh->samplesize = 2;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
37 break;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
38 case 2:
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
39 sh->sample_format = AFMT_AF_FLAGS | AF_FORMAT_I |
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
40 AF_FORMAT_BE | AF_FORMAT_US;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
41 sh->samplesize = 3;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
42 break;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
43 default:
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
44 sh->sample_format = AFMT_S16_BE;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
45 sh->samplesize = 2;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
46 }
7670
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
47 } else {
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
48 // use defaults:
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
49 sh->channels=2;
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
50 sh->samplerate=48000;
13236
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
51 sh->sample_format = AFMT_S16_BE;
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
52 sh->samplesize = 2;
7670
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
53 }
13236
97a6f049c9f8 first attempt to make 24-bit PCM DVDs work
reimar
parents: 7670
diff changeset
54 sh->i_bps = sh->samplesize * sh->channels * sh->samplerate;
7670
d388a7ee48c5 parse samplerate & channels from LPCM header
arpi
parents: 7191
diff changeset
55 return 1;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
56 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
57
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58 static int preinit(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
59 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
60 sh->audio_out_minsize=2048;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
61 return 1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
62 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
63
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
64 static void uninit(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
65 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
66 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
67
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
68 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
69 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
70 int skip;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
71 switch(cmd)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
72 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
73 case ADCTRL_SKIP_FRAME:
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
74 skip=sh->i_bps/16;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
75 skip=skip&(~3);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
76 demux_read_data(sh->ds,NULL,skip);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
77 return CONTROL_TRUE;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
78 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
79 return CONTROL_UNKNOWN;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
80 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
81
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
82 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
83 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
84 int j,len;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
85 len=demux_read_data(sh_audio->ds,buf,(minlen+3)&(~3));
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
86 return len;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
87 }