35#include "config_components.h"
48 if (srate_hz != 8000 && srate_hz != 16000 && srate_hz != 24000 &&
49 srate_hz != 32000 && srate_hz != 48000 && srate_hz != 96000) {
52 "Invalid LC3 sample rate: %d Hz.\n", srate_hz);
56 if (frame_us != 2500 && frame_us != 5000 &&
57 frame_us != 7500 && frame_us != 10000) {
60 "Invalid LC3 frame duration: %.1f ms.\n", frame_us / 1000.f);
69typedef struct LC3DemuxContext {
76 int frame_us, srate_hz;
82 AV_RL16(
p->buf + 2) < 9 *
sizeof(uint16_t))
85 srate_hz =
AV_RL16(
p->buf + 4) * 100;
86 frame_us =
AV_RL16(
p->buf + 10) * 10;
95 LC3DemuxContext *lc3 =
s->priv_data;
97 uint16_t
tag, hdr_size;
99 int srate_hz, frame_us,
channels, bit_rate;
100 int ep_mode, hr_mode;
101 int num_extra_params;
107 if (
tag != 0x1ccc || hdr_size < 9 *
sizeof(uint16_t))
110 num_extra_params = hdr_size /
sizeof(uint16_t) - 9;
118 hr_mode = num_extra_params >= 1 &&
avio_rl16(
s->pb);
144 lc3->frame_samples =
av_rescale(frame_us, srate_hz, 1000*1000);
146 delay =
av_rescale(frame_us == 7500 ? 4000 : 2500, srate_hz, 1000*1000);
147 lc3->end_dts = length ? length + delay : -1;
154 LC3DemuxContext *lc3 =
s->priv_data;
167 remaining_samples = lc3->end_dts < 0 ? lc3->frame_samples :
169 pkt->duration =
FFMIN(lc3->frame_samples, remaining_samples);
177 .p.extensions =
"lc3",
179 .priv_data_size =
sizeof(LC3DemuxContext),
195 int frame_us, ep_mode, hr_mode;
210 avio_wl16(
s->pb, (9 + hr_mode) *
sizeof(uint16_t));
233 .p.extensions =
"lc3",
240 .write_header = lc3_write_header,
241 .write_packet = lc3_write_packet,
void avio_wl32(AVIOContext *s, unsigned int val)
void avio_wl16(AVIOContext *s, unsigned int val)
void avio_wb16(AVIOContext *s, unsigned int val)
unsigned int avio_rb16(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
unsigned int avio_rl16(AVIOContext *s)
unsigned int avio_rl32(AVIOContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
Update cur_dts of all streams based on the given timestamp and AVStream.
static int read_header(FFV1Context *f, RangeCoder *c)
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int check_frame_length(void *avcl, int srate_hz, int frame_us)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH
If this flag is set, it indicates that for each codec type whose corresponding default codec (i....
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int nb_channels
Number of channels in this layout.
int extradata_size
Size of the extradata content in bytes.
AVChannelLayout ch_layout
The channel layout and number of channels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static int frame_samples(const SyncQueue *sq, SyncQueueFrame frame)