Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-05-05 20:22:46 +0400
committerAnton Khirnov <anton@khirnov.net>2012-05-14 23:36:11 +0400
commit369cb092ecbbaff20bb0a2a1d60536c3bc04a8f0 (patch)
treec85f97db62bdaff958c535b8abf9e8bf2f6db5fb
parent9f26421b0be2af36b5405608f4e7429b4bd7fbdb (diff)
avconv: add support for audio filters.
The FATE changes are all off-by-one due to different rounding being used (lrintf vs av_rescale_q).
-rw-r--r--avconv.c806
-rw-r--r--doc/avconv.texi5
-rw-r--r--tests/ref/fate/adpcm-ima-amv20
-rw-r--r--tests/ref/fate/adpcm-ima-smjpeg16
-rw-r--r--tests/ref/fate/smjpeg16
5 files changed, 359 insertions, 504 deletions
diff --git a/avconv.c b/avconv.c
index fbe3827405..25958ea559 100644
--- a/avconv.c
+++ b/avconv.c
@@ -140,11 +140,6 @@ static float dts_delta_threshold = 10;
static int print_stats = 1;
-static uint8_t *audio_buf;
-static unsigned int allocated_audio_buf_size;
-static uint8_t *async_buf;
-static unsigned int allocated_async_buf_size;
-
#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
typedef struct InputFilter {
@@ -211,6 +206,11 @@ typedef struct InputStream {
int resample_width;
int resample_pix_fmt;
+ int resample_sample_fmt;
+ int resample_sample_rate;
+ int resample_channels;
+ uint64_t resample_channel_layout;
+
/* a pool of free buffers for decoded data */
FrameBuffer *buffer_pool;
@@ -249,7 +249,6 @@ typedef struct OutputStream {
AVBitStreamFilterContext *bitstream_filters;
AVCodec *enc;
int64_t max_frames;
- AVFrame *output_frame;
AVFrame *filtered_frame;
/* video only */
@@ -265,14 +264,6 @@ typedef struct OutputStream {
int forced_kf_count;
int forced_kf_index;
- /* audio only */
- int audio_resample;
- AVAudioResampleContext *avr;
- int resample_sample_fmt;
- int resample_channels;
- uint64_t resample_channel_layout;
- int resample_sample_rate;
- AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */
FILE *logfile;
OutputFilter *filter;
@@ -583,42 +574,150 @@ static void filter_release_buffer(AVFilterBuffer *fb)
unref_buffer(buf->ist, buf);
}
-static char *choose_pixel_fmts(OutputStream *ost)
+/**
+ * Define a function for building a string containing a list of
+ * allowed formats,
+ */
+#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name, separator) \
+static char *choose_ ## var ## s(OutputStream *ost) \
+{ \
+ if (ost->st->codec->var != none) { \
+ get_name(ost->st->codec->var); \
+ return av_strdup(name); \
+ } else if (ost->enc->supported_list) { \
+ const type *p; \
+ AVIOContext *s = NULL; \
+ uint8_t *ret; \
+ int len; \
+ \
+ if (avio_open_dyn_buf(&s) < 0) \
+ exit_program(1); \
+ \
+ for (p = ost->enc->supported_list; *p != none; p++) { \
+ get_name(*p); \
+ avio_printf(s, "%s" separator, name); \
+ } \
+ len = avio_close_dyn_buf(s, &ret); \
+ ret[len - 1] = 0; \
+ return ret; \
+ } else \
+ return NULL; \
+}
+
+#define GET_PIX_FMT_NAME(pix_fmt)\
+ const char *name = av_get_pix_fmt_name(pix_fmt);
+
+DEF_CHOOSE_FORMAT(enum PixelFormat, pix_fmt, pix_fmts, PIX_FMT_NONE,
+ GET_PIX_FMT_NAME, ":")
+
+#define GET_SAMPLE_FMT_NAME(sample_fmt)\
+ const char *name = av_get_sample_fmt_name(sample_fmt)
+
+DEF_CHOOSE_FORMAT(enum AVSampleFormat, sample_fmt, sample_fmts,
+ AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME, ",")
+
+#define GET_SAMPLE_RATE_NAME(rate)\
+ char name[16];\
+ snprintf(name, sizeof(name), "%d", rate);
+
+DEF_CHOOSE_FORMAT(int, sample_rate, supported_samplerates, 0,
+ GET_SAMPLE_RATE_NAME, ",")
+
+#define GET_CH_LAYOUT_NAME(ch_layout)\
+ char name[16];\
+ snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
+
+DEF_CHOOSE_FORMAT(uint64_t, channel_layout, channel_layouts, 0,
+ GET_CH_LAYOUT_NAME, ",")
+
+static int configure_audio_filters(FilterGraph *fg, AVFilterContext **in_filter,
+ AVFilterContext **out_filter)
{
- if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
- return av_strdup(av_get_pix_fmt_name(ost->st->codec->pix_fmt));
- } else if (ost->enc->pix_fmts) {
- const enum PixelFormat *p;
- AVIOContext *s = NULL;
- uint8_t *ret;
- int len;
-
- if (avio_open_dyn_buf(&s) < 0)
- exit_program(1);
+ InputStream *ist = fg->inputs[0]->ist;
+ OutputStream *ost = fg->outputs[0]->ost;
+ AVCodecContext *codec = ost->st->codec;
+ AVCodecContext *icodec = ist->st->codec;
+ char *sample_fmts, *sample_rates, *channel_layouts;
+ char args[256];
+ int ret;
+
+ avfilter_graph_free(&fg->graph);
+ if (!(fg->graph = avfilter_graph_alloc()))
+ return AVERROR(ENOMEM);
+
+ snprintf(args, sizeof(args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:"
+ "channel_layout=0x%"PRIx64, ist->st->time_base.num,
+ ist->st->time_base.den, icodec->sample_rate,
+ av_get_sample_fmt_name(icodec->sample_fmt), icodec->channel_layout);
+ ret = avfilter_graph_create_filter(&fg->inputs[0]->filter,
+ avfilter_get_by_name("abuffer"),
+ "src", args, NULL, fg->graph);
+ if (ret < 0)
+ return ret;
- for (p = ost->enc->pix_fmts; *p != PIX_FMT_NONE; p++)
- avio_printf(s, "%s:", av_get_pix_fmt_name(*p));
- len = avio_close_dyn_buf(s, &ret);
- ret[len - 1] = 0;
+ ret = avfilter_graph_create_filter(&fg->outputs[0]->filter,
+ avfilter_get_by_name("abuffersink"),
+ "out", NULL, NULL, fg->graph);
+ if (ret < 0)
return ret;
- } else
- return NULL;
+
+ *in_filter = fg->inputs[0]->filter;
+ *out_filter = fg->outputs[0]->filter;
+
+ if (codec->channels && !codec->channel_layout)
+ codec->channel_layout = av_get_default_channel_layout(codec->channels);
+
+ sample_fmts = choose_sample_fmts(ost);
+ sample_rates = choose_sample_rates(ost);
+ channel_layouts = choose_channel_layouts(ost);
+ if (sample_fmts || sample_rates || channel_layouts) {
+ AVFilterContext *format;
+ char args[256];
+ int len = 0;
+
+ if (sample_fmts)
+ len += snprintf(args + len, sizeof(args) - len, "sample_fmts=%s:",
+ sample_fmts);
+ if (sample_rates)
+ len += snprintf(args + len, sizeof(args) - len, "sample_rates=%s:",
+ sample_rates);
+ if (channel_layouts)
+ len += snprintf(args + len, sizeof(args) - len, "channel_layouts=%s:",
+ channel_layouts);
+ args[len - 1] = 0;
+
+ av_freep(&sample_fmts);
+ av_freep(&sample_rates);
+ av_freep(&channel_layouts);
+
+ ret = avfilter_graph_create_filter(&format,
+ avfilter_get_by_name("aformat"),
+ "aformat", args, NULL, fg->graph);
+ if (ret < 0)
+ return ret;
+
+ ret = avfilter_link(format, 0, fg->outputs[0]->filter, 0);
+ if (ret < 0)
+ return ret;
+
+ *out_filter = format;
+ }
+
+ return 0;
}
-static int configure_video_filters(FilterGraph *fg)
+static int configure_video_filters(FilterGraph *fg, AVFilterContext **in_filter,
+ AVFilterContext **out_filter)
{
InputStream *ist = fg->inputs[0]->ist;
OutputStream *ost = fg->outputs[0]->ost;
- AVFilterContext *in_filter, *out_filter, *filter;
+ AVFilterContext *filter;
AVCodecContext *codec = ost->st->codec;
char *pix_fmts;
AVRational sample_aspect_ratio;
char args[255];
int ret;
- avfilter_graph_free(&fg->graph);
- fg->graph = avfilter_graph_alloc();
-
if (ist->st->sample_aspect_ratio.num) {
sample_aspect_ratio = ist->st->sample_aspect_ratio;
} else
@@ -638,8 +737,8 @@ static int configure_video_filters(FilterGraph *fg)
"out", NULL, NULL, fg->graph);
if (ret < 0)
return ret;
- in_filter = fg->inputs[0]->filter;
- out_filter = fg->outputs[0]->filter;
+ *in_filter = fg->inputs[0]->filter;
+ *out_filter = fg->outputs[0]->filter;
if (codec->width || codec->height) {
snprintf(args, 255, "%d:%d:flags=0x%X",
@@ -649,27 +748,51 @@ static int configure_video_filters(FilterGraph *fg)
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
NULL, args, NULL, fg->graph)) < 0)
return ret;
- if ((ret = avfilter_link(in_filter, 0, filter, 0)) < 0)
+ if ((ret = avfilter_link(*in_filter, 0, filter, 0)) < 0)
return ret;
- in_filter = filter;
+ *in_filter = filter;
}
- if ((pix_fmts = choose_pixel_fmts(ost))) {
+ if ((pix_fmts = choose_pix_fmts(ost))) {
if ((ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", pix_fmts, NULL,
fg->graph)) < 0)
return ret;
- if ((ret = avfilter_link(filter, 0, out_filter, 0)) < 0)
+ if ((ret = avfilter_link(filter, 0, *out_filter, 0)) < 0)
return ret;
- out_filter = filter;
+ *out_filter = filter;
av_freep(&pix_fmts);
}
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
fg->graph->scale_sws_opts = av_strdup(args);
+ return 0;
+}
+
+static int configure_simple_filtergraph(FilterGraph *fg)
+{
+ OutputStream *ost = fg->outputs[0]->ost;
+ AVFilterContext *in_filter, *out_filter;
+ int ret;
+
+ avfilter_graph_free(&fg->graph);
+ fg->graph = avfilter_graph_alloc();
+
+ switch (ost->st->codec->codec_type) {
+ case AVMEDIA_TYPE_VIDEO:
+ ret = configure_video_filters(fg, &in_filter, &out_filter);
+ break;
+ case AVMEDIA_TYPE_AUDIO:
+ ret = configure_audio_filters(fg, &in_filter, &out_filter);
+ break;
+ default: av_assert0(0);
+ }
+ if (ret < 0)
+ return ret;
+
if (ost->avfilter) {
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
@@ -834,7 +957,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFil
pad_idx = 0;
}
- if ((pix_fmts = choose_pixel_fmts(ofilter->ost))) {
+ if ((pix_fmts = choose_pix_fmts(ofilter->ost))) {
AVFilterContext *filter;
if ((ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
@@ -931,7 +1054,8 @@ static int configure_complex_filters(void)
static int configure_filtergraph(FilterGraph *fg)
{
- return fg->graph_desc ? configure_complex_filter(fg) : configure_video_filters(fg);
+ return fg->graph_desc ? configure_complex_filter(fg) :
+ configure_simple_filtergraph(fg);
}
static int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
@@ -1009,13 +1133,6 @@ void exit_program(int ret)
}
output_streams[i]->bitstream_filters = NULL;
- if (output_streams[i]->output_frame) {
- AVFrame *frame = output_streams[i]->output_frame;
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
- av_freep(&frame);
- }
-
av_freep(&output_streams[i]->avfilter);
av_freep(&output_streams[i]->filtered_frame);
av_freep(&output_streams[i]);
@@ -1042,10 +1159,6 @@ void exit_program(int ret)
av_freep(&output_files);
uninit_opts();
- av_free(audio_buf);
- allocated_audio_buf_size = 0;
- av_free(async_buf);
- allocated_async_buf_size = 0;
avfilter_uninit();
avformat_network_deinit();
@@ -1085,25 +1198,6 @@ static void assert_codec_experimental(AVCodecContext *c, int encoder)
}
}
-static void choose_sample_fmt(AVStream *st, AVCodec *codec)
-{
- if (codec && codec->sample_fmts) {
- const enum AVSampleFormat *p = codec->sample_fmts;
- for (; *p != -1; p++) {
- if (*p == st->codec->sample_fmt)
- break;
- }
- if (*p == -1) {
- av_log(NULL, AV_LOG_WARNING,
- "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
- av_get_sample_fmt_name(st->codec->sample_fmt),
- codec->name,
- av_get_sample_fmt_name(codec->sample_fmts[0]));
- st->codec->sample_fmt = codec->sample_fmts[0];
- }
- }
-}
-
/**
* Update the requested input sample format based on the output sample format.
* This is currently only used to request float output from decoders which
@@ -1144,26 +1238,6 @@ static void update_sample_fmt(AVCodecContext *dec, AVCodec *dec_codec,
}
}
-static void choose_sample_rate(AVStream *st, AVCodec *codec)
-{
- if (codec && codec->supported_samplerates) {
- const int *p = codec->supported_samplerates;
- int best = 0;
- int best_dist = INT_MAX;
- for (; *p; p++) {
- int dist = abs(st->codec->sample_rate - *p);
- if (dist < best_dist) {
- best_dist = dist;
- best = *p;
- }
- }
- if (best_dist) {
- av_log(st->codec, AV_LOG_WARNING, "Requested sampling rate unsupported using closest supported (%d)\n", best);
- }
- st->codec->sample_rate = best;
- }
-}
-
static double
get_sync_ipts(const OutputStream *ost, int64_t pts)
{
@@ -1235,107 +1309,24 @@ static int check_recording_time(OutputStream *ost)
return 1;
}
-static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
-{
- char layout_name[256];
- AVCodecContext *enc = ost->st->codec;
- AVCodecContext *dec = ist->st->codec;
-
- if (dec->channel_layout &&
- av_get_channel_layout_nb_channels(dec->channel_layout) != dec->channels) {
- av_get_channel_layout_string(layout_name, sizeof(layout_name),
- dec->channels, dec->channel_layout);
- av_log(NULL, AV_LOG_ERROR, "New channel layout (%s) is invalid\n",
- layout_name);
- dec->channel_layout = 0;
- }
- if (!dec->channel_layout) {
- if (enc->channel_layout && dec->channels == enc->channels) {
- dec->channel_layout = enc->channel_layout;
- } else {
- dec->channel_layout = av_get_default_channel_layout(dec->channels);
-
- if (!dec->channel_layout) {
- av_log(NULL, AV_LOG_FATAL, "Unable to find default channel "
- "layout for Input Stream #%d.%d\n", ist->file_index,
- ist->st->index);
- exit_program(1);
- }
- }
- av_get_channel_layout_string(layout_name, sizeof(layout_name),
- dec->channels, dec->channel_layout);
- av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
- "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
- }
- if (!enc->channel_layout) {
- if (dec->channels == enc->channels) {
- enc->channel_layout = dec->channel_layout;
- return;
- } else {
- enc->channel_layout = av_get_default_channel_layout(enc->channels);
- }
- if (!enc->channel_layout) {
- av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout "
- "for Output Stream #%d.%d\n", ost->file_index,
- ost->st->index);
- exit_program(1);
- }
- av_get_channel_layout_string(layout_name, sizeof(layout_name),
- enc->channels, enc->channel_layout);
- av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream "
- "#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name);
- }
-}
-
-static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)
-{
- int fill_char = 0x00;
- if (sample_fmt == AV_SAMPLE_FMT_U8)
- fill_char = 0x80;
- memset(buf, fill_char, size);
-}
-
-static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,
- const uint8_t *buf, int buf_size)
+static void do_audio_out(AVFormatContext *s, OutputStream *ost,
+ AVFrame *frame)
{
AVCodecContext *enc = ost->st->codec;
- AVFrame *frame = NULL;
AVPacket pkt;
- int ret, got_packet;
+ int got_packet = 0;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
- if (buf) {
- if (!ost->output_frame) {
- ost->output_frame = avcodec_alloc_frame();
- if (!ost->output_frame) {
- av_log(NULL, AV_LOG_FATAL, "out-of-memory in encode_audio_frame()\n");
- exit_program(1);
- }
- }
- frame = ost->output_frame;
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
- avcodec_get_frame_defaults(frame);
-
- frame->nb_samples = buf_size /
- (enc->channels * av_get_bytes_per_sample(enc->sample_fmt));
- if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt,
- buf, buf_size, 1)) < 0) {
- av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
- exit_program(1);
- }
-
- if (!check_recording_time(ost))
- return 0;
+ if (!check_recording_time(ost))
+ return;
+ if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)
frame->pts = ost->sync_opts;
- ost->sync_opts += frame->nb_samples;
- }
+ ost->sync_opts = frame->pts + frame->nb_samples;
- got_packet = 0;
if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) {
av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
exit_program(1);
@@ -1353,207 +1344,6 @@ static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,
audio_size += pkt.size;
}
-
- return pkt.size;
-}
-
-static int alloc_audio_output_buf(AVCodecContext *dec, AVCodecContext *enc,
- int nb_samples, int *buf_linesize)
-{
- int64_t audio_buf_samples;
- int audio_buf_size;
-
- /* calculate required number of samples to allocate */
- audio_buf_samples = ((int64_t)nb_samples * enc->sample_rate + dec->sample_rate) /
- dec->sample_rate;
- audio_buf_samples = 4 * audio_buf_samples + 16; // safety factors for resampling
- audio_buf_samples = FFMAX(audio_buf_samples, enc->frame_size);
- if (audio_buf_samples > INT_MAX)
- return AVERROR(EINVAL);
-
- audio_buf_size = av_samples_get_buffer_size(buf_linesize, enc->channels,
- audio_buf_samples,
- enc->sample_fmt, 0);
- if (audio_buf_size < 0)
- return audio_buf_size;
-
- av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size);
- if (!audio_buf)
- return AVERROR(ENOMEM);
-
- return 0;
-}
-
-static void do_audio_out(AVFormatContext *s, OutputStream *ost,
- InputStream *ist, AVFrame *decoded_frame)
-{
- uint8_t *buftmp;
-
- int size_out, frame_bytes, resample_changed, ret;
- AVCodecContext *enc = ost->st->codec;
- AVCodecContext *dec = ist->st->codec;
- int osize = av_get_bytes_per_sample(enc->sample_fmt);
- int isize = av_get_bytes_per_sample(dec->sample_fmt);
- uint8_t *buf = decoded_frame->data[0];
- int size = decoded_frame->nb_samples * dec->channels * isize;
- int out_linesize = 0;
- int buf_linesize = decoded_frame->linesize[0];
-
- get_default_channel_layouts(ost, ist);
-
- if (alloc_audio_output_buf(dec, enc, decoded_frame->nb_samples, &out_linesize) < 0) {
- av_log(NULL, AV_LOG_FATAL, "Error allocating audio buffer\n");
- exit_program(1);
- }
-
- if (audio_sync_method > 1 ||
- enc->channels != dec->channels ||
- enc->channel_layout != dec->channel_layout ||
- enc->sample_rate != dec->sample_rate ||
- dec->sample_fmt != enc->sample_fmt)
- ost->audio_resample = 1;
-
- resample_changed = ost->resample_sample_fmt != dec->sample_fmt ||
- ost->resample_channels != dec->channels ||
- ost->resample_channel_layout != dec->channel_layout ||
- ost->resample_sample_rate != dec->sample_rate;
-
- if ((ost->audio_resample && !ost->avr) || resample_changed) {
- if (resample_changed) {
- av_log(NULL, AV_LOG_INFO, "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:0x%"PRIx64" to rate:%d fmt:%s ch:%d chl:0x%"PRIx64"\n",
- ist->file_index, ist->st->index,
- ost->resample_sample_rate, av_get_sample_fmt_name(ost->resample_sample_fmt),
- ost->resample_channels, ost->resample_channel_layout,
- dec->sample_rate, av_get_sample_fmt_name(dec->sample_fmt),
- dec->channels, dec->channel_layout);
- ost->resample_sample_fmt = dec->sample_fmt;
- ost->resample_channels = dec->channels;
- ost->resample_channel_layout = dec->channel_layout;
- ost->resample_sample_rate = dec->sample_rate;
- if (ost->avr)
- avresample_close(ost->avr);
- }
- /* if audio_sync_method is >1 the resampler is needed for audio drift compensation */
- if (audio_sync_method <= 1 &&
- ost->resample_sample_fmt == enc->sample_fmt &&
- ost->resample_channels == enc->channels &&
- ost->resample_channel_layout == enc->channel_layout &&
- ost->resample_sample_rate == enc->sample_rate) {
- ost->audio_resample = 0;
- } else if (ost->audio_resample) {
- if (!ost->avr) {
- ost->avr = avresample_alloc_context();
- if (!ost->avr) {
- av_log(NULL, AV_LOG_FATAL, "Error allocating context for libavresample\n");
- exit_program(1);
- }
- }
-
- av_opt_set_int(ost->avr, "in_channel_layout", dec->channel_layout, 0);
- av_opt_set_int(ost->avr, "in_sample_fmt", dec->sample_fmt, 0);
- av_opt_set_int(ost->avr, "in_sample_rate", dec->sample_rate, 0);
- av_opt_set_int(ost->avr, "out_channel_layout", enc->channel_layout, 0);
- av_opt_set_int(ost->avr, "out_sample_fmt", enc->sample_fmt, 0);
- av_opt_set_int(ost->avr, "out_sample_rate", enc->sample_rate, 0);
- if (audio_sync_method > 1)
- av_opt_set_int(ost->avr, "force_resampling", 1, 0);
-
- /* if both the input and output formats are s16 or u8, use s16 as
- the internal sample format */
- if (av_get_bytes_per_sample(dec->sample_fmt) <= 2 &&
- av_get_bytes_per_sample(enc->sample_fmt) <= 2) {
- av_opt_set_int(ost->avr, "internal_sample_fmt", AV_SAMPLE_FMT_S16P, 0);
- }
-
- ret = avresample_open(ost->avr);
- if (ret < 0) {
- av_log(NULL, AV_LOG_FATAL, "Error opening libavresample\n");
- exit_program(1);
- }
- }
- }
-
- if (audio_sync_method > 0) {
- double delta = get_sync_ipts(ost, ist->last_dts) * enc->sample_rate - ost->sync_opts -
- av_fifo_size(ost->fifo) / (enc->channels * osize);
- int idelta = delta * dec->sample_rate / enc->sample_rate;
- int byte_delta = idelta * isize * dec->channels;
-
- // FIXME resample delay
- if (fabs(delta) > 50) {
- if (ist->is_start || fabs(delta) > audio_drift_threshold*enc->sample_rate) {
- if (byte_delta < 0) {
- byte_delta = FFMAX(byte_delta, -size);
- size += byte_delta;
- buf -= byte_delta;
- av_log(NULL, AV_LOG_VERBOSE, "discarding %d audio samples\n",
- -byte_delta / (isize * dec->channels));
- if (!size)
- return;
- ist->is_start = 0;
- } else {
- av_fast_malloc(&async_buf, &allocated_async_buf_size,
- byte_delta + size);
- if (!async_buf) {
- av_log(NULL, AV_LOG_FATAL, "Out of memory in do_audio_out\n");
- exit_program(1);
- }
-
- if (alloc_audio_output_buf(dec, enc, decoded_frame->nb_samples + idelta, &out_linesize) < 0) {
- av_log(NULL, AV_LOG_FATAL, "Error allocating audio buffer\n");
- exit_program(1);
- }
- ist->is_start = 0;
-
- generate_silence(async_buf, dec->sample_fmt, byte_delta);
- memcpy(async_buf + byte_delta, buf, size);
- buf = async_buf;
- size += byte_delta;
- buf_linesize = allocated_async_buf_size;
- av_log(NULL, AV_LOG_VERBOSE, "adding %d audio samples of silence\n", idelta);
- }
- } else if (audio_sync_method > 1) {
- int comp = av_clip(delta, -audio_sync_method, audio_sync_method);
- av_log(NULL, AV_LOG_VERBOSE, "compensating audio timestamp drift:%f compensation:%d in:%d\n",
- delta, comp, enc->sample_rate);
-// fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2));
- avresample_set_compensation(ost->avr, comp, enc->sample_rate);
- }
- }
- } else if (audio_sync_method == 0)
- ost->sync_opts = lrintf(get_sync_ipts(ost, ist->last_dts) * enc->sample_rate) -
- av_fifo_size(ost->fifo) / (enc->channels * osize); // FIXME wrong
-
- if (ost->audio_resample) {
- buftmp = audio_buf;
- size_out = avresample_convert(ost->avr, (void **)&buftmp,
- allocated_audio_buf_size, out_linesize,
- (void **)&buf, buf_linesize,
- size / (dec->channels * isize));
- size_out = size_out * enc->channels * osize;
- } else {
- buftmp = buf;
- size_out = size;
- }
-
- /* now encode as many frames as possible */
- if (!(enc->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
- /* output resampled raw samples */
- if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
- av_log(NULL, AV_LOG_FATAL, "av_fifo_realloc2() failed\n");
- exit_program(1);
- }
- av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL);
-
- frame_bytes = enc->frame_size * osize * enc->channels;
-
- while (av_fifo_size(ost->fifo) >= frame_bytes) {
- av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
- encode_audio_frame(s, ost, audio_buf, frame_bytes);
- }
- } else {
- encode_audio_frame(s, ost, buftmp, size_out);
- }
}
static void pre_process_video_frame(InputStream *ist, AVPicture *picture, void **bufp)
@@ -1852,6 +1642,7 @@ static int poll_filters(void)
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
OutputFile *of = output_files[ost->file_index];
+ int ret = 0;
if (!ost->filter || ost->is_past_recording_time)
continue;
@@ -1862,11 +1653,29 @@ static int poll_filters(void)
avcodec_get_frame_defaults(ost->filtered_frame);
filtered_frame = ost->filtered_frame;
- while (av_buffersink_read(ost->filter->filter, &picref) >= 0) {
+ while (ret >= 0) {
+ if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
+ !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE))
+ ret = av_buffersink_read_samples(ost->filter->filter, &picref,
+ ost->st->codec->frame_size);
+ else
+ ret = av_buffersink_read(ost->filter->filter, &picref);
+
+ if (ret < 0)
+ break;
+
avfilter_copy_buf_props(filtered_frame, picref);
- filtered_frame->pts = av_rescale_q(picref->pts,
- ost->filter->filter->inputs[0]->time_base,
- AV_TIME_BASE_Q);
+ if (ost->enc->type == AVMEDIA_TYPE_VIDEO)
+ filtered_frame->pts = av_rescale_q(picref->pts,
+ ost->filter->filter->inputs[0]->time_base,
+ AV_TIME_BASE_Q);
+ else if (picref->pts != AV_NOPTS_VALUE)
+ filtered_frame->pts = av_rescale_q(picref->pts,
+ ost->filter->filter->inputs[0]->time_base,
+ ost->st->codec->time_base) -
+ av_rescale_q(of->start_time,
+ AV_TIME_BASE_Q,
+ ost->st->codec->time_base);
if (of->start_time && filtered_frame->pts < of->start_time)
return 0;
@@ -1882,8 +1691,11 @@ static int poll_filters(void)
if (vstats_filename && frame_size)
do_video_stats(of->ctx, ost, frame_size);
break;
+ case AVMEDIA_TYPE_AUDIO:
+ do_audio_out(of->ctx, ost, filtered_frame);
+ break;
default:
- // TODO support audio/subtitle filters
+ // TODO support subtitle filters
av_assert0(0);
}
@@ -2033,38 +1845,38 @@ static void flush_encoders(void)
continue;
for (;;) {
- AVPacket pkt;
- int fifo_bytes, got_packet;
- av_init_packet(&pkt);
- pkt.data = NULL;
- pkt.size = 0;
+ int (*encode)(AVCodecContext*, AVPacket*, const AVFrame*, int*) = NULL;
+ const char *desc;
+ int64_t *size;
switch (ost->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- fifo_bytes = av_fifo_size(ost->fifo);
- if (fifo_bytes > 0) {
- /* encode any samples remaining in fifo */
- int frame_bytes = fifo_bytes;
-
- av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL);
-
- encode_audio_frame(os, ost, audio_buf, frame_bytes);
- } else {
- /* flush encoder with NULL frames until it is done
- returning packets */
- if (encode_audio_frame(os, ost, NULL, 0) == 0) {
- stop_encoding = 1;
- break;
- }
- }
+ encode = avcodec_encode_audio2;
+ desc = "Audio";
+ size = &audio_size;
break;
case AVMEDIA_TYPE_VIDEO:
- ret = avcodec_encode_video2(enc, &pkt, NULL, &got_packet);
+ encode = avcodec_encode_video2;
+ desc = "Video";
+ size = &video_size;
+ break;
+ default:
+ stop_encoding = 1;
+ }
+
+ if (encode) {
+ AVPacket pkt;
+ int got_packet;
+ av_init_packet(&pkt);
+ pkt.data = NULL;
+ pkt.size = 0;
+
+ ret = encode(enc, &pkt, NULL, &got_packet);
if (ret < 0) {
- av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
+ av_log(NULL, AV_LOG_FATAL, "%s encoding failed\n", desc);
exit_program(1);
}
- video_size += ret;
+ *size += ret;
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
@@ -2077,10 +1889,8 @@ static void flush_encoders(void)
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
write_frame(os, &pkt, ost);
- break;
- default:
- stop_encoding = 1;
}
+
if (stop_encoding)
break;
}
@@ -2172,12 +1982,30 @@ static void rate_emu_sleep(InputStream *ist)
}
}
+static int guess_input_channel_layout(InputStream *ist)
+{
+ AVCodecContext *dec = ist->st->codec;
+
+ if (!dec->channel_layout) {
+ char layout_name[256];
+
+ dec->channel_layout = av_get_default_channel_layout(dec->channels);
+ if (!dec->channel_layout)
+ return 0;
+ av_get_channel_layout_string(layout_name, sizeof(layout_name),
+ dec->channels, dec->channel_layout);
+ av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
+ "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
+ }
+ return 1;
+}
+
static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
{
AVFrame *decoded_frame;
AVCodecContext *avctx = ist->st->codec;
int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);
- int i, ret;
+ int i, ret, resample_changed;
if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame()))
return AVERROR(ENOMEM);
@@ -2192,6 +2020,9 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
if (!*got_output) {
/* no audio frame */
+ if (!pkt->size)
+ for (i = 0; i < ist->nb_filters; i++)
+ av_buffersrc_buffer(ist->filters[i]->filter, NULL);
return ret;
}
@@ -2199,11 +2030,10 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
the decoder could be delaying output by a packet or more. */
if (decoded_frame->pts != AV_NOPTS_VALUE)
ist->next_dts = decoded_frame->pts;
-
- /* increment next_dts to use for the case where the input stream does not
- have timestamps or there are multiple frames in the packet */
- ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) /
- avctx->sample_rate;
+ else if (pkt->pts != AV_NOPTS_VALUE) {
+ decoded_frame->pts = pkt->pts;
+ pkt->pts = AV_NOPTS_VALUE;
+ }
// preprocess audio (volume)
if (audio_volume != 256) {
@@ -2265,14 +2095,50 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
rate_emu_sleep(ist);
- for (i = 0; i < nb_output_streams; i++) {
- OutputStream *ost = output_streams[i];
+ resample_changed = ist->resample_sample_fmt != decoded_frame->format ||
+ ist->resample_channels != avctx->channels ||
+ ist->resample_channel_layout != decoded_frame->channel_layout ||
+ ist->resample_sample_rate != decoded_frame->sample_rate;
+ if (resample_changed) {
+ char layout1[64], layout2[64];
- if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
- continue;
- do_audio_out(output_files[ost->file_index]->ctx, ost, ist, decoded_frame);
+ if (!guess_input_channel_layout(ist)) {
+ av_log(NULL, AV_LOG_FATAL, "Unable to find default channel "
+ "layout for Input Stream #%d.%d\n", ist->file_index,
+ ist->st->index);
+ exit_program(1);
+ }
+ decoded_frame->channel_layout = avctx->channel_layout;
+
+ av_get_channel_layout_string(layout1, sizeof(layout1), ist->resample_channels,
+ ist->resample_channel_layout);
+ av_get_channel_layout_string(layout2, sizeof(layout2), avctx->channels,
+ decoded_frame->channel_layout);
+
+ av_log(NULL, AV_LOG_INFO,
+ "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:%s to rate:%d fmt:%s ch:%d chl:%s\n",
+ ist->file_index, ist->st->index,
+ ist->resample_sample_rate, av_get_sample_fmt_name(ist->resample_sample_fmt),
+ ist->resample_channels, layout1,
+ decoded_frame->sample_rate, av_get_sample_fmt_name(decoded_frame->format),
+ avctx->channels, layout2);
+
+ ist->resample_sample_fmt = decoded_frame->format;
+ ist->resample_sample_rate = decoded_frame->sample_rate;
+ ist->resample_channel_layout = decoded_frame->channel_layout;
+ ist->resample_channels = avctx->channels;
+
+ for (i = 0; i < nb_filtergraphs; i++)
+ if (ist_in_filtergraph(filtergraphs[i], ist) &&
+ configure_filtergraph(filtergraphs[i]) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n");
+ exit_program(1);
+ }
}
+ for (i = 0; i < ist->nb_filters; i++)
+ av_buffersrc_write_frame(ist->filters[i]->filter, decoded_frame);
+
return ret;
}
@@ -2550,17 +2416,6 @@ static int init_input_stream(int ist_index, char *error, int error_len)
}
assert_codec_experimental(ist->st->codec, 0);
assert_avoptions(ist->opts);
-
- if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- for (i = 0; i < nb_output_streams; i++) {
- OutputStream *ost = output_streams[i];
- if (ost->source_index == ist_index) {
- if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout)
- get_default_channel_layouts(ost, ist);
- break;
- }
- }
- }
}
ist->last_dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
@@ -2732,45 +2587,26 @@ static int transcode_init(void)
ist->decoding_needed = 1;
ost->encoding_needed = 1;
- switch (codec->codec_type) {
- case AVMEDIA_TYPE_AUDIO:
- ost->fifo = av_fifo_alloc(1024);
- if (!ost->fifo) {
- return AVERROR(ENOMEM);
- }
-
- if (!codec->sample_rate)
- codec->sample_rate = icodec->sample_rate;
- choose_sample_rate(ost->st, ost->enc);
- codec->time_base = (AVRational){ 1, codec->sample_rate };
-
- if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
- codec->sample_fmt = icodec->sample_fmt;
- choose_sample_fmt(ost->st, ost->enc);
-
- if (!codec->channels)
- codec->channels = icodec->channels;
- if (!codec->channel_layout)
- codec->channel_layout = icodec->channel_layout;
- if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
- codec->channel_layout = 0;
-
- icodec->request_channels = codec-> channels;
- ost->resample_sample_fmt = icodec->sample_fmt;
- ost->resample_sample_rate = icodec->sample_rate;
- ost->resample_channels = icodec->channels;
- ost->resample_channel_layout = icodec->channel_layout;
- break;
- case AVMEDIA_TYPE_VIDEO:
- if (!ost->filter) {
+ if (!ost->filter &&
+ (codec->codec_type == AVMEDIA_TYPE_VIDEO ||
+ codec->codec_type == AVMEDIA_TYPE_AUDIO)) {
FilterGraph *fg;
fg = init_simple_filtergraph(ist, ost);
- if (configure_video_filters(fg)) {
+ if (configure_simple_filtergraph(fg)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit(1);
}
- }
+ }
+ switch (codec->codec_type) {
+ case AVMEDIA_TYPE_AUDIO:
+ codec->sample_fmt = ost->filter->filter->inputs[0]->format;
+ codec->sample_rate = ost->filter->filter->inputs[0]->sample_rate;
+ codec->channel_layout = ost->filter->filter->inputs[0]->channel_layout;
+ codec->channels = av_get_channel_layout_nb_channels(codec->channel_layout);
+ codec->time_base = (AVRational){ 1, codec->sample_rate };
+ break;
+ case AVMEDIA_TYPE_VIDEO:
/*
* We want CFR output if and only if one of those is true:
* 1) user specified output framerate with -r
@@ -3227,12 +3063,8 @@ static int transcode(void)
fclose(ost->logfile);
ost->logfile = NULL;
}
- av_fifo_free(ost->fifo); /* works even if fifo is not
- initialized but set to zero */
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->forced_kf_pts);
- if (ost->avr)
- avresample_free(&ost->avr);
av_dict_free(&ost->opts);
}
}
@@ -3564,6 +3396,14 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
break;
case AVMEDIA_TYPE_AUDIO:
+ guess_input_channel_layout(ist);
+
+ ist->resample_sample_fmt = dec->sample_fmt;
+ ist->resample_sample_rate = dec->sample_rate;
+ ist->resample_channels = dec->channels;
+ ist->resample_channel_layout = dec->channel_layout;
+
+ break;
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_SUBTITLE:
case AVMEDIA_TYPE_ATTACHMENT:
@@ -4095,7 +3935,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc)
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if (!ost->stream_copy) {
- char *sample_fmt = NULL;
+ char *sample_fmt = NULL, *filters = NULL;;
MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st);
@@ -4107,6 +3947,10 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc)
}
MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st);
+
+ MATCH_PER_STREAM_OPT(filters, str, filters, oc, st);
+ if (filters)
+ ost->avfilter = av_strdup(filters);
}
return ost;
@@ -4850,6 +4694,11 @@ static int opt_video_filters(OptionsContext *o, const char *opt, const char *arg
return parse_option(o, "filter:v", arg, options);
}
+static int opt_audio_filters(OptionsContext *o, const char *opt, const char *arg)
+{
+ return parse_option(o, "filter:a", arg, options);
+}
+
static int opt_vsync(const char *opt, const char *arg)
{
if (!av_strcasecmp(arg, "cfr")) video_sync_method = VSYNC_CFR;
@@ -5022,6 +4871,7 @@ static const OptionDef options[] = {
{ "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
{ "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING, {.off = OFFSET(sample_fmts)}, "set sample format", "format" },
{ "channel_layout", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_channel_layout}, "set channel layout", "layout" },
+ { "af", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_filters}, "audio filters", "filter list" },
/* subtitle options */
{ "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off = OFFSET(subtitle_disable)}, "disable subtitle" },
diff --git a/doc/avconv.texi b/doc/avconv.texi
index cc46e95392..511642a56d 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -435,6 +435,11 @@ Set the audio codec. This is an alias for @code{-codec:a}.
@item -sample_fmt[:@var{stream_specifier}] @var{sample_fmt} (@emph{output,per-stream})
Set the audio sample format. Use @code{-sample_fmts} to get a list
of supported sample formats.
+@item -af @var{filter_graph} (@emph{output})
+@var{filter_graph} is a description of the filter graph to apply to
+the input audio.
+Use the option "-filters" to show all the available filters (including
+also sources and sinks). This is an alias for @code{-filter:a}.
@end table
@section Advanced Audio options:
diff --git a/tests/ref/fate/adpcm-ima-amv b/tests/ref/fate/adpcm-ima-amv
index 977c125080..6c2fa32726 100644
--- a/tests/ref/fate/adpcm-ima-amv
+++ b/tests/ref/fate/adpcm-ima-amv
@@ -3,7 +3,7 @@
0, 1378, 1378, 1378, 2756, 0x8462443f
0, 2756, 2756, 1378, 2756, 0x9f493ba6
0, 4134, 4134, 1378, 2756, 0x634e5f06
-0, 5512, 5512, 1380, 2760, 0x51f35cd4
+0, 5513, 5513, 1380, 2760, 0x51f35cd4
0, 6891, 6891, 1378, 2756, 0x011c51e5
0, 8269, 8269, 1378, 2756, 0x8c2c198c
0, 9647, 9647, 1378, 2756, 0x2b4a3397
@@ -19,7 +19,7 @@
0, 23428, 23428, 1378, 2756, 0x96346ba6
0, 24806, 24806, 1378, 2756, 0x3d54543b
0, 26184, 26184, 1380, 2760, 0x601786e1
-0, 27562, 27562, 1378, 2756, 0xf22a5793
+0, 27563, 27563, 1378, 2756, 0xf22a5793
0, 28941, 28941, 1378, 2756, 0x21f54d49
0, 30319, 30319, 1378, 2756, 0x0c6d4399
0, 31697, 31697, 1378, 2756, 0x17282f8e
@@ -35,7 +35,7 @@
0, 45478, 45478, 1380, 2760, 0x98a76091
0, 46856, 46856, 1378, 2756, 0x5d357141
0, 48234, 48234, 1378, 2756, 0x65ea2657
-0, 49612, 49612, 1378, 2756, 0xb5e1334a
+0, 49613, 49613, 1378, 2756, 0xb5e1334a
0, 50991, 50991, 1378, 2756, 0x32cd5d91
0, 52369, 52369, 1378, 2756, 0xdc23722b
0, 53747, 53747, 1378, 2756, 0x2ba34684
@@ -51,7 +51,7 @@
0, 67528, 67528, 1378, 2756, 0x39c2586c
0, 68906, 68906, 1378, 2756, 0x7ffc46e5
0, 70284, 70284, 1378, 2756, 0xa2766664
-0, 71662, 71662, 1378, 2756, 0xacb50c6c
+0, 71663, 71663, 1378, 2756, 0xacb50c6c
0, 73041, 73041, 1378, 2756, 0x7f659084
0, 74419, 74419, 1378, 2756, 0xc72e6a12
0, 75797, 75797, 1380, 2760, 0xdb6944df
@@ -67,7 +67,7 @@
0, 89578, 89578, 1378, 2756, 0x5c17abef
0, 90956, 90956, 1378, 2756, 0xb3235184
0, 92334, 92334, 1378, 2756, 0xdabb64a6
-0, 93712, 93712, 1378, 2756, 0xa95dc58d
+0, 93713, 93713, 1378, 2756, 0xa95dc58d
0, 95091, 95091, 1380, 2760, 0x8e7ac9eb
0, 96469, 96469, 1378, 2756, 0x492b658e
0, 97847, 97847, 1378, 2756, 0x377483ab
@@ -83,7 +83,7 @@
0, 111628, 111628, 1378, 2756, 0xf0de66ae
0, 113006, 113006, 1378, 2756, 0xeabf3c32
0, 114384, 114384, 1378, 2756, 0xe98e81d1
-0, 115762, 115762, 1380, 2760, 0x56aa5889
+0, 115763, 115763, 1380, 2760, 0x56aa5889
0, 117141, 117141, 1378, 2756, 0x4fd34c0e
0, 118519, 118519, 1378, 2756, 0x67cf6912
0, 119897, 119897, 1378, 2756, 0xfa944def
@@ -99,7 +99,7 @@
0, 133678, 133678, 1378, 2756, 0x2e0e3f2e
0, 135056, 135056, 1380, 2760, 0xdf534478
0, 136434, 136434, 1378, 2756, 0xca000a2e
-0, 137812, 137812, 1378, 2756, 0x87472df3
+0, 137813, 137813, 1378, 2756, 0x87472df3
0, 139191, 139191, 1378, 2756, 0x16733810
0, 140569, 140569, 1378, 2756, 0xfa0734b4
0, 141947, 141947, 1378, 2756, 0x5eff3fc4
@@ -115,7 +115,7 @@
0, 155728, 155728, 1380, 2760, 0x8eca4bdb
0, 157106, 157106, 1378, 2756, 0x62bd4162
0, 158484, 158484, 1378, 2756, 0x9f744aa4
-0, 159862, 159862, 1378, 2756, 0x0f3f6409
+0, 159863, 159863, 1378, 2756, 0x0f3f6409
0, 161241, 161241, 1378, 2756, 0x3fee827a
0, 162619, 162619, 1378, 2756, 0x48a0ac19
0, 163997, 163997, 1378, 2756, 0x8e4ce0d0
@@ -131,7 +131,7 @@
0, 177778, 177778, 1378, 2756, 0xab01fb12
0, 179156, 179156, 1378, 2756, 0x04cffe5c
0, 180534, 180534, 1378, 2756, 0xef661c5e
-0, 181912, 181912, 1378, 2756, 0x094c5fc5
+0, 181913, 181913, 1378, 2756, 0x094c5fc5
0, 183291, 183291, 1378, 2756, 0xe0c1486a
0, 184669, 184669, 1380, 2760, 0x8c3535b7
0, 186047, 186047, 1378, 2756, 0x594934aa
@@ -147,7 +147,7 @@
0, 199828, 199828, 1378, 2756, 0x448e681d
0, 201206, 201206, 1378, 2756, 0x0ba9826e
0, 202584, 202584, 1378, 2756, 0x049f36fa
-0, 203962, 203962, 1378, 2756, 0x096a2b62
+0, 203963, 203963, 1378, 2756, 0x096a2b62
0, 205341, 205341, 1380, 2760, 0x579e2035
0, 206719, 206719, 1378, 2756, 0xd13e30e1
0, 208097, 208097, 1378, 2756, 0x30b6412b
diff --git a/tests/ref/fate/adpcm-ima-smjpeg b/tests/ref/fate/adpcm-ima-smjpeg
index 287e8a091c..45cb97bfc1 100644
--- a/tests/ref/fate/adpcm-ima-smjpeg
+++ b/tests/ref/fate/adpcm-ima-smjpeg
@@ -27,7 +27,7 @@
0, 12789, 12789, 512, 1024, 0x3866b03b
0, 13296, 13296, 512, 1024, 0xbc005403
0, 13803, 13803, 512, 1024, 0xe9dfcc51
-0, 14332, 14332, 512, 1024, 0x83c837cb
+0, 14333, 14333, 512, 1024, 0x83c837cb
0, 14840, 14840, 512, 1024, 0xfa649580
0, 15347, 15347, 512, 1024, 0x519452ea
0, 15854, 15854, 512, 1024, 0xd4978774
@@ -108,7 +108,7 @@
0, 54265, 54265, 512, 1024, 0xd6ece2a1
0, 54772, 54772, 512, 1024, 0x33ab9553
0, 55279, 55279, 512, 1024, 0xd50c73a6
-0, 55786, 55786, 512, 1024, 0xfe25b63a
+0, 55787, 55787, 512, 1024, 0xfe25b63a
0, 56316, 56316, 512, 1024, 0x7e2959e3
0, 56823, 56823, 512, 1024, 0xa4c07b34
0, 57330, 57330, 512, 1024, 0xd6d8f15c
@@ -139,7 +139,7 @@
0, 70141, 70141, 512, 1024, 0xc434d238
0, 70648, 70648, 512, 1024, 0xe9ad7562
0, 71155, 71155, 512, 1024, 0xb51b6b50
-0, 71662, 71662, 512, 1024, 0xe70aecd3
+0, 71663, 71663, 512, 1024, 0xe70aecd3
0, 72192, 72192, 512, 1024, 0x03c816b2
0, 72699, 72699, 512, 1024, 0x869fdf25
0, 73206, 73206, 512, 1024, 0xd40a0a62
@@ -170,7 +170,7 @@
0, 85995, 85995, 512, 1024, 0xaa919ccc
0, 86524, 86524, 512, 1024, 0x15993dbc
0, 87031, 87031, 512, 1024, 0xbe01a7b9
-0, 87538, 87538, 512, 1024, 0xefe93c09
+0, 87539, 87539, 512, 1024, 0xefe93c09
0, 88046, 88046, 512, 1024, 0x1bb566e5
0, 88575, 88575, 512, 1024, 0x15ce6237
0, 89082, 89082, 512, 1024, 0xa8552e66
@@ -201,7 +201,7 @@
0, 101871, 101871, 512, 1024, 0x1e01fb02
0, 102378, 102378, 512, 1024, 0x4ed2c1d8
0, 102907, 102907, 512, 1024, 0xf2fdbe63
-0, 103414, 103414, 512, 1024, 0x8d6f63a1
+0, 103415, 103415, 512, 1024, 0x8d6f63a1
0, 103922, 103922, 512, 1024, 0xded468d9
0, 104429, 104429, 512, 1024, 0xccad839e
0, 104958, 104958, 512, 1024, 0xdde7c082
@@ -232,7 +232,7 @@
0, 117747, 117747, 512, 1024, 0xb01e2365
0, 118254, 118254, 512, 1024, 0x14e200d3
0, 118783, 118783, 512, 1024, 0xd1184c98
-0, 119290, 119290, 512, 1024, 0xef9140e9
+0, 119291, 119291, 512, 1024, 0xef9140e9
0, 119798, 119798, 512, 1024, 0x4cbb645e
0, 120305, 120305, 512, 1024, 0xe7fe2f06
0, 120812, 120812, 512, 1024, 0xf8c45028
@@ -263,7 +263,7 @@
0, 133623, 133623, 512, 1024, 0xa5099687
0, 134130, 134130, 512, 1024, 0xbff10707
0, 134637, 134637, 512, 1024, 0x37c4ffc0
-0, 135166, 135166, 512, 1024, 0xf9fb6caa
+0, 135167, 135167, 512, 1024, 0xf9fb6caa
0, 135674, 135674, 512, 1024, 0x3b6a3a1f
0, 136181, 136181, 512, 1024, 0x83431edb
0, 136688, 136688, 512, 1024, 0x1eb713cf
@@ -344,7 +344,7 @@
0, 175099, 175099, 512, 1024, 0xd009a7ca
0, 175606, 175606, 512, 1024, 0xb6d5a938
0, 176113, 176113, 512, 1024, 0xf3d45e47
-0, 176620, 176620, 512, 1024, 0xea8e04fc
+0, 176621, 176621, 512, 1024, 0xea8e04fc
0, 177150, 177150, 512, 1024, 0x0b928bd8
0, 177657, 177657, 512, 1024, 0x0f02caec
0, 178164, 178164, 512, 1024, 0xe2b137a8
diff --git a/tests/ref/fate/smjpeg b/tests/ref/fate/smjpeg
index 78b750a5ac..7aac52febc 100644
--- a/tests/ref/fate/smjpeg
+++ b/tests/ref/fate/smjpeg
@@ -34,7 +34,7 @@
1, 12789, 12789, 512, 1024, 0x3866b03b
1, 13296, 13296, 512, 1024, 0xbc005403
1, 13803, 13803, 512, 1024, 0xe9dfcc51
-1, 14332, 14332, 512, 1024, 0x83c837cb
+1, 14333, 14333, 512, 1024, 0x83c837cb
0, 666, 666, 0, 6808, 0x1f6eb7c3
1, 14840, 14840, 512, 1024, 0xfa649580
1, 15347, 15347, 512, 1024, 0x519452ea
@@ -132,7 +132,7 @@
1, 54265, 54265, 512, 1024, 0xd6ece2a1
1, 54772, 54772, 512, 1024, 0x33ab9553
1, 55279, 55279, 512, 1024, 0xd50c73a6
-1, 55786, 55786, 512, 1024, 0xfe25b63a
+1, 55787, 55787, 512, 1024, 0xfe25b63a
1, 56316, 56316, 512, 1024, 0x7e2959e3
0, 2555, 2555, 0, 7213, 0x97b89994
1, 56823, 56823, 512, 1024, 0xa4c07b34
@@ -170,7 +170,7 @@
1, 70648, 70648, 512, 1024, 0xe9ad7562
0, 3222, 3222, 0, 7065, 0x45035c5c
1, 71155, 71155, 512, 1024, 0xb51b6b50
-1, 71662, 71662, 512, 1024, 0xe70aecd3
+1, 71663, 71663, 512, 1024, 0xe70aecd3
1, 72192, 72192, 512, 1024, 0x03c816b2
1, 72699, 72699, 512, 1024, 0x869fdf25
1, 73206, 73206, 512, 1024, 0xd40a0a62
@@ -207,7 +207,7 @@
1, 85995, 85995, 512, 1024, 0xaa919ccc
1, 86524, 86524, 512, 1024, 0x15993dbc
1, 87031, 87031, 512, 1024, 0xbe01a7b9
-1, 87538, 87538, 512, 1024, 0xefe93c09
+1, 87539, 87539, 512, 1024, 0xefe93c09
1, 88046, 88046, 512, 1024, 0x1bb566e5
0, 4000, 4000, 0, 7246, 0x519a7a3c
1, 88575, 88575, 512, 1024, 0x15ce6237
@@ -245,7 +245,7 @@
1, 102378, 102378, 512, 1024, 0x4ed2c1d8
0, 4666, 4666, 111, 7104, 0xc0d14f78
1, 102907, 102907, 512, 1024, 0xf2fdbe63
-1, 103414, 103414, 512, 1024, 0x8d6f63a1
+1, 103415, 103415, 512, 1024, 0x8d6f63a1
1, 103922, 103922, 512, 1024, 0xded468d9
1, 104429, 104429, 512, 1024, 0xccad839e
1, 104958, 104958, 512, 1024, 0xdde7c082
@@ -282,7 +282,7 @@
1, 117747, 117747, 512, 1024, 0xb01e2365
1, 118254, 118254, 512, 1024, 0x14e200d3
1, 118783, 118783, 512, 1024, 0xd1184c98
-1, 119290, 119290, 512, 1024, 0xef9140e9
+1, 119291, 119291, 512, 1024, 0xef9140e9
1, 119798, 119798, 512, 1024, 0x4cbb645e
0, 5444, 5444, 111, 7106, 0xd1a83ddc
1, 120305, 120305, 512, 1024, 0xe7fe2f06
@@ -320,7 +320,7 @@
1, 134130, 134130, 512, 1024, 0xbff10707
1, 134637, 134637, 512, 1024, 0x37c4ffc0
0, 6111, 6111, 111, 7283, 0x19dd7319
-1, 135166, 135166, 512, 1024, 0xf9fb6caa
+1, 135167, 135167, 512, 1024, 0xf9fb6caa
1, 135674, 135674, 512, 1024, 0x3b6a3a1f
1, 136181, 136181, 512, 1024, 0x83431edb
1, 136688, 136688, 512, 1024, 0x1eb713cf
@@ -418,7 +418,7 @@
1, 175606, 175606, 512, 1024, 0xb6d5a938
1, 176113, 176113, 512, 1024, 0xf3d45e47
0, 8000, 8000, 111, 2153, 0xf4e3bc17
-1, 176620, 176620, 512, 1024, 0xea8e04fc
+1, 176621, 176621, 512, 1024, 0xea8e04fc
1, 177150, 177150, 512, 1024, 0x0b928bd8
1, 177657, 177657, 512, 1024, 0x0f02caec
1, 178164, 178164, 512, 1024, 0xe2b137a8