1 /*
2 * Audio Interleaving functions
3 *
4 * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
28
30 {
31 int i;
35
38 }
39 }
40
42 const int *samples_per_frame,
44 {
45 int i;
46
47 if (!samples_per_frame)
49
53 }
57
64 }
68
72 }
73 }
74
75 return 0;
76 }
77
79 int stream_index,
int flush)
80 {
83 int ret;
86 return 0;
87
89 if (ret < 0)
90 return ret;
92
97
101
103 }
104
108 {
109 int i, ret;
110
111 if (pkt) {
120 }
122 } else {
123 // rewrite pts and dts to be decoded time line position
127 return ret;
128 }
130 }
131
138 return ret;
139 }
140 if (ret < 0)
141 return ret;
142 }
143 }
144
146 }
static void flush(AVCodecContext *avctx)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
const int * samples
current samples per frame, pointer to samples_per_frame
const int * samples_per_frame
must be 0-terminated
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int ff_audio_interleave_init(AVFormatContext *s, const int *samples_per_frame, AVRational time_base)
AVStream ** streams
A list of all streams in the file.
unsigned fifo_size
size of currently allocated FIFO
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush, int(*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int), int(*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
Rechunk audio PCM packets per AudioInterleaveContext->samples_per_frame and interleave them correctly...
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
enum AVMediaType codec_type
General type of the encoded data.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVRational time_base
time base of output audio packets
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
a very simple circular buffer FIFO implementation
Rational number (pair of numerator and denominator).
int sample_size
size of one sample all channels included
AVFifoBuffer * av_fifo_alloc_array(size_t nmemb, size_t size)
Initialize an AVFifoBuffer.
void ff_audio_interleave_close(AVFormatContext *s)
static int get_packet(URLContext *s, int for_header)
Interact with the server by receiving and sending RTMP packets until there is some significant data (...
static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...