33#include <mpeghdec/mpeghdecoder.h>
44#define MAX_LOST_FRAMES 2
46#define PER_CHANNEL_OUTBUF_SIZE (3072 * (MAX_LOST_FRAMES + 1))
62 mpeghdecoder_destroy(
s->decoder);
106 s->decoder_buffer =
av_malloc_array(
s->decoder_buffer_size,
sizeof(*
s->decoder_buffer));
107 if (!
s->decoder_buffer)
111 s->decoder = mpeghdecoder_init(cicp);
112 if (
s->decoder ==
NULL) {
119 if (mpeghdecoder_setMhaConfig(
s->decoder, avctx->
extradata,
130 int *got_frame_ptr,
AVPacket *avpkt)
134 MPEGH_DECODER_ERROR err;
135 MPEGH_DECODER_OUTPUT_INFO out_info;
143 if ((err = mpeghdecoder_processTimescale(
s->decoder, avpkt->
data,
152 err = mpeghdecoder_flushAndGet(
s->decoder);
154 if (err != MPEGH_DEC_OK && err != MPEGH_DEC_FEED_DATA)
156 "mpeghdecoder_flushAndGet() failed: %d\n", err);
159 err = mpeghdecoder_getSamples(
s->decoder,
s->decoder_buffer,
160 s->decoder_buffer_size,
162 if (err == MPEGH_DEC_FEED_DATA) {
171 frame->nb_samples = out_info.numSamplesPerChannel;
173 frame->pts = out_info.ticks;
174 frame->time_base.num = 1;
175 frame->time_base.den = out_info.sampleRate;
180 memcpy(
frame->extended_data[0],
s->decoder_buffer,
182 sizeof(*
s->decoder_buffer) );
185 return ret = avpkt->
size;
190 MPEGH_DECODER_ERROR err;
193 err = mpeghdecoder_flush(
s->decoder);
195 if (err != MPEGH_DEC_OK && err != MPEGH_DEC_FEED_DATA)
200 .p.name =
"libmpeghdec",
212 .p.wrapper_name =
"libmpeghdec",
const FFCodec ff_libmpeghdec_decoder
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
reference-counted frame API
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_CODEC_ID_MPEGH_3D_AUDIO
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S32
signed 32 bits
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int mpegh3dadec_init(AVCodecContext *avctx)
static int mpegh3dadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
#define PER_CHANNEL_OUTBUF_SIZE
static av_cold int channel_layout_to_cicp(const AVChannelLayout *layout)
static av_cold void mpegh3dadec_flush(AVCodecContext *avctx)
static av_cold int mpegh3dadec_close(AVCodecContext *avctx)
#define MKTAG(a, b, c, d)
Memory handling functions.
mpeg audio layer common tables.
const uint64_t ff_mpa_cicp_channel_layout_masks[20]
const AVProfile ff_mpegh_3da_profiles[]
#define FF_ARRAY_ELEMS(a)
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
HANDLE_MPEGH_DECODER_CONTEXT decoder
int decoder_buffer_size
in samples
#define av_malloc_array(a, b)