Mercurial > mplayer.hg
annotate libmpcodecs/ad_libvorbis.c @ 27305:b20d1786f838
No idea which vos support -noborder how well, though those based on
X11 or running on Windows _should_ work.
Just remove that line for now.
author | reimar |
---|---|
date | Tue, 22 Jul 2008 18:40:01 +0000 |
parents | 21ce55d8dde0 |
children | d47744b95b78 |
rev | line source |
---|---|
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
1 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
2 #include <stdio.h> |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
3 #include <stdlib.h> |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
4 #include <unistd.h> |
8220 | 5 #include <stdarg.h> |
6 #include <math.h> | |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
7 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
8 #include "config.h" |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
9 #include "ad_internal.h" |
26988
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
10 #include "libaf/reorder_ch.h" |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
11 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
12 static ad_info_t info = |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
13 { |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
14 "Ogg/Vorbis audio decoder", |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
15 "libvorbis", |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
16 "Felix Buenemann, A'rpi", |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
17 "libvorbis", |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
18 "" |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
19 }; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
20 |
7174 | 21 LIBAD_EXTERN(libvorbis) |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
22 |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
23 #ifdef TREMOR |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
24 #include <tremor/ivorbiscodec.h> |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
25 #else |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
26 #include <vorbis/codec.h> |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
27 #endif |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
28 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
29 // This struct is also defined in demux_ogg.c => common header ? |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
30 typedef struct ov_struct_st { |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
31 vorbis_info vi; /* struct that stores all the static vorbis bitstream |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
32 settings */ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
33 vorbis_comment vc; /* struct that stores all the bitstream user comments */ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
34 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
35 vorbis_block vb; /* local working space for packet->PCM decode */ |
8220 | 36 float rg_scale; /* replaygain scale */ |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
37 #ifdef TREMOR |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
38 int rg_scale_int; |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
39 #endif |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
40 } ov_struct_t; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
41 |
19104
2ec2301183cd
marks several read-only string parameters which aren't modified inside the called function as const. Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18879
diff
changeset
|
42 static int read_vorbis_comment( char* ptr, const char* comment, const char* format, ... ) { |
8220 | 43 va_list va; |
44 int clen, ret; | |
45 | |
46 va_start( va, format ); | |
47 clen = strlen( comment ); | |
48 ret = strncasecmp( ptr, comment, clen) == 0 ? vsscanf( ptr+clen, format, va ) : 0; | |
49 va_end( va ); | |
50 | |
51 return ret; | |
52 } | |
53 | |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
54 static int preinit(sh_audio_t *sh) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
55 { |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
56 sh->audio_out_minsize=1024*4; // 1024 samples/frame |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
57 return 1; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
58 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
59 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
60 static int init(sh_audio_t *sh) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
61 { |
17093
e13c1bce5ad5
ad_libvorbis.c:119: warning: assignment from incompatible pointer type
rathann
parents:
16183
diff
changeset
|
62 unsigned int offset, i, length, hsizes[3]; |
e13c1bce5ad5
ad_libvorbis.c:119: warning: assignment from incompatible pointer type
rathann
parents:
16183
diff
changeset
|
63 void *headers[3]; |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
64 unsigned char* extradata; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
65 ogg_packet op; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
66 vorbis_comment vc; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
67 struct ov_struct_st *ov; |
7071
acc51ad47911
- functions inside of functions are invalid in icc. replaced with #define's
arpi
parents:
6587
diff
changeset
|
68 #define ERROR() { \ |
acc51ad47911
- functions inside of functions are invalid in icc. replaced with #define's
arpi
parents:
6587
diff
changeset
|
69 vorbis_comment_clear(&vc); \ |
acc51ad47911
- functions inside of functions are invalid in icc. replaced with #define's
arpi
parents:
6587
diff
changeset
|
70 vorbis_info_clear(&ov->vi); \ |
acc51ad47911
- functions inside of functions are invalid in icc. replaced with #define's
arpi
parents:
6587
diff
changeset
|
71 free(ov); \ |
acc51ad47911
- functions inside of functions are invalid in icc. replaced with #define's
arpi
parents:
6587
diff
changeset
|
72 return 0; \ |
5775 | 73 } |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
74 |
15425
2071633f9bdc
initialize vorbis structure before calling ERROR()
nicodvb
parents:
15420
diff
changeset
|
75 /// Init the decoder with the 3 header packets |
18879 | 76 ov = malloc(sizeof(struct ov_struct_st)); |
15425
2071633f9bdc
initialize vorbis structure before calling ERROR()
nicodvb
parents:
15420
diff
changeset
|
77 vorbis_info_init(&ov->vi); |
2071633f9bdc
initialize vorbis structure before calling ERROR()
nicodvb
parents:
15420
diff
changeset
|
78 vorbis_comment_init(&vc); |
2071633f9bdc
initialize vorbis structure before calling ERROR()
nicodvb
parents:
15420
diff
changeset
|
79 |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
80 if(! sh->wf) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
81 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be absent! exit\n"); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
82 ERROR(); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
83 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
84 |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
85 if(! sh->wf->cbSize) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
86 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be absent!, exit\n"); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
87 ERROR(); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
88 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
89 |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
90 mp_msg(MSGT_DECAUDIO,MSGL_V,"ad_vorbis, extradata seems is %d bytes long\n", sh->wf->cbSize); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
91 extradata = (char*) (sh->wf+1); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
92 if(!extradata) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
93 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be NULL!, exit\n"); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
94 ERROR(); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
95 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
96 |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
97 if(*extradata != 2) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
98 mp_msg (MSGT_DEMUX, MSGL_WARN, "ad_vorbis: Vorbis track does not contain valid headers.\n"); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
99 ERROR(); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
100 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
101 |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
102 offset = 1; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
103 for (i=0; i < 2; i++) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
104 length = 0; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
105 while ((extradata[offset] == (unsigned char) 0xFF) && length < sh->wf->cbSize) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
106 length += 255; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
107 offset++; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
108 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
109 if(offset >= (sh->wf->cbSize - 1)) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
110 mp_msg (MSGT_DEMUX, MSGL_WARN, "ad_vorbis: Vorbis track does not contain valid headers.\n"); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
111 ERROR(); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
112 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
113 length += extradata[offset]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
114 offset++; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
115 mp_msg (MSGT_DEMUX, MSGL_V, "ad_vorbis, offset: %u, length: %u\n", offset, length); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
116 hsizes[i] = length; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
117 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
118 |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
119 headers[0] = &extradata[offset]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
120 headers[1] = &extradata[offset + hsizes[0]]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
121 headers[2] = &extradata[offset + hsizes[0] + hsizes[1]]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
122 hsizes[2] = sh->wf->cbSize - offset - hsizes[0] - hsizes[1]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
123 mp_msg (MSGT_DEMUX, MSGL_V, "ad_vorbis, header sizes: %d %d %d\n", hsizes[0], hsizes[1], hsizes[2]); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
124 |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
125 for(i=0; i<3; i++) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
126 op.bytes = hsizes[i]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
127 op.packet = headers[i]; |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
128 op.b_o_s = (i == 0); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
129 if(vorbis_synthesis_headerin(&ov->vi,&vc,&op) <0) { |
17366 | 130 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis: header n. %d broken! len=%ld\n", i, op.bytes); |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
131 ERROR(); |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
132 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
133 if(i == 2) { |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
134 float rg_gain=0.f, rg_peak=0.f; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
135 char **ptr=vc.user_comments; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
136 while(*ptr){ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
137 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbisComment: %s\n",*ptr); |
8220 | 138 /* replaygain */ |
139 read_vorbis_comment( *ptr, "replaygain_album_gain=", "%f", &rg_gain ); | |
140 read_vorbis_comment( *ptr, "rg_audiophile=", "%f", &rg_gain ); | |
141 if( !rg_gain ) { | |
142 read_vorbis_comment( *ptr, "replaygain_track_gain=", "%f", &rg_gain ); | |
143 read_vorbis_comment( *ptr, "rg_radio=", "%f", &rg_gain ); | |
144 } | |
145 read_vorbis_comment( *ptr, "replaygain_album_peak=", "%f", &rg_peak ); | |
146 if( !rg_peak ) { | |
147 read_vorbis_comment( *ptr, "replaygain_track_peak=", "%f", &rg_peak ); | |
148 read_vorbis_comment( *ptr, "rg_peak=", "%f", &rg_peak ); | |
149 } | |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
150 ++ptr; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
151 } |
8220 | 152 /* replaygain: scale */ |
153 if(!rg_gain) | |
154 ov->rg_scale = 1.f; /* just in case pow() isn't standard-conformant */ | |
155 else | |
156 ov->rg_scale = pow(10.f, rg_gain/20); | |
157 /* replaygain: anticlip */ | |
158 if(ov->rg_scale * rg_peak > 1.f) | |
159 ov->rg_scale = 1.f / rg_peak; | |
160 /* replaygain: security */ | |
161 if(ov->rg_scale > 15.) | |
162 ov->rg_scale = 15.; | |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
163 #ifdef TREMOR |
8946
9821db5b213f
1000l, this clips!! IMO rg_scale nonsense should be removed with
rfelker
parents:
8343
diff
changeset
|
164 ov->rg_scale_int = (int)(ov->rg_scale*64.f); |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
165 #endif |
8220 | 166 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Bitstream is %d channel%s, %dHz, %dbit/s %cBR\n",(int)ov->vi.channels,ov->vi.channels>1?"s":"",(int)ov->vi.rate,(int)ov->vi.bitrate_nominal, |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
167 (ov->vi.bitrate_lower!=ov->vi.bitrate_nominal)||(ov->vi.bitrate_upper!=ov->vi.bitrate_nominal)?'V':'C'); |
8220 | 168 if(rg_gain || rg_peak) |
169 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Gain = %+.2f dB, Peak = %.4f, Scale = %.2f\n", rg_gain, rg_peak, ov->rg_scale); | |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
170 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Encoded by: %s\n",vc.vendor); |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
171 } |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
172 } |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
14542
diff
changeset
|
173 |
5775 | 174 vorbis_comment_clear(&vc); |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
175 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
176 // printf("lower=%d upper=%d \n",(int)ov->vi.bitrate_lower,(int)ov->vi.bitrate_upper); |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
177 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
178 // Setup the decoder |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
179 sh->channels=ov->vi.channels; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
180 sh->samplerate=ov->vi.rate; |
13374
e94036364011
fix reimar's 10l...no actually imho it's arpi's 100l for writing the
rfelker
parents:
9169
diff
changeset
|
181 sh->samplesize=2; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
182 // assume 128kbit if bitrate not specified in the header |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
183 sh->i_bps=((ov->vi.bitrate_nominal>0) ? ov->vi.bitrate_nominal : 128000)/8; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
184 sh->context = ov; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
185 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
186 /// Finish the decoder init |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
187 vorbis_synthesis_init(&ov->vd,&ov->vi); |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
188 vorbis_block_init(&ov->vd,&ov->vb); |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
189 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Init OK!\n"); |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
190 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
191 return 1; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
192 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
193 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
194 static void uninit(sh_audio_t *sh) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
195 { |
5775 | 196 struct ov_struct_st *ov = sh->context; |
13641 | 197 vorbis_dsp_clear(&ov->vd); |
5775 | 198 vorbis_block_clear(&ov->vb); |
199 vorbis_info_clear(&ov->vi); | |
200 free(ov); | |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
201 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
202 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
203 static int control(sh_audio_t *sh,int cmd,void* arg, ...) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
204 { |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
205 switch(cmd) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
206 { |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
207 #if 0 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
208 case ADCTRL_RESYNC_STREAM: |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
209 return CONTROL_TRUE; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
210 case ADCTRL_SKIP_FRAME: |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
211 return CONTROL_TRUE; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
212 #endif |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
213 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
214 return CONTROL_UNKNOWN; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
215 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
216 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
217 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
218 { |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
219 int len = 0; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
220 int samples; |
16183 | 221 #ifdef TREMOR |
222 ogg_int32_t **pcm; | |
223 #else | |
23380
8ef36374e8c5
Move variable declaration into conditional to avoid an unused variable warning.
diego
parents:
19104
diff
changeset
|
224 float scale; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
225 float **pcm; |
16183 | 226 #endif |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
227 struct ov_struct_st *ov = sh->context; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
228 while(len < minlen) { |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
229 while((samples=vorbis_synthesis_pcmout(&ov->vd,&pcm))<=0){ |
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
230 ogg_packet op; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
231 double pts; |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
232 memset(&op,0,sizeof(op)); //op.b_o_s = op.e_o_s = 0; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
233 op.bytes = ds_get_packet_pts(sh->ds,&op.packet, &pts); |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
234 if(op.bytes<=0) break; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
235 if (pts != MP_NOPTS_VALUE) { |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
236 sh->pts = pts; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
237 sh->pts_bytes = 0; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
238 } |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
239 if(vorbis_synthesis(&ov->vb,&op)==0) /* test for success! */ |
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
240 vorbis_synthesis_blockin(&ov->vd,&ov->vb); |
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
241 } |
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
242 if(samples<=0) break; // error/EOF |
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
243 while(samples>0){ |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
244 int i,j; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
245 int clipflag=0; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
246 int convsize=(maxlen-len)/(2*ov->vi.channels); // max size! |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
247 int bout=((samples<convsize)?samples:convsize); |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
248 |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
249 if(bout<=0) break; // no buffer space |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
250 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
251 /* convert floats to 16 bit signed ints (host order) and |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
252 interleave */ |
8947
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
253 #ifdef TREMOR |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
254 if (ov->rg_scale_int == 64) { |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
255 for(i=0;i<ov->vi.channels;i++){ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
256 ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
257 ogg_int16_t *ptr=convbuffer+i; |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
258 ogg_int32_t *mono=pcm[i]; |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8220
diff
changeset
|
259 for(j=0;j<bout;j++){ |
8947
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
260 int val=mono[j]>>9; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
261 /* might as well guard against clipping */ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
262 if(val>32767){ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
263 val=32767; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
264 clipflag=1; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
265 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
266 if(val<-32768){ |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
267 val=-32768; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
268 clipflag=1; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
269 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
270 *ptr=val; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
271 ptr+=ov->vi.channels; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
272 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
273 } |
8947
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
274 } else |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
275 #endif /* TREMOR */ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
276 { |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
277 #ifndef TREMOR |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
278 scale = 32767.f * ov->rg_scale; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
279 #endif |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
280 for(i=0;i<ov->vi.channels;i++){ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
281 ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
282 ogg_int16_t *ptr=convbuffer+i; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
283 #ifdef TREMOR |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
284 ogg_int32_t *mono=pcm[i]; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
285 for(j=0;j<bout;j++){ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
286 int val=(mono[j]*ov->rg_scale_int)>>(9+6); |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
287 #else |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
288 float *mono=pcm[i]; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
289 for(j=0;j<bout;j++){ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
290 int val=mono[j]*scale; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
291 /* might as well guard against clipping */ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
292 if(val>32767){ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
293 val=32767; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
294 clipflag=1; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
295 } |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
296 if(val<-32768){ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
297 val=-32768; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
298 clipflag=1; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
299 } |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
300 #endif /* TREMOR */ |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
301 *ptr=val; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
302 ptr+=ov->vi.channels; |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
303 } |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
304 } |
1c8e98dba92f
don't waste time on rg_scale nonsense if not necessary.
rfelker
parents:
8946
diff
changeset
|
305 } |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
306 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
307 if(clipflag) |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
308 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"Clipping in frame %ld\n",(long)(ov->vd.sequence)); |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
309 len+=2*ov->vi.channels*bout; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
17366
diff
changeset
|
310 sh->pts_bytes += 2*ov->vi.channels*bout; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
311 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[decoded: %d / %d ]\n",bout,samples); |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
312 samples-=bout; |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
313 vorbis_synthesis_read(&ov->vd,bout); /* tell libvorbis how |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
314 many samples we |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
315 actually consumed */ |
9169
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
316 } //while(samples>0) |
f49a2bf04229
- fixed the input buffering (don't read input unless we're already processed
arpi
parents:
8947
diff
changeset
|
317 // if (!samples) break; // why? how? |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
318 } |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
319 |
26988
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
320 if (len > 0 && ov->vi.channels >= 5) { |
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
321 reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_VORBIS_DEFAULT, |
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
322 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, |
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
323 ov->vi.channels, len / sh->samplesize, |
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
324 sh->samplesize); |
21ce55d8dde0
Fix channel order for libvorbis decoder, original patched by Nicolas George.
ulion
parents:
23380
diff
changeset
|
325 } |
5427
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
326 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
327 |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
328 return len; |
0b5462a620fc
vorbis driver ported, and also fixed a bug, as nominal_bitrate can be -1
arpi
parents:
diff
changeset
|
329 } |