Mercurial > mplayer.hg
annotate libmpcodecs/ad_mpc.c @ 15984:3c9638eb3b64
cgop does work as long as scene change detection is disabled
author | ranma |
---|---|
date | Sat, 16 Jul 2005 22:44:08 +0000 |
parents | 4007949d98bc |
children | 7b8870739cc7 |
rev | line source |
---|---|
15958
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
1 /** |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
2 * Musepack audio files decoder for MPlayer |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
3 * by Reza Jelveh <reza.jelveh@tuhh.de> and |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
4 * Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de> |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
5 * License: GPL |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
6 */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
7 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
8 #include <stdio.h> |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
9 #include <stdlib.h> |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
10 #include <unistd.h> |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
11 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
12 #include "config.h" |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
13 #include "ad_internal.h" |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
14 #include "../libaf/af_format.h" |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
15 #include "../libvo/fastmemcpy.h" |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
16 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
17 static ad_info_t info = |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
18 { |
15960 | 19 "Musepack audio decoder", |
20 "mpcdec", | |
15958
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
21 "Reza Jelveh and Reimar Döffinger", |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
22 "", |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
23 "" |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
24 }; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
25 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
26 LIBAD_EXTERN(libmusepack) |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
27 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
28 #include <mpcdec/mpcdec.h> |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
29 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
30 #define MAX_FRAMESIZE MPC_DECODER_BUFFER_LENGTH |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
31 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
32 typedef struct context_s { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
33 char *header; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
34 int header_len; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
35 sh_audio_t *sh; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
36 uint32_t pos; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
37 mpc_decoder decoder; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
38 } context_t; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
39 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
40 /** |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
41 * \brief mpc_reader callback function for reading the header |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
42 */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
43 static mpc_int32_t cb_read(void *data, void *buf, mpc_int32_t size) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
44 context_t *d = (context_t *)data; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
45 char *p = (char *)buf; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
46 int s = size; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
47 if (d->pos < d->header_len) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
48 if (s > d->header_len - d->pos) |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
49 s = d->header_len - d->pos; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
50 memcpy(p, &d->header[d->pos], s); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
51 } else |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
52 s = 0; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
53 memset(&p[s], 0, size - s); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
54 d->pos += size; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
55 return size; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
56 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
57 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
58 /** |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
59 * \brief dummy mpc_reader callback function for seeking |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
60 */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
61 static mpc_bool_t cb_seek(void *data, mpc_int32_t offset ) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
62 context_t *d = (context_t *)data; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
63 d->pos = offset; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
64 return 1; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
65 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
66 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
67 /** |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
68 * \brief dummy mpc_reader callback function for getting stream position |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
69 */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
70 static mpc_int32_t cb_tell(void *data) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
71 context_t *d = (context_t *)data; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
72 return d->pos; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
73 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
74 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
75 /** |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
76 * \brief dummy mpc_reader callback function for getting stream length |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
77 */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
78 static mpc_int32_t cb_get_size(void *data) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
79 return 1 << 30; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
80 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
81 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
82 /** |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
83 * \brief mpc_reader callback function, we cannot seek. |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
84 */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
85 static mpc_bool_t cb_canseek(void *data) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
86 return 0; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
87 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
88 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
89 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
90 mpc_reader header_reader = { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
91 .read = cb_read, .seek = cb_seek, .tell = cb_tell, |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
92 .get_size = cb_get_size, .canseek = cb_canseek |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
93 }; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
94 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
95 static int preinit(sh_audio_t *sh) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
96 // sh->audio_out_minsize = 2 * MPC_DECODER_BUFFER_LENGTH; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
97 return 1; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
98 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
99 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
100 static void uninit(sh_audio_t *sh) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
101 if (sh->context) |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
102 free(sh->context); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
103 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
104 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
105 static int init(sh_audio_t *sh) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
106 mpc_streaminfo info; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
107 context_t *cd = malloc(sizeof(context_t)); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
108 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
109 if (!sh->wf || (sh->wf->cbSize < 6 * 4)) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
110 mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n"); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
111 return 0; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
112 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
113 cd->header = (char *)sh->wf; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
114 cd->header = &cd->header[sizeof(WAVEFORMATEX)]; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
115 cd->header_len = sh->wf->cbSize; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
116 cd->sh = sh; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
117 cd->pos = 0; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
118 sh->context = (char *)cd; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
119 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
120 /* read file's streaminfo data */ |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
121 mpc_streaminfo_init(&info); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
122 header_reader.data = cd; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
123 if (mpc_streaminfo_read(&info, &header_reader) != ERROR_CODE_OK) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
124 mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Not a valid musepack file.\n"); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
125 return 0; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
126 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
127 sh->i_bps = info.average_bitrate / 8; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
128 sh->channels = info.channels; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
129 sh->samplerate = info.sample_freq; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
130 sh->samplesize = 4; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
131 sh->sample_format = |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
132 #if MPC_SAMPLE_FORMAT == float |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
133 AF_FORMAT_FLOAT_NE; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
134 #elif MPC_SAMPLE_FORMAT == mpc_int32_t |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
135 AF_FORMAT_S32_NE; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
136 #else |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
137 #error musepack lib must use either float or mpc_int32_t sample format |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
138 #endif |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
139 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
140 mpc_decoder_setup(&cd->decoder, NULL); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
141 mpc_decoder_set_streaminfo(&cd->decoder, &info); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
142 return 1; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
143 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
144 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
145 // FIXME: minlen is currently ignored |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
146 static int decode_audio(sh_audio_t *sh, unsigned char *buf, |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
147 int minlen, int maxlen) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
148 int status, len; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
149 MPC_SAMPLE_FORMAT *sample_buffer = (MPC_SAMPLE_FORMAT *)buf; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
150 mpc_uint32_t *packet = NULL; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
151 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
152 context_t *cd = (context_t *) sh->context; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
153 if (maxlen < MPC_DECODER_BUFFER_LENGTH) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
154 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "maxlen too small in decode_audio\n"); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
155 return -1; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
156 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
157 len = ds_get_packet(sh->ds, (unsigned char **)&packet); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
158 if (len <= 0) return -1; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
159 status = mpc_decoder_decode_frame(&cd->decoder, packet, len, sample_buffer); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
160 if (status == -1) // decode error |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
161 mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Error decoding file.\n"); |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
162 if (status <= 0) // error or EOF |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
163 return -1; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
164 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
165 status = MPC_FRAME_LENGTH * sh->channels; // one sample per channel |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
166 #if MPC_SAMPLE_FORMAT == float || MPC_SAMPLE_FORMAT == mpc_int32_t |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
167 status *= 4; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
168 #else |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
169 // should not happen |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
170 status *= 2; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
171 #endif |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
172 return status; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
173 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
174 |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
175 static int control(sh_audio_t *sh, int cmd, void* arg, ...) { |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
176 return CONTROL_UNKNOWN; |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
177 } |
087142ef3a2d
musepack demuxing and decoding support (demuxing is v7 bitstream only).
reimar
parents:
diff
changeset
|
178 |