33#include <mpeghdec/mpeghdecoder.h>
42#define MAX_LOST_FRAMES 2
44#define PER_CHANNEL_OUTBUF_SIZE (3072 * (MAX_LOST_FRAMES + 1))
60 mpeghdecoder_destroy(
s->decoder);
72#define CH_LAYOUT_7POINT2POINT3 AV_CH_LAYOUT_5POINT1POINT2 | AV_CH_SIDE_SURROUND_LEFT | \
73 AV_CH_SIDE_SURROUND_RIGHT | AV_CH_TOP_BACK_CENTER | \
75#define CH_LAYOUT_5POINT1POINT6 AV_CH_LAYOUT_5POINT1POINT4_BACK | \
76 AV_CH_TOP_FRONT_CENTER | AV_CH_TOP_CENTER
77#define CH_LAYOUT_7POINT1POINT6 AV_CH_LAYOUT_7POINT1POINT4_BACK | \
78 AV_CH_TOP_FRONT_CENTER | AV_CH_TOP_CENTER
79 static const uint64_t channel_layout_masks[] = {
93 if (channel_layout_masks[
i]) {
125 s->decoder_buffer =
av_malloc_array(
s->decoder_buffer_size,
sizeof(*
s->decoder_buffer));
126 if (!
s->decoder_buffer)
130 s->decoder = mpeghdecoder_init(cicp);
131 if (
s->decoder ==
NULL) {
137 if (mpeghdecoder_setMhaConfig(
s->decoder, avctx->
extradata,
148 int *got_frame_ptr,
AVPacket *avpkt)
152 MPEGH_DECODER_ERROR err;
153 MPEGH_DECODER_OUTPUT_INFO out_info;
161 if ((err = mpeghdecoder_processTimescale(
s->decoder, avpkt->
data,
170 err = mpeghdecoder_flushAndGet(
s->decoder);
172 if (err != MPEGH_DEC_OK && err != MPEGH_DEC_FEED_DATA)
174 "mpeghdecoder_flushAndGet() failed: %d\n", err);
177 err = mpeghdecoder_getSamples(
s->decoder,
s->decoder_buffer,
178 s->decoder_buffer_size,
180 if (err == MPEGH_DEC_FEED_DATA) {
189 frame->nb_samples = out_info.numSamplesPerChannel;
191 frame->pts = out_info.ticks;
192 frame->time_base.num = 1;
193 frame->time_base.den = out_info.sampleRate;
198 memcpy(
frame->extended_data[0],
s->decoder_buffer,
200 sizeof(*
s->decoder_buffer) );
203 return ret = avpkt->
size;
208 MPEGH_DECODER_ERROR err;
211 err = mpeghdecoder_flush(
s->decoder);
213 if (err != MPEGH_DEC_OK && err != MPEGH_DEC_FEED_DATA)
218 .p.name =
"libmpeghdec",
230 .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_CH_LAYOUT_6POINT1
#define AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_7POINT1POINT4_BACK
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_7POINT1_WIDE
#define AV_CH_LAYOUT_5POINT1POINT2
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_22POINT2
#define AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_5POINT1POINT4_BACK
#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.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
@ 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 CH_LAYOUT_7POINT2POINT3
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
#define CH_LAYOUT_5POINT1POINT6
#define CH_LAYOUT_7POINT1POINT6
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)
Memory handling functions.
#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
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)