22 #include <vo-amrwbenc/enc_if.h>
33 #define MAX_PACKET_SIZE (1 + (477 + 7) / 8)
55 static const int rates[] = { 6600, 8850, 12650, 14250, 15850, 18250,
56 19850, 23050, 23850 };
57 int i, best = -1, min_diff = 0;
60 for (i = 0; i < 9; i++) {
61 if (rates[i] == bitrate)
63 if (best < 0 || abs(rates[i] - bitrate) < min_diff) {
65 min_diff = abs(rates[i] - bitrate);
69 snprintf(log_buf,
sizeof(log_buf),
"bitrate not supported: use one of ");
70 for (i = 0; i < 9; i++)
71 av_strlcatf(log_buf,
sizeof(log_buf),
"%.2fk, ", rates[i] / 1000.f);
72 av_strlcatf(log_buf,
sizeof(log_buf),
"using %.2fk", rates[best] / 1000.f);
97 #if FF_API_OLD_ENCODE_AUDIO
103 s->
state = E_IF_init();
118 const AVFrame *frame,
int *got_packet_ptr)
121 const int16_t *
samples = (
const int16_t *)frame->
data[0];
148 .
name =
"libvo_amrwbenc",
158 "(Adaptive Multi-Rate Wide-Band)"),
159 .priv_class = &
class,
This structure describes decoded (raw) audio or video data.
memory handling functions
AVFrame * coded_frame
the picture in the bitstream
static int amr_wb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
#define AV_OPT_FLAG_AUDIO_PARAM
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
struct AMRWBContext AMRWBContext
int64_t pts
presentation timestamp in time_base units (time when frame should be shown to user) If AV_NOPTS_VALUE...
static const AVOption options[]
static int init(AVCodecParserContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
common internal API header
AVFrame * avcodec_alloc_frame(void)
Allocate an AVFrame and set its fields to default values.
static int get_wb_bitrate_mode(int bitrate, void *log_ctx)
int bit_rate
the average bitrate
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
#define AV_OPT_FLAG_ENCODING_PARAM
int frame_size
Number of samples per channel in an audio frame.
int sample_rate
samples per second
main external API structure.
static void close(AVCodecParserContext *s)
Describe the class of an AVClass context structure.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
AVSampleFormat
Audio Sample Formats.
static int amr_wb_encode_close(AVCodecContext *avctx)
static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
int channels
number of audio channels
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVCodec ff_libvo_amrwbenc_encoder
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)