From 0b6f9736355f0a561b7e744e38699af88513bfab Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 22 Jun 2012 18:52:27 +0100 Subject: [PATCH 01/10] h264: use asm cabac reader under a generic condition This removes a dependency on implementation details from generic code and allows easy addition of the equivalent optimisation for other architectures than x86. Signed-off-by: Mans Rullgard --- libavcodec/h264_cabac.c | 6 +++--- libavcodec/x86/h264_i386.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 08a6a5b15d..2bf08b5221 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1652,14 +1652,14 @@ decode_cabac_residual_internal(H264Context *h, DCTELEM *block, index[coeff_count++] = last;\ } const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; -#if ARCH_X86 && HAVE_7REGS - coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, +#ifdef decode_significance + coeff_count = decode_significance_8x8(CC, significant_coeff_ctx_base, index, last_coeff_ctx_base, sig_off); } else { if (is_dc && chroma422) { // dc 422 DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); } else { - coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, + coeff_count = decode_significance(CC, max_coeff, significant_coeff_ctx_base, index, last_coeff_ctx_base-significant_coeff_ctx_base); } #else diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 10ea32e0b8..c0033b7ff3 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -37,6 +37,7 @@ //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) #if HAVE_7REGS +#define decode_significance decode_significance_x86 static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off){ @@ -105,6 +106,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, return coeff_count; } +#define decode_significance_8x8 decode_significance_8x8_x86 static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){ From 7a8059eb9c47fe873996376e041e2f0e8d427e8e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 22 Jun 2012 23:01:03 +0200 Subject: [PATCH 02/10] doc/filters: fix typo. --- doc/filters.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 218cd600ee..d3543b39c0 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -281,7 +281,7 @@ Desired output channel layout. Defaults to stereo. Map channels from inputs to output. The argument is a comma-separated list of mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}} form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel} -can be either the name of the input channel (e.g. FR for front left) or its +can be either the name of the input channel (e.g. FL for front left) or its index in the specified input stream. @var{out_channel} is the name of the output channel. @end table From 6fc7d9a07850b50575f3342c2a54560fcaf66c5d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 23 Jun 2012 16:02:45 +0200 Subject: [PATCH 03/10] avconv: remove redundant handling of async. Because of a mistake during merging the code for simple and complex filtergraphs, -async inserts an asyncts filter both on input and output. Remove the output hunk. --- avconv.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/avconv.c b/avconv.c index bc6a8fbe06..27fbb0b2ce 100644 --- a/avconv.c +++ b/avconv.c @@ -742,34 +742,6 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, pad_idx = 0; } - if (audio_sync_method > 0) { - AVFilterContext *async; - char args[256]; - int len = 0; - - av_log(NULL, AV_LOG_WARNING, "-async has been deprecated. Used the " - "asyncts audio filter instead.\n"); - - if (audio_sync_method > 1) - len += snprintf(args + len, sizeof(args) - len, "compensate=1:" - "max_comp=%d:", audio_sync_method); - snprintf(args + len, sizeof(args) - len, "min_delta=%f", - audio_drift_threshold); - - ret = avfilter_graph_create_filter(&async, - avfilter_get_by_name("asyncts"), - "async", args, NULL, fg->graph); - if (ret < 0) - return ret; - - ret = avfilter_link(last_filter, pad_idx, async, 0); - if (ret < 0) - return ret; - - last_filter = async; - pad_idx = 0; - } - if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0) return ret; From df98bf22cb931376c6423ede861e5a94c3881e94 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 23 Jun 2012 16:08:24 +0200 Subject: [PATCH 04/10] avconv: use more descriptive names for hardcoded filters. Also ensure that all such filters get a non-NULL name. Should fix FATE failures on some architectures after 58b049f2fa4f192b00baadb5f1f32ca366f936ea. --- avconv.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/avconv.c b/avconv.c index 27fbb0b2ce..da385c9c46 100644 --- a/avconv.c +++ b/avconv.c @@ -622,11 +622,12 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; int ret; + char name[255]; - + snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("buffersink"), - "out", NULL, pix_fmts, fg->graph); + name, NULL, pix_fmts, fg->graph); if (ret < 0) return ret; @@ -638,8 +639,10 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, codec->width, codec->height, (unsigned)ost->sws_flags); + snprintf(name, sizeof(name), "scaler for output stream %d:%d", + ost->file_index, ost->index); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), - NULL, args, NULL, fg->graph)) < 0) + name, args, NULL, fg->graph)) < 0) return ret; if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0) return ret; @@ -650,6 +653,8 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, if ((pix_fmts = choose_pix_fmts(ost))) { AVFilterContext *filter; + snprintf(name, sizeof(name), "pixel format for output stream %d:%d", + ost->file_index, ost->index); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("format"), "format", pix_fmts, NULL, @@ -669,8 +674,10 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num, ost->frame_rate.den); + snprintf(name, sizeof(name), "fps for output stream %d:%d", + ost->file_index, ost->index); ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"), - "fps", args, NULL, fg->graph); + name, args, NULL, fg->graph); if (ret < 0) return ret; @@ -694,11 +701,14 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; char *sample_fmts, *sample_rates, *channel_layouts; + char name[255]; int ret; + + snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("abuffersink"), - "out", NULL, NULL, fg->graph); + name, NULL, NULL, fg->graph); if (ret < 0) return ret; @@ -728,9 +738,11 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, av_freep(&sample_rates); av_freep(&channel_layouts); + snprintf(name, sizeof(name), "audio format for output stream %d:%d", + ost->file_index, ost->index); ret = avfilter_graph_create_filter(&format, avfilter_get_by_name("aformat"), - "aformat", args, NULL, fg->graph); + name, args, NULL, fg->graph); if (ret < 0) return ret; @@ -787,7 +799,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, ist->framerate.num} : ist->st->time_base; AVRational sar; - char args[255]; + char args[255], name[255]; int pad_idx = in->pad_idx; int ret; @@ -797,17 +809,21 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, snprintf(args, sizeof(args), "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width, ist->st->codec->height, ist->st->codec->pix_fmt, tb.num, tb.den, sar.num, sar.den); + snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, + ist->file_index, ist->st->index); - if ((ret = avfilter_graph_create_filter(&ifilter->filter, filter, in->name, + if ((ret = avfilter_graph_create_filter(&ifilter->filter, filter, name, args, NULL, fg->graph)) < 0) return ret; if (ist->framerate.num) { AVFilterContext *setpts; + snprintf(name, sizeof(name), "force CFR for input from stream %d:%d", + ist->file_index, ist->st->index); if ((ret = avfilter_graph_create_filter(&setpts, avfilter_get_by_name("setpts"), - "setpts", "N", NULL, + name, "N", NULL, fg->graph)) < 0) return ret; @@ -830,7 +846,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AVFilter *filter = avfilter_get_by_name("abuffer"); InputStream *ist = ifilter->ist; int pad_idx = in->pad_idx; - char args[255]; + char args[255], name[255]; int ret; snprintf(args, sizeof(args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s" @@ -839,9 +855,11 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, ist->st->codec->sample_rate, av_get_sample_fmt_name(ist->st->codec->sample_fmt), ist->st->codec->channel_layout); + snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, + ist->file_index, ist->st->index); if ((ret = avfilter_graph_create_filter(&ifilter->filter, filter, - in->name, args, NULL, + name, args, NULL, fg->graph)) < 0) return ret; @@ -859,9 +877,11 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, snprintf(args + len, sizeof(args) - len, "min_delta=%f", audio_drift_threshold); + snprintf(name, sizeof(name), "graph %d audio sync for input stream %d:%d", + fg->index, ist->file_index, ist->st->index); ret = avfilter_graph_create_filter(&async, avfilter_get_by_name("asyncts"), - "async", args, NULL, fg->graph); + name, args, NULL, fg->graph); if (ret < 0) return ret; From fd269d6253576f220dbd18c367593cc6242989dc Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 23 Jun 2012 16:10:08 +0200 Subject: [PATCH 05/10] avconv: remove a forgotten debugging printf. --- avconv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/avconv.c b/avconv.c index da385c9c46..84e6baa281 100644 --- a/avconv.c +++ b/avconv.c @@ -4441,7 +4441,6 @@ loop_end: } else if (ret < 0) exit_program(1); } - printf("ret %d, stream_spec %s\n", ret, stream_spec); } else { switch (type) { From b5bce20cc395b1dfd0017dd3140fa39998cd0a02 Mon Sep 17 00:00:00 2001 From: Mashiat Sarker Shakkhar Date: Sat, 23 Jun 2012 09:53:43 +0600 Subject: [PATCH 06/10] image2: Add "start_number" private option to the muxer This adds the capability to start counting file number from an arbitrary integer. This includes a few lines of trivial code from FFmpeg codebase. Signed-off-by: Anton Khirnov --- libavformat/img2enc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index c825c2bf23..0f348576f5 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -26,8 +26,10 @@ #include "avformat.h" #include "avio_internal.h" #include "internal.h" +#include "libavutil/opt.h" typedef struct { + const AVClass *class; /**< Class for private options. */ int img_number; int is_pipe; char path[1024]; @@ -37,7 +39,6 @@ static int write_header(AVFormatContext *s) { VideoMuxData *img = s->priv_data; - img->img_number = 1; av_strlcpy(img->path, s->filename, sizeof(img->path)); /* find format */ @@ -124,7 +125,21 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } +#define OFFSET(x) offsetof(VideoMuxData, x) +#define ENC AV_OPT_FLAG_ENCODING_PARAM +static const AVOption muxoptions[] = { + { "start_number", "first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, {.dbl = 1}, 1, INT_MAX, ENC }, + { NULL }, +}; + #if CONFIG_IMAGE2_MUXER +static const AVClass img2mux_class = { + .class_name = "image2 muxer", + .item_name = av_default_item_name, + .option = muxoptions, + .version = LIBAVUTIL_VERSION_INT, +}; + AVOutputFormat ff_image2_muxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), @@ -135,7 +150,8 @@ AVOutputFormat ff_image2_muxer = { .video_codec = CODEC_ID_MJPEG, .write_header = write_header, .write_packet = write_packet, - .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE + .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE, + .priv_class = &img2mux_class, }; #endif #if CONFIG_IMAGE2PIPE_MUXER From f57d2f587b0b424cd81178f76885ac5117ebe16f Mon Sep 17 00:00:00 2001 From: Mashiat Sarker Shakkhar Date: Sat, 23 Jun 2012 09:57:04 +0600 Subject: [PATCH 07/10] image2: Add "start_number" private option to the demuxer Currently if a pattern is given we look for up to the fifth file name in the sequence. This option sets that limit to an arbitrary number. Signed-off-by: Anton Khirnov --- libavformat/img2dec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index b4b9723bcd..8f30cd559a 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -40,6 +40,7 @@ typedef struct { char *video_size; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ int loop; + int start_number; } VideoDemuxData; static const int sizes[][2] = { @@ -70,13 +71,13 @@ static int infer_size(int *width_ptr, int *height_ptr, int size) /* return -1 if no image found */ static int find_image_range(int *pfirst_index, int *plast_index, - const char *path) + const char *path, int max_start) { char buf[1024]; int range, last_index, range1, first_index; /* find the first image */ - for(first_index = 0; first_index < 5; first_index++) { + for (first_index = 0; first_index < max_start; first_index++) { if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ *pfirst_index = *plast_index = 1; @@ -182,7 +183,8 @@ static int read_header(AVFormatContext *s1) } if (!s->is_pipe) { - if (find_image_range(&first_index, &last_index, s->path) < 0) + if (find_image_range(&first_index, &last_index, s->path, + FFMAX(s->start_number, 5)) < 0) return AVERROR(ENOENT); s->img_first = first_index; s->img_last = last_index; @@ -283,6 +285,7 @@ static const AVOption options[] = { { "video_size", "", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { "loop", "", OFFSET(loop), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, + { "start_number", "first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.dbl = 1}, 1, INT_MAX, DEC }, { NULL }, }; From a7b8ff94b19732012549c745e2be3a4b1e2cb872 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 21 Jun 2012 18:13:34 +0200 Subject: [PATCH 08/10] mov: make a length variable larger. Right now, it's uint16_t, but for itunes metadata a 32bit number is stored in it. --- libavformat/mov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 63c79cd002..fa70eff66f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -172,8 +172,8 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) #endif char str[1024], key2[16], language[4] = {0}; const char *key = NULL; - uint16_t str_size, langcode = 0; - uint32_t data_type = 0; + uint16_t langcode = 0; + uint32_t data_type = 0, str_size; int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL; switch (atom.type) { From 980e65f11994c3659451feb170bff085731693c2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 22 Jun 2012 13:08:08 +0200 Subject: [PATCH 09/10] ape: create audio stream before reading tags. Tags may contain attached picture, which will be exported as video streams. This ensures that the audio stream is always the first. --- libavformat/ape.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/ape.c b/libavformat/ape.c index b3fca23db5..76ad549117 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -312,12 +312,6 @@ static int ape_read_header(AVFormatContext * s) ape_dumpinfo(s, ape); - /* try to read APE tags */ - if (pb->seekable) { - ff_ape_parse_tag(s); - avio_seek(pb, 0, SEEK_SET); - } - av_log(s, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %"PRIu16"\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype); @@ -354,6 +348,12 @@ static int ape_read_header(AVFormatContext * s) pts += ape->blocksperframe / MAC_SUBFRAME_SIZE; } + /* try to read APE tags */ + if (pb->seekable) { + ff_ape_parse_tag(s); + avio_seek(pb, 0, SEEK_SET); + } + return 0; } From 145a8096d53c20da7898539e521e6d4267ab2f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sat, 23 Jun 2012 19:21:35 +0300 Subject: [PATCH 10/10] log: Only include unistd.h if configure found it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MSVC has isatty (in io.h), but not unistd.h. (isatty isn't called at all for windows, since there's a special case block for that.) Signed-off-by: Martin Storsjö --- libavutil/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/log.c b/libavutil/log.c index e4a9fec552..e2773d433d 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -26,7 +26,7 @@ #include "config.h" -#if HAVE_ISATTY +#if HAVE_UNISTD_H #include #endif #include