libmpcdec  1.2.2
mpcdec.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2009, The Musepack Development Team
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  * Redistributions in binary form must reproduce the above
13  copyright notice, this list of conditions and the following
14  disclaimer in the documentation and/or other materials provided
15  with the distribution.
16 
17  * Neither the name of the The Musepack Development Team nor the
18  names of its contributors may be used to endorse or promote
19  products derived from this software without specific prior
20  written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
36 #ifndef _MPCDEC_H_
37 #define _MPCDEC_H_
38 #ifdef WIN32
39 #pragma once
40 #endif
41 
42 #include "reader.h"
43 #include "streaminfo.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 enum {
50  MPC_FRAME_LENGTH = (36 * 32),
52  MPC_DECODER_SYNTH_DELAY = 481
53 };
54 
55 typedef struct mpc_decoder_t mpc_decoder;
56 typedef struct mpc_demux_t mpc_demux;
57 
58 typedef struct mpc_bits_reader_t {
59  unsigned char * buff;
60  unsigned int count;
62 
63 typedef struct mpc_frame_info_t {
64  mpc_uint32_t samples;
65  mpc_int32_t bits;
66  MPC_SAMPLE_FORMAT * buffer;
67  mpc_bool_t is_key_frame;
69 
70 typedef struct mpc_chap_info_t {
71  mpc_uint64_t sample;
72  mpc_uint16_t gain;
73  mpc_uint16_t peak;
74  mpc_uint_t tag_size;
75  char * tag;
77 
81 MPC_API mpc_decoder * mpc_decoder_init(mpc_streaminfo *si);
82 
84 MPC_API void mpc_decoder_exit(mpc_decoder *p_dec);
85 
91 MPC_API void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor);
92 
93 MPC_API void mpc_decoder_decode_frame(mpc_decoder * d, mpc_bits_reader * r, mpc_frame_info * i);
94 
95 // This is the gain reference used in old replaygain
96 #define MPC_OLD_GAIN_REF 64.82
97 
103 MPC_API mpc_demux * mpc_demux_init(mpc_reader * p_reader);
105 MPC_API void mpc_demux_exit(mpc_demux * d);
115 MPC_API void mpc_set_replay_level(mpc_demux * d, float level, mpc_bool_t use_gain,
116  mpc_bool_t use_title, mpc_bool_t clip_prevention);
118 MPC_API mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i);
120 MPC_API void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i);
122 MPC_API mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample);
124 MPC_API mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds);
125 
127 MPC_API mpc_seek_t mpc_demux_pos(mpc_demux * d);
128 
130 
135 MPC_API mpc_int_t mpc_demux_chap_nb(mpc_demux * d);
143 MPC_API mpc_chap_info const * mpc_demux_chap(mpc_demux * d, int chap_nb);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 #endif
MPC_API mpc_demux * mpc_demux_init(mpc_reader *p_reader)
unsigned int count
pointer on current byte
Definition: mpcdec.h:60
MPC_API void mpc_set_replay_level(mpc_demux *d, float level, mpc_bool_t use_gain, mpc_bool_t use_title, mpc_bool_t clip_prevention)
MPC_API void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor)
char * tag
size of the tag element (0 if no tag is present for this chapter)
Definition: mpcdec.h:75
MPC_API mpc_status mpc_demux_seek_second(mpc_demux *d, double seconds)
seeks to a given second
mpc_bool_t is_key_frame
frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT))
Definition: mpcdec.h:67
MPC_API mpc_seek_t mpc_demux_pos(mpc_demux *d)
MPC_API mpc_status mpc_demux_seek_sample(mpc_demux *d, mpc_uint64_t destsample)
seeks to a given sample
mpc_uint16_t peak
replaygain chapter value
Definition: mpcdec.h:73
mpc_int32_t bits
number of samples in the frame (counting once for multiple channels)
Definition: mpcdec.h:65
MPC_API mpc_int_t mpc_demux_chap_nb(mpc_demux *d)
chapters : only for sv8 streams
mpc_uint16_t gain
sample where the chapter starts
Definition: mpcdec.h:72
MPC_API void mpc_demux_get_info(mpc_demux *d, mpc_streaminfo *i)
get streaminfo
MPC_API mpc_status mpc_demux_decode(mpc_demux *d, mpc_frame_info *i)
decode frame
MPC_SAMPLE_FORMAT * buffer
number of bits consumed by this frame (-1) if end of stream
Definition: mpcdec.h:66
mpc_uint_t tag_size
peak chapter loudness level
Definition: mpcdec.h:74
MPC_API mpc_decoder * mpc_decoder_init(mpc_streaminfo *si)
MPC_API mpc_chap_info const * mpc_demux_chap(mpc_demux *d, int chap_nb)
Samples per mpc frame.
Definition: mpcdec.h:50
MPC_API void mpc_decoder_exit(mpc_decoder *p_dec)
Releases input mpc decoder.
MPC_API void mpc_demux_exit(mpc_demux *d)
free demuxer
Required buffer size for decoder.
Definition: mpcdec.h:51
mpc stream properties structure
Definition: streaminfo.h:54