Go to the documentation of this file.
45 if (
ctx->par_in->ch_layout.nb_channels <= 0 ||
ctx->par_in->sample_rate <= 0)
49 s->sample_size =
ctx->par_in->ch_layout.nb_channels *
52 if (
s->frame_rate.num) {
55 min_samples =
s->nb_out_samples;
57 if (min_samples <= 0 || min_samples > INT_MAX /
s->sample_size - 1)
62 if (!
s->in_pkt || !
s->out_pkt)
103 if (
s->frame_rate.num) {
107 return s->nb_out_samples;
115 int data_size = nb_samples *
s->sample_size;
119 if (
s->in_pkt->size) {
120 if (
s->out_pkt->size ||
s->in_pkt->size < data_size) {
121 int drain =
FFMIN(
s->in_pkt->size, data_size -
s->out_pkt->size);
122 if (!
s->out_pkt->size) {
131 s->out_pkt->size = 0;
133 memcpy(
s->out_pkt->data +
s->out_pkt->size,
s->in_pkt->data, drain);
134 s->out_pkt->size += drain;
136 if (!
s->in_pkt->size)
138 if (
s->out_pkt->size == data_size) {
143 }
else if (
s->in_pkt->size > data_size) {
161 memset(
s->out_pkt->data +
s->out_pkt->size, 0, data_size -
s->out_pkt->size);
162 s->out_pkt->size = data_size;
164 nb_samples =
s->out_pkt->size /
s->sample_size;
176 #define OFFSET(x) offsetof(PCMContext, x)
177 #define FLAGS (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_BSF_PARAM)
179 {
"nb_out_samples",
"set the number of per-packet output samples",
OFFSET(nb_out_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX,
FLAGS },
180 {
"n",
"set the number of per-packet output samples",
OFFSET(nb_out_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX,
FLAGS },
215 .
p.
name =
"pcm_rechunk",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AVERROR_EOF
End of file.
static void uninit(AVBSFContext *ctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
The bitstream filter state.
static int rechunk_filter(AVBSFContext *ctx, AVPacket *pkt)
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
static void flush(AVBSFContext *ctx)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int init(AVBSFContext *ctx)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
AVCodecID
Identify the syntax and semantics of the bitstream.
AVBitStreamFilter p
The public AVBitStreamFilter.
static AVRational av_make_q(int num, int den)
Create an AVRational.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static const AVClass pcm_rechunk_class
@ AV_ROUND_DOWN
Round toward -infinity.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static enum AVCodecID codec_ids[]
const FFBitStreamFilter ff_pcm_rechunk_bsf
static int send_packet(PCMContext *s, int nb_samples, AVPacket *pkt)
static const AVOption options[]
This structure stores compressed data.
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
static int get_next_nb_samples(AVBSFContext *ctx)
void * priv_data
Format private data.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
static void drain_packet(AVPacket *pkt, int drain_data, int drain_samples)