From 88a3569917c817ecaa9982cea1f022b34d986390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 10 Sep 2012 15:34:51 +0300 Subject: [PATCH 1/9] configure: Don't try to enable the log2 function on msvcrt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some msvcrt versions (the static 64 bit libc in MSVC 10) have a log2 function, but there is no declaration for it in the headers. Therefore, the normal configure check might find it, but it can fail during build or at runtime, depending on whether implicit function declarations are an error or not. Therefore simply ignore this function on this platform. Signed-off-by: Martin Storsjö --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index ae8e76590a..d5809aa0ca 100755 --- a/configure +++ b/configure @@ -1381,6 +1381,8 @@ need_memalign="altivec neon sse" symver_if_any="symver_asm_label symver_gnu_asm" +log2_deps="!msvcrt" + # subsystems dct_select="rdft" mdct_select="fft" From afb5ed55d2e4cc9cadd5ab6bcbf5b0a1abb5080a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 4 Sep 2012 18:23:25 +0200 Subject: [PATCH 2/9] configure: Add --disable-inline-asm command line option This can come in handy for testing and possibly other purposes. --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index d5809aa0ca..29c4317f17 100755 --- a/configure +++ b/configure @@ -259,6 +259,7 @@ Optimization options (experts only): --disable-mmi disable MMI optimizations --disable-neon disable NEON optimizations --disable-vis disable VIS optimizations + --disable-inline-asm disable use of inline assembler --disable-yasm disable use of yasm assembler Developer options (useful when working on Libav itself): @@ -1275,6 +1276,7 @@ CMDLINE_SELECT=" cross_compile debug extra_warnings + inline_asm logging optimizations symver @@ -2926,7 +2928,7 @@ EOF sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }') extern_prefix=${sym%%ff_extern*} -check_cc < Date: Mon, 10 Sep 2012 17:35:39 +0300 Subject: [PATCH 3/9] configure: Adjust the xgetbv instrinsic check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 64 bit cl.exe version 16.00.30319.01 crashes with an internal compiler error on the current check (and thus deduces it isn't supported, even if the actual usage in libavuil/x86/cpu.c works fine), but by assigning the value from the intrinsic to a variable, or returning it, it works fine. This error is fixed in cl.exe version 16.00.40219.01. Signed-off-by: Martin Storsjö --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 29c4317f17..fec7b2543d 100755 --- a/configure +++ b/configure @@ -3029,7 +3029,7 @@ elif enabled sparc; then elif enabled x86; then - check_code ld immintrin.h "__xgetbv(0)" && enable xgetbv + check_code ld immintrin.h "return __xgetbv(0)" && enable xgetbv check_code ld intrin.h "int info[4]; __cpuid(info, 0)" && enable cpuid check_code ld intrin.h "__rdtsc()" && enable rdtsc check_code ld intrin.h "unsigned int x = __readeflags()" && enable rweflags From 0697d81269ab07d91b3303923a4751c21c675439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 9 Sep 2012 22:35:50 +0300 Subject: [PATCH 4/9] file: Use a normal private context for storing the file descriptor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the file descriptor was stored in the priv_data pointer. Signed-off-by: Martin Storsjö --- libavformat/file.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 0e3577d070..3cfd28c2a4 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -36,21 +36,26 @@ /* standard file protocol */ +typedef struct FileContext { + int fd; +} FileContext; + static int file_read(URLContext *h, unsigned char *buf, int size) { - int fd = (intptr_t) h->priv_data; - return read(fd, buf, size); + FileContext *c = h->priv_data; + return read(c->fd, buf, size); } static int file_write(URLContext *h, const unsigned char *buf, int size) { - int fd = (intptr_t) h->priv_data; - return write(fd, buf, size); + FileContext *c = h->priv_data; + return write(c->fd, buf, size); } static int file_get_handle(URLContext *h) { - return (intptr_t) h->priv_data; + FileContext *c = h->priv_data; + return c->fd; } static int file_check(URLContext *h, int mask) @@ -70,6 +75,7 @@ static int file_check(URLContext *h, int mask) static int file_open(URLContext *h, const char *filename, int flags) { + FileContext *c = h->priv_data; int access; int fd; @@ -88,26 +94,26 @@ static int file_open(URLContext *h, const char *filename, int flags) fd = open(filename, access, 0666); if (fd == -1) return AVERROR(errno); - h->priv_data = (void *) (intptr_t) fd; + c->fd = fd; return 0; } /* XXX: use llseek */ static int64_t file_seek(URLContext *h, int64_t pos, int whence) { - int fd = (intptr_t) h->priv_data; + FileContext *c = h->priv_data; if (whence == AVSEEK_SIZE) { struct stat st; - int ret = fstat(fd, &st); + int ret = fstat(c->fd, &st); return ret < 0 ? AVERROR(errno) : st.st_size; } - return lseek(fd, pos, whence); + return lseek(c->fd, pos, whence); } static int file_close(URLContext *h) { - int fd = (intptr_t) h->priv_data; - return close(fd); + FileContext *c = h->priv_data; + return close(c->fd); } URLProtocol ff_file_protocol = { @@ -119,6 +125,7 @@ URLProtocol ff_file_protocol = { .url_close = file_close, .url_get_file_handle = file_get_handle, .url_check = file_check, + .priv_data_size = sizeof(FileContext), }; #endif /* CONFIG_FILE_PROTOCOL */ @@ -127,6 +134,7 @@ URLProtocol ff_file_protocol = { static int pipe_open(URLContext *h, const char *filename, int flags) { + FileContext *c = h->priv_data; int fd; char *final; av_strstart(filename, "pipe:", &filename); @@ -142,7 +150,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags) #if HAVE_SETMODE setmode(fd, O_BINARY); #endif - h->priv_data = (void *) (intptr_t) fd; + c->fd = fd; h->is_streamed = 1; return 0; } @@ -154,6 +162,7 @@ URLProtocol ff_pipe_protocol = { .url_write = file_write, .url_get_file_handle = file_get_handle, .url_check = file_check, + .priv_data_size = sizeof(FileContext), }; #endif /* CONFIG_PIPE_PROTOCOL */ From ee0dadc1092cc097356daf967840faa0811409b1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 1 Sep 2012 16:20:58 +0200 Subject: [PATCH 5/9] flvdec: always set AVFMTCTX_NOHEADER. New streams may be created at any time, e.g. on codec change. --- libavformat/flvdec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 084d012a61..868cc6b793 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -501,9 +501,7 @@ static int flv_read_header(AVFormatContext *s) av_log(s, AV_LOG_WARNING, "Broken FLV file, which says no streams present, this might fail\n"); } - if((flags & (FLV_HEADER_FLAG_HASVIDEO|FLV_HEADER_FLAG_HASAUDIO)) - != (FLV_HEADER_FLAG_HASVIDEO|FLV_HEADER_FLAG_HASAUDIO)) - s->ctx_flags |= AVFMTCTX_NOHEADER; + s->ctx_flags |= AVFMTCTX_NOHEADER; if(flags & FLV_HEADER_FLAG_HASVIDEO){ if(!create_stream(s, AVMEDIA_TYPE_VIDEO)) @@ -714,7 +712,6 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) if(i == s->nb_streams){ st = create_stream(s, is_audio ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO); - s->ctx_flags &= ~AVFMTCTX_NOHEADER; } av_dlog(s, "%d %X %d \n", is_audio, flags, st->discard); if( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || is_audio)) From 4e82cbb62909bcffca0007ac80e619a28a714b13 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 10 Sep 2012 14:37:46 +0200 Subject: [PATCH 6/9] avplay: fix prototypes for option callbacks. They have been wrong since 11d957fbd81288e64408e79ed369446346000b29 --- avplay.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/avplay.c b/avplay.c index 0c642e07b0..029c7bc172 100644 --- a/avplay.c +++ b/avplay.c @@ -2791,26 +2791,26 @@ static void event_loop(void) } } -static int opt_frame_size(const char *opt, const char *arg) +static int opt_frame_size(void *optctx, const char *opt, const char *arg) { av_log(NULL, AV_LOG_ERROR, "Option '%s' has been removed, use private format options instead\n", opt); return AVERROR(EINVAL); } -static int opt_width(const char *opt, const char *arg) +static int opt_width(void *optctx, const char *opt, const char *arg) { screen_width = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX); return 0; } -static int opt_height(const char *opt, const char *arg) +static int opt_height(void *optctx, const char *opt, const char *arg) { screen_height = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX); return 0; } -static int opt_format(const char *opt, const char *arg) +static int opt_format(void *optctx, const char *opt, const char *arg) { file_iformat = av_find_input_format(arg); if (!file_iformat) { @@ -2820,14 +2820,14 @@ static int opt_format(const char *opt, const char *arg) return 0; } -static int opt_frame_pix_fmt(const char *opt, const char *arg) +static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg) { av_log(NULL, AV_LOG_ERROR, "Option '%s' has been removed, use private format options instead\n", opt); return AVERROR(EINVAL); } -static int opt_sync(const char *opt, const char *arg) +static int opt_sync(void *optctx, const char *opt, const char *arg) { if (!strcmp(arg, "audio")) av_sync_type = AV_SYNC_AUDIO_MASTER; @@ -2842,26 +2842,26 @@ static int opt_sync(const char *opt, const char *arg) return 0; } -static int opt_seek(const char *opt, const char *arg) +static int opt_seek(void *optctx, const char *opt, const char *arg) { start_time = parse_time_or_die(opt, arg, 1); return 0; } -static int opt_duration(const char *opt, const char *arg) +static int opt_duration(void *optctx, const char *opt, const char *arg) { duration = parse_time_or_die(opt, arg, 1); return 0; } -static int opt_debug(const char *opt, const char *arg) +static int opt_debug(void *optctx, const char *opt, const char *arg) { av_log_set_level(99); debug = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); return 0; } -static int opt_vismv(const char *opt, const char *arg) +static int opt_vismv(void *optctx, const char *opt, const char *arg) { debug_mv = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); return 0; @@ -2869,25 +2869,25 @@ static int opt_vismv(const char *opt, const char *arg) static const OptionDef options[] = { #include "cmdutils_common_opts.h" - { "x", HAS_ARG, { (void*)opt_width }, "force displayed width", "width" }, - { "y", HAS_ARG, { (void*)opt_height }, "force displayed height", "height" }, - { "s", HAS_ARG | OPT_VIDEO, { (void*)opt_frame_size }, "set frame size (WxH or abbreviation)", "size" }, + { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" }, + { "y", HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" }, + { "s", HAS_ARG | OPT_VIDEO, { .func_arg = opt_frame_size }, "set frame size (WxH or abbreviation)", "size" }, { "fs", OPT_BOOL, { (void*)&is_full_screen }, "force full screen" }, { "an", OPT_BOOL, { (void*)&audio_disable }, "disable audio" }, { "vn", OPT_BOOL, { (void*)&video_disable }, "disable video" }, { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&wanted_stream[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_number" }, { "vst", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&wanted_stream[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_number" }, { "sst", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&wanted_stream[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_number" }, - { "ss", HAS_ARG, { (void*)&opt_seek }, "seek to a given position in seconds", "pos" }, - { "t", HAS_ARG, { (void*)&opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, + { "ss", HAS_ARG, { .func_arg = opt_seek }, "seek to a given position in seconds", "pos" }, + { "t", HAS_ARG, { .func_arg = opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, { "bytes", OPT_INT | HAS_ARG, { (void*)&seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, { "nodisp", OPT_BOOL, { (void*)&display_disable }, "disable graphical display" }, - { "f", HAS_ARG, { (void*)opt_format }, "force format", "fmt" }, - { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { (void*)opt_frame_pix_fmt }, "set pixel format", "format" }, + { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" }, + { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, { "stats", OPT_BOOL | OPT_EXPERT, { (void*)&show_status }, "show status", "" }, - { "debug", HAS_ARG | OPT_EXPERT, { (void*)opt_debug }, "print specific debug info", "" }, + { "debug", HAS_ARG | OPT_EXPERT, { .func_arg = opt_debug }, "print specific debug info", "" }, { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&workaround_bugs }, "workaround bugs", "" }, - { "vismv", HAS_ARG | OPT_EXPERT, { (void*)opt_vismv }, "visualize motion vectors", "" }, + { "vismv", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vismv }, "visualize motion vectors", "" }, { "fast", OPT_BOOL | OPT_EXPERT, { (void*)&fast }, "non spec compliant optimizations", "" }, { "genpts", OPT_BOOL | OPT_EXPERT, { (void*)&genpts }, "generate pts", "" }, { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""}, @@ -2896,7 +2896,7 @@ static const OptionDef options[] = { { "skipidct", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&skip_idct }, "", "" }, { "idct", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&idct }, "set idct algo", "algo" }, { "ec", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&error_concealment }, "set error concealment options", "bit_mask" }, - { "sync", HAS_ARG | OPT_EXPERT, { (void*)opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" }, + { "sync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" }, { "autoexit", OPT_BOOL | OPT_EXPERT, { (void*)&autoexit }, "exit at the end", "" }, { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { (void*)&exit_on_keydown }, "exit on key down", "" }, { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { (void*)&exit_on_mousedown }, "exit on mouse down", "" }, From 0e8dccb79b4ecb0dfcba731bf6db75a08cfc4a7b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 10 Sep 2012 14:42:24 +0200 Subject: [PATCH 7/9] avplay: get rid of ugly casts in the options table --- avplay.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/avplay.c b/avplay.c index 029c7bc172..a0b0e5bc56 100644 --- a/avplay.c +++ b/avplay.c @@ -2872,43 +2872,43 @@ static const OptionDef options[] = { { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" }, { "y", HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" }, { "s", HAS_ARG | OPT_VIDEO, { .func_arg = opt_frame_size }, "set frame size (WxH or abbreviation)", "size" }, - { "fs", OPT_BOOL, { (void*)&is_full_screen }, "force full screen" }, - { "an", OPT_BOOL, { (void*)&audio_disable }, "disable audio" }, - { "vn", OPT_BOOL, { (void*)&video_disable }, "disable video" }, - { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&wanted_stream[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_number" }, - { "vst", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&wanted_stream[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_number" }, - { "sst", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&wanted_stream[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_number" }, + { "fs", OPT_BOOL, { &is_full_screen }, "force full screen" }, + { "an", OPT_BOOL, { &audio_disable }, "disable audio" }, + { "vn", OPT_BOOL, { &video_disable }, "disable video" }, + { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, { &wanted_stream[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_number" }, + { "vst", OPT_INT | HAS_ARG | OPT_EXPERT, { &wanted_stream[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_number" }, + { "sst", OPT_INT | HAS_ARG | OPT_EXPERT, { &wanted_stream[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_number" }, { "ss", HAS_ARG, { .func_arg = opt_seek }, "seek to a given position in seconds", "pos" }, { "t", HAS_ARG, { .func_arg = opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, - { "bytes", OPT_INT | HAS_ARG, { (void*)&seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, - { "nodisp", OPT_BOOL, { (void*)&display_disable }, "disable graphical display" }, + { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, + { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" }, { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" }, { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, - { "stats", OPT_BOOL | OPT_EXPERT, { (void*)&show_status }, "show status", "" }, + { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" }, { "debug", HAS_ARG | OPT_EXPERT, { .func_arg = opt_debug }, "print specific debug info", "" }, - { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&workaround_bugs }, "workaround bugs", "" }, + { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, { &workaround_bugs }, "workaround bugs", "" }, { "vismv", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vismv }, "visualize motion vectors", "" }, - { "fast", OPT_BOOL | OPT_EXPERT, { (void*)&fast }, "non spec compliant optimizations", "" }, - { "genpts", OPT_BOOL | OPT_EXPERT, { (void*)&genpts }, "generate pts", "" }, - { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""}, - { "skiploop", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&skip_loop_filter }, "", "" }, - { "skipframe", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&skip_frame }, "", "" }, - { "skipidct", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&skip_idct }, "", "" }, - { "idct", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&idct }, "set idct algo", "algo" }, - { "ec", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&error_concealment }, "set error concealment options", "bit_mask" }, + { "fast", OPT_BOOL | OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" }, + { "genpts", OPT_BOOL | OPT_EXPERT, { &genpts }, "generate pts", "" }, + { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, { &decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""}, + { "skiploop", OPT_INT | HAS_ARG | OPT_EXPERT, { &skip_loop_filter }, "", "" }, + { "skipframe", OPT_INT | HAS_ARG | OPT_EXPERT, { &skip_frame }, "", "" }, + { "skipidct", OPT_INT | HAS_ARG | OPT_EXPERT, { &skip_idct }, "", "" }, + { "idct", OPT_INT | HAS_ARG | OPT_EXPERT, { &idct }, "set idct algo", "algo" }, + { "ec", OPT_INT | HAS_ARG | OPT_EXPERT, { &error_concealment }, "set error concealment options", "bit_mask" }, { "sync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" }, - { "autoexit", OPT_BOOL | OPT_EXPERT, { (void*)&autoexit }, "exit at the end", "" }, - { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { (void*)&exit_on_keydown }, "exit on key down", "" }, - { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { (void*)&exit_on_mousedown }, "exit on mouse down", "" }, - { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&loop }, "set number of times the playback shall be looped", "loop count" }, - { "framedrop", OPT_BOOL | OPT_EXPERT, { (void*)&framedrop }, "drop frames when cpu is too slow", "" }, - { "infbuf", OPT_BOOL | OPT_EXPERT, { (void*)&infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, - { "window_title", OPT_STRING | HAS_ARG, { (void*)&window_title }, "set window title", "window title" }, + { "autoexit", OPT_BOOL | OPT_EXPERT, { &autoexit }, "exit at the end", "" }, + { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { &exit_on_keydown }, "exit on key down", "" }, + { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { &exit_on_mousedown }, "exit on mouse down", "" }, + { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, { &loop }, "set number of times the playback shall be looped", "loop count" }, + { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" }, + { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, + { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" }, #if CONFIG_AVFILTER - { "vf", OPT_STRING | HAS_ARG, { (void*)&vfilters }, "video filters", "filter list" }, + { "vf", OPT_STRING | HAS_ARG, { &vfilters }, "video filters", "filter list" }, #endif - { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { (void*)&rdftspeed }, "rdft speed", "msecs" }, - { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { (void*)opt_default }, "generic catch all option", "" }, + { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" }, + { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { opt_default }, "generic catch all option", "" }, { "i", 0, { NULL }, "avconv compatibility dummy option", ""}, { NULL, }, }; From 1648a508fabcbdcefd091fcd7c324ba973437858 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 5 Sep 2012 16:42:57 +0200 Subject: [PATCH 8/9] x86: dsputil: Move specific optimization settings out of global init function They belong in the init functions specific to each CPU capability. --- libavcodec/x86/dsputil_mmx.c | 59 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index f3ee342d72..136a5b1ee3 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2589,6 +2589,21 @@ static void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx, int mm_flags) SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx); SET_HPEL_FUNCS(avg, 1, 8, mmx); SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx); + + switch (avctx->idct_algo) { + case FF_IDCT_AUTO: + case FF_IDCT_SIMPLEMMX: + c->idct_put = ff_simple_idct_put_mmx; + c->idct_add = ff_simple_idct_add_mmx; + c->idct = ff_simple_idct_mmx; + c->idct_permutation_type = FF_SIMPLE_IDCT_PERM; + break; + case FF_IDCT_XVIDMMX: + c->idct_put = ff_idct_xvid_mmx_put; + c->idct_add = ff_idct_xvid_mmx_add; + c->idct = ff_idct_xvid_mmx; + break; + } } #if ARCH_X86_32 || !HAVE_YASM @@ -2656,6 +2671,12 @@ static void dsputil_init_mmx2(DSPContext *c, AVCodecContext *avctx, } } + if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) { + c->idct_put = ff_idct_xvid_mmx2_put; + c->idct_add = ff_idct_xvid_mmx2_add; + c->idct = ff_idct_xvid_mmx2; + } + if (CONFIG_VP3_DECODER && (avctx->codec_id == AV_CODEC_ID_VP3 || avctx->codec_id == AV_CODEC_ID_THEORA)) { c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_exact_mmx2; @@ -2885,6 +2906,13 @@ static void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx, H264_QPEL_FUNCS(3, 2, sse2); H264_QPEL_FUNCS(3, 3, sse2); } + + if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) { + c->idct_put = ff_idct_xvid_sse2_put; + c->idct_add = ff_idct_xvid_sse2_add; + c->idct = ff_idct_xvid_sse2; + c->idct_permutation_type = FF_SSE2_IDCT_PERM; + } #endif /* HAVE_INLINE_ASM */ #if HAVE_YASM @@ -3011,37 +3039,8 @@ void ff_dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx) c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov; #endif - if (mm_flags & AV_CPU_FLAG_MMX) { -#if HAVE_INLINE_ASM - const int idct_algo = avctx->idct_algo; - - if (avctx->bits_per_raw_sample <= 8) { - if (idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_SIMPLEMMX) { - c->idct_put = ff_simple_idct_put_mmx; - c->idct_add = ff_simple_idct_add_mmx; - c->idct = ff_simple_idct_mmx; - c->idct_permutation_type = FF_SIMPLE_IDCT_PERM; - } else if (idct_algo == FF_IDCT_XVIDMMX) { - if (mm_flags & AV_CPU_FLAG_SSE2) { - c->idct_put = ff_idct_xvid_sse2_put; - c->idct_add = ff_idct_xvid_sse2_add; - c->idct = ff_idct_xvid_sse2; - c->idct_permutation_type = FF_SSE2_IDCT_PERM; - } else if (mm_flags & AV_CPU_FLAG_MMXEXT) { - c->idct_put = ff_idct_xvid_mmx2_put; - c->idct_add = ff_idct_xvid_mmx2_add; - c->idct = ff_idct_xvid_mmx2; - } else { - c->idct_put = ff_idct_xvid_mmx_put; - c->idct_add = ff_idct_xvid_mmx_add; - c->idct = ff_idct_xvid_mmx; - } - } - } -#endif /* HAVE_INLINE_ASM */ - + if (mm_flags & AV_CPU_FLAG_MMX) dsputil_init_mmx(c, avctx, mm_flags); - } if (mm_flags & AV_CPU_FLAG_MMXEXT) dsputil_init_mmx2(c, avctx, mm_flags); From 55e778bebd6352977eebe406b522e2e9aed7ce35 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 10 Sep 2012 21:15:09 +0200 Subject: [PATCH 9/9] rtpdec_jpeg: Add support for default quantizers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generate quantization tables when they are not present in the first chunk. Signed-off-by: Martin Storsjö --- libavformat/rtpdec_jpeg.c | 50 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c index c77ecbfdef..671763d289 100644 --- a/libavformat/rtpdec_jpeg.c +++ b/libavformat/rtpdec_jpeg.c @@ -33,6 +33,28 @@ struct PayloadContext { int hdr_size; ///< size of the current frame header }; +static const uint8_t default_quantizers[128] = { + /* luma table */ + 16, 11, 12, 14, 12, 10, 16, 14, + 13, 14, 18, 17, 16, 19, 24, 40, + 26, 24, 22, 22, 24, 49, 35, 37, + 29, 40, 58, 51, 61, 60, 57, 51, + 56, 55, 64, 72, 92, 78, 64, 68, + 87, 69, 55, 56, 80, 109, 81, 87, + 95, 98, 103, 104, 103, 62, 77, 113, + 121, 112, 100, 120, 92, 101, 103, 99, + + /* chroma table */ + 17, 18, 18, 24, 21, 24, 47, 26, + 26, 47, 99, 66, 56, 66, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 +}; + static PayloadContext *jpeg_new_context(void) { return av_mallocz(sizeof(PayloadContext)); @@ -170,6 +192,27 @@ static int jpeg_create_header(uint8_t *buf, int size, uint32_t type, uint32_t w, return put_bits_count(&pbc) / 8; } +static void create_default_qtables(uint8_t *qtables, uint8_t q) +{ + int factor = q; + int i; + + factor = av_clip(q, 1, 99); + + if (q < 50) + q = 5000 / factor; + else + q = 200 - factor * 2; + + for (i = 0; i < 128; i++) { + int val = (default_quantizers[i] * q + 50) / 100; + + /* Limit the quantizers to 1 <= q <= 255. */ + val = av_clip(val, 1, 255); + qtables[i] = val; + } +} + static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, int flags) @@ -238,6 +281,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, if (off == 0) { /* Start of JPEG data packet. */ + uint8_t new_qtables[128]; uint8_t hdr[1024]; /* Skip the current frame in case of the end packet @@ -249,9 +293,9 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, jpeg->timestamp = *timestamp; if (!qtables) { - av_log(ctx, AV_LOG_ERROR, - "Unimplemented default quantization tables.\n"); - return AVERROR_PATCHWELCOME; + create_default_qtables(new_qtables, q); + qtables = new_qtables; + qtable_len = sizeof(new_qtables); } /* Generate a frame and scan headers that can be prepended to the