Re: [FFmpeg-devel] [PATCH 14/14] videotoolbox: remove opengl compatibility attribute
On 12/16/2017 04:19 PM, Wang Bin wrote: > 2017-12-16 15:33 GMT+08:00 Xiaolei Yu : >> On 12/16/2017 02:07 PM, Wang Bin wrote: >>> 2017-12-16 2:52 GMT+08:00 wm4 : On Fri, 15 Dec 2017 15:02:44 +0800 wbse...@gmail.com wrote: > From: wang-bin > > 1. a cvpixelbuffer backed by iosurface can always be converted to an > opengl texture, using CGLTexImageIOSurface2D for macOS, and undocumented > api texImageIOSurface(which is internally used by public api > CVOpenGLESTextureCacheCreateTextureFromImage) for iOS4.0+. > 2. enabling the attribute can slow down decoding speed a lot. I tested > many video clips on my macbook air. for example: ffmpeg -ss 00:00:00 -t > 00:03:00 -hwaccel videotoolbox -an -i big_buck_bunny_1080p_h264.mov -f > null ->/dev/null, result with the attribute > enabled: frame= 2082 fps= 85 q=-0.0 Lsize=N/A time=00:03:00.00 > bitrate=N/A speed=7.34x > disabled: frame= 2031 fps=104 q=-0.0 Lsize=N/A time=00:03:00.00 > bitrate=N/A speed=9.22x > --- > libavcodec/videotoolbox.c | 5 - > 1 file changed, 5 deletions(-) > > diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c > index 9d2f0afa20..24631684d7 100644 > --- a/libavcodec/videotoolbox.c > +++ b/libavcodec/videotoolbox.c > @@ -664,11 +664,6 @@ static CFDictionaryRef > videotoolbox_buffer_attributes_create(int width, > CFDictionarySetValue(buffer_attributes, > kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); > CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w); > CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h); > -#if TARGET_OS_IPHONE > -CFDictionarySetValue(buffer_attributes, > kCVPixelBufferOpenGLESCompatibilityKey, kCFBooleanTrue); > -#else > -CFDictionarySetValue(buffer_attributes, > kCVPixelBufferIOSurfaceOpenGLTextureCompatibilityKey, kCFBooleanTrue); > -#endif > > CFRelease(io_surface_properties); > CFRelease(cv_pix_fmt); Does this have a negative effect on compatibility or performance? (In both cases I'm asking about the case when actually using GL rendering.) >>> >>> Disabling the attribute improves performance in my tests. I can not >>> find any document about these keys. What i know is the decoded >>> cvpixelbuffer is backed by iosurface, and the api to create texture >>> from iosurface is available since macOS10.6 >> >> Maybe you can add a flag to make them optional? >> They are documented at: >> https://developer.apple.com/documentation/corevideo/kcvpixelbufferopenglescompatibilitykey >> https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfaceopengltexturecompatibilitykey >> >> Things may still work without them but I would like to follow the >> documentation whenever possible. And I think iOS DOES require the flag for >> those buffers to be consumed through GLES. >> > > Your links explain nothing. iOS does not need it as mentioned in the > patch. I tested on iphone4s+iOS9 and some new devices. Will find time to test this week. VTDecompressionOutputCallback actually returns a CVImageBuffer and blindly casting it to a CVPixelBuffer is dangerous. I will test if the type ids of the output are affected with different key combinations. > >> Pure speculation here. GPU texture units usually require special memory >> layouts that may be suboptimal for the decoder. When these constraints are >> not met either the driver has to perform the conversion or you pay the >> penalty at access time. > > Not sure about memory layout. The fact is on mac the performance is > much better without it. No difference on ios. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 07/25] avfilter: negotiate color_range between filters
On Sat, Dec 16, 2017 at 11:12:27AM +0100, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > fftools/ffmpeg.c| 2 ++ > fftools/ffmpeg.h| 1 + > fftools/ffmpeg_filter.c | 57 +++--- > fftools/ffmpeg_opt.c| 2 ++ > libavcodec/utils.c | 11 +++ > libavfilter/avfilter.c | 9 -- > libavfilter/avfilter.h | 4 ++- > libavfilter/avfiltergraph.c | 53 > libavfilter/buffersink.c| 16 ++ > libavfilter/buffersink.h| 1 + > libavfilter/buffersrc.c | 4 +++ > libavfilter/formats.c | 75 > ++--- > libavfilter/formats.h | 31 +++ > libavfilter/internal.h | 11 +++ > libavfilter/vf_format.c | 46 ++- > libavfilter/vf_noise.c | 6 +++- > libavfilter/vf_scale.c | 17 -- > libavfilter/vsrc_testsrc.c | 15 +++-- > tests/fate/filter-video.mak | 2 +- > tests/fate/pixlet.mak | 2 +- > 20 files changed, 343 insertions(+), 22 deletions(-) This causes a segfault ./ffmpeg -f lavfi -i "amovie=fate-suite/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv,asplit=3[out1][a][b]; [a]showwaves=s=340x240,pad=iw:ih*2[waves]; [b]showspectrum=s=340x240[spectrum]; [waves][spectrum] overlay=0:h [out0]" -t 0.1 -qscale 2 waves.avi Program received signal SIGSEGV, Segmentation fault. 0x00476a7f in query_formats (graph=0x21d1f80, log_ctx=0x21d10e0) at libavfilter/avfiltergraph.c:607 607 av_assert0( inlink-> in_color_ranges->refcount > 0); (gdb) bt #0 0x00476a7f in query_formats (graph=0x21d1f80, log_ctx=0x21d10e0) at libavfilter/avfiltergraph.c:607 #1 0x004789ce in graph_config_formats (graph=0x21d1f80, log_ctx=0x21d10e0) at libavfilter/avfiltergraph.c:1216 #2 0x00478ea0 in avfilter_graph_config (graphctx=0x21d1f80, log_ctx=0x21d10e0) at libavfilter/avfiltergraph.c:1327 #3 0x004418ad in lavfi_read_header (avctx=0x21d10e0) at libavdevice/lavfi.c:302 #4 0x007c1acd in avformat_open_input (ps=0x7fffdbc0, filename=0x7fffe5d4 "amovie=fate-suite/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv,asplit=3[out1][a][b]; [a]showwaves=s=340x240,pad=iw:ih*2[waves]; [b]showspectrum=s=340x240[spectrum]"..., fmt=0x192be40 , options=0x21d0dc8) at libavformat/utils.c:600 #5 0x0041524f in open_input_file (o=0x7fffdcc0, filename=0x7fffe5d4 "amovie=fate-suite/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv,asplit=3[out1][a][b]; [a]showwaves=s=340x240,pad=iw:ih*2[waves]; [b]showspectrum=s=340x240[spectrum]"...) at fftools/ffmpeg_opt.c:1070 #6 0x0041efb8 in open_files (l=0x21d0d78, inout=0x12004b7 "input", open_file=0x414903 ) at fftools/ffmpeg_opt.c:3299 #7 0x0041f14a in ffmpeg_parse_options (argc=10, argv=0x7fffe2d8) at fftools/ffmpeg_opt.c:3339 #8 0x0043d5fd in main (argc=10, argv=0x7fffe2d8) at fftools/ffmpeg.c:4818 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 13/25] avcodec/mjpegenc: add support for non-YUVJ formats
On Sat, Dec 16, 2017 at 11:12:33AM +0100, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > libavcodec/mjpegenc.c| 5 - > tests/lavf-regression.sh | 2 +- > 2 files changed, 5 insertions(+), 2 deletions(-) this breaks jpg encoding, (looks like colorspace convert/negotiate failing somehow) for example: ./ffmpeg -ss 1 -i ~/tickets/4395/small_test2.dv -vframes 1 file.jpg fails with: [mjpeg @ 0x334dea0] colorspace not supported in jpeg Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! input should be here: http://samples.mplayerhq.hu/DV-raw/small_test2.dv [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 2/2] avformat/dashenc: Persistent HTTP connections supported as an option
From: Karthick Jeyapal --- doc/muxers.texi | 2 ++ libavformat/dashenc.c | 67 +-- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 3d0c7bf..d6415db 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -249,6 +249,8 @@ DASH-templated name to used for the media segments. Default is "chunk-stream$Rep URL of the page that will return the UTC timestamp in ISO format. Example: "https://time.akamai.com/?iso"; @item -http_user_agent @var{user_agent} Override User-Agent field in HTTP header. Applicable only for HTTP output. +@item -http_persistent @var{http_persistent} +Use persistent HTTP connections. Applicable only for HTTP output. @item -hls_playlist @var{hls_playlist} Generate HLS playlist files as well. The master playlist is generated with the filename master.m3u8. One media playlist file is generated for each stream with filenames media_0.m3u8, media_1.m3u8, etc. diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 5687530..e7d1a0d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -37,6 +37,9 @@ #include "avformat.h" #include "avio_internal.h" #include "hlsplaylist.h" +#if CONFIG_HTTP_PROTOCOL +#include "http.h" +#endif #include "internal.h" #include "isom.h" #include "os_support.h" @@ -103,7 +106,10 @@ typedef struct DASHContext { const char *utc_timing_url; const char *user_agent; int hls_playlist; +int http_persistent; int master_playlist_created; +AVIOContext *mpd_out; +AVIOContext *m3u8_out; } DASHContext; static struct codec_string { @@ -117,6 +123,36 @@ static struct codec_string { { 0, NULL } }; +static int dashenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, + AVDictionary **options) { +DASHContext *c = s->priv_data; +int http_base_proto = filename ? ff_is_http_proto(filename) : 0; +int err = AVERROR_MUXER_NOT_FOUND; +if (!*pb || !http_base_proto || !c->http_persistent) { +err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options); +#if CONFIG_HTTP_PROTOCOL +} else { +URLContext *http_url_context = ffio_geturlcontext(*pb); +av_assert0(http_url_context); +err = ff_http_do_new_request(http_url_context, filename); +#endif +} +return err; +} + +static void dashenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) { +DASHContext *c = s->priv_data; +int http_base_proto = filename ? ff_is_http_proto(filename) : 0; + +if (!http_base_proto || !c->http_persistent) { +ff_format_io_close(s, pb); +#if CONFIG_HTTP_PROTOCOL +} else { +avio_flush(*pb); +#endif +} +} + static void set_codec_str(AVFormatContext *s, AVCodecParameters *par, char *str, int size) { @@ -218,6 +254,8 @@ static void set_http_options(AVDictionary **options, DASHContext *c) { if (c->user_agent) av_dict_set(options, "user_agent", c->user_agent, 0); +if (c->http_persistent) +av_dict_set_int(options, "multiple_requests", 1, 0); } static void get_hls_playlist_name(char *playlist_name, int string_size, @@ -273,9 +311,10 @@ static void dash_free(AVFormatContext *s) av_freep(&c->streams); } -static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c, +static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatContext *s, int representation_id, int final) { +DASHContext *c = s->priv_data; int i, start_index = 0, start_number = 1; if (c->window_size) { start_index = FFMAX(os->nb_segments - c->window_size, 0); @@ -339,7 +378,6 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext int timescale = os->ctx->streams[0]->time_base.den; char temp_filename_hls[1024]; char filename_hls[1024]; -AVIOContext *out_hls = NULL; AVDictionary *http_opts = NULL; int target_duration = 0; int ret = 0; @@ -352,7 +390,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext snprintf(temp_filename_hls, sizeof(temp_filename_hls), use_rename ? "%s.tmp" : "%s", filename_hls); set_http_options(&http_opts, c); -avio_open2(&out_hls, temp_filename_hls, AVIO_FLAG_WRITE, NULL, &http_opts); +dashenc_io_open(s, &c->m3u8_out, temp_filename_hls, &http_opts); av_dict_free(&http_opts); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; @@ -361,15 +399,15 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext target_duration = hls_get_int_from_double(duration); } -ff_hls_write_playlist_header(out_hls, 6, -1, target_duration, +ff_hls_write_playlist_header(c->m3u8_out, 6, -1, targe
[FFmpeg-devel] [PATCH v2 1/2] avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-use
From: Karthick Jeyapal --- libavformat/hlsenc.c | 12 +++- libavformat/internal.h | 8 libavformat/utils.c| 5 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e3442c3..03d54c7 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -240,15 +240,10 @@ static int mkdir_p(const char *path) { return ret; } -static int is_http_proto(char *filename) { -const char *proto = avio_find_protocol_name(filename); -return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0; -} - static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, AVDictionary **options) { HLSContext *hls = s->priv_data; -int http_base_proto = filename ? is_http_proto(filename) : 0; +int http_base_proto = filename ? ff_is_http_proto(filename) : 0; int err = AVERROR_MUXER_NOT_FOUND; if (!*pb || !http_base_proto || !hls->http_persistent) { err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options); @@ -264,8 +259,7 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) { HLSContext *hls = s->priv_data; -int http_base_proto = filename ? is_http_proto(filename) : 0; - +int http_base_proto = filename ? ff_is_http_proto(filename) : 0; if (!http_base_proto || !hls->http_persistent || hls->key_info_file || hls->encrypt) { ff_format_io_close(s, pb); } else { @@ -275,7 +269,7 @@ static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c) { -int http_base_proto = is_http_proto(s->filename); +int http_base_proto = ff_is_http_proto(s->filename); if (c->method) { av_dict_set(options, "method", c->method, 0); diff --git a/libavformat/internal.h b/libavformat/internal.h index 36a5721..8f168c9 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -619,6 +619,14 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op void ff_format_io_close(AVFormatContext *s, AVIOContext **pb); /** + * Utility function to check if the file uses http or https protocol + * + * @param s AVFormatContext + * @param filename URL or file name to open for writing + */ +int ff_is_http_proto(char *filename); + +/** * Parse creation_time in AVFormatContext metadata if exists and warn if the * parsing fails. * diff --git a/libavformat/utils.c b/libavformat/utils.c index 84e4920..f18a7c8 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5459,6 +5459,11 @@ void ff_format_io_close(AVFormatContext *s, AVIOContext **pb) *pb = NULL; } +int ff_is_http_proto(char *filename) { +const char *proto = avio_find_protocol_name(filename); +return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0; +} + int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds) { AVDictionaryEntry *entry; -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Persistent HTTP connections supported as an option
On 12/15/17 9:36 PM, Karthick J wrote: From: Karthick Jeyapal --- libavformat/dashenc.c | 67 +-- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 5687530..e7d1a0d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -37,6 +37,9 @@ #include "avformat.h" #include "avio_internal.h" #include "hlsplaylist.h" +#if CONFIG_HTTP_PROTOCOL +#include "http.h" +#endif #include "internal.h" #include "isom.h" #include "os_support.h" @@ -103,7 +106,10 @@ typedef struct DASHContext { const char *utc_timing_url; const char *user_agent; int hls_playlist; +int http_persistent; int master_playlist_created; +AVIOContext *mpd_out; +AVIOContext *m3u8_out; } DASHContext; static struct codec_string { @@ -117,6 +123,36 @@ static struct codec_string { { 0, NULL } }; +static int dashenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, + AVDictionary **options) { +DASHContext *c = s->priv_data; +int http_base_proto = filename ? ff_is_http_proto(filename) : 0; +int err = AVERROR_MUXER_NOT_FOUND; +if (!*pb || !http_base_proto || !c->http_persistent) { +err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options); +#if CONFIG_HTTP_PROTOCOL +} else { +URLContext *http_url_context = ffio_geturlcontext(*pb); +av_assert0(http_url_context); +err = ff_http_do_new_request(http_url_context, filename); +#endif +} +return err; +} + +static void dashenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) { +DASHContext *c = s->priv_data; +int http_base_proto = filename ? ff_is_http_proto(filename) : 0; + +if (!http_base_proto || !c->http_persistent) { +ff_format_io_close(s, pb); +#if CONFIG_HTTP_PROTOCOL +} else { +avio_flush(*pb); +#endif +} +} + static void set_codec_str(AVFormatContext *s, AVCodecParameters *par, char *str, int size) { @@ -218,6 +254,8 @@ static void set_http_options(AVDictionary **options, DASHContext *c) { if (c->user_agent) av_dict_set(options, "user_agent", c->user_agent, 0); +if (c->http_persistent) +av_dict_set_int(options, "multiple_requests", 1, 0); } static void get_hls_playlist_name(char *playlist_name, int string_size, @@ -273,9 +311,10 @@ static void dash_free(AVFormatContext *s) av_freep(&c->streams); } -static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c, +static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatContext *s, int representation_id, int final) { +DASHContext *c = s->priv_data; int i, start_index = 0, start_number = 1; if (c->window_size) { start_index = FFMAX(os->nb_segments - c->window_size, 0); @@ -339,7 +378,6 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext int timescale = os->ctx->streams[0]->time_base.den; char temp_filename_hls[1024]; char filename_hls[1024]; -AVIOContext *out_hls = NULL; AVDictionary *http_opts = NULL; int target_duration = 0; int ret = 0; @@ -352,7 +390,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext snprintf(temp_filename_hls, sizeof(temp_filename_hls), use_rename ? "%s.tmp" : "%s", filename_hls); set_http_options(&http_opts, c); -avio_open2(&out_hls, temp_filename_hls, AVIO_FLAG_WRITE, NULL, &http_opts); +dashenc_io_open(s, &c->m3u8_out, temp_filename_hls, &http_opts); av_dict_free(&http_opts); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; @@ -361,15 +399,15 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext target_duration = hls_get_int_from_double(duration); } -ff_hls_write_playlist_header(out_hls, 6, -1, target_duration, +ff_hls_write_playlist_header(c->m3u8_out, 6, -1, target_duration, start_number, PLAYLIST_TYPE_NONE); -ff_hls_write_init_file(out_hls, os->initfile, c->single_file, +ff_hls_write_init_file(c->m3u8_out, os->initfile, c->single_file, os->init_range_length, os->init_start_pos); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; -ret = ff_hls_write_file_entry(out_hls, 0, c->single_file, +ret = ff_hls_write_file_entry(c->m3u8_out, 0, c->single_file, (double) seg->duration / timescale, 0, seg->range_length, seg->start_pos, NULL,
[FFmpeg-devel] avfilter/vf_limiter : add checkasm and AVX2 version
Hello, in attach patch to add a checkasm test for vf_limiter SIMD (8 and 16) the checkasm patch need to be apply after patch in discussion : "avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version" 007 : add ff_limiter_init func to init the dsp func 008 : checkasm patch can be test with ./tests/checkasm/checkasm --test=vf_limiter --bench or make fate-checkasm 009 : add AVX2 version Checkasm result limiter_8_c: 205.7 limiter_8_sse2: 34.2 limiter_8_avx2: 23.2 limiter_16_c: 113.9 limiter_16_sse4: 34.4 limiter_16_avx2: 23.7 Martin 0007-checkasm-vf_limiter-add-checkasm-test-for-8-and-16-l.patch Description: Binary data 0008-avfilter-x86-vf_limiter-create-macro-for-limiter-8-a.patch Description: Binary data 0009-avfilter-x86-vf_limiter-add-AVX2-version-for-limiter.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data
On Fri, Dec 15, 2017 at 02:24:17PM -0800, Jacob Trimble wrote: > >> + > >> +/** The ID of the key used to encrypt the packet. */ > >> +uint8_t key_id[16]; > >> + > >> +/** The initialization vector. */ > >> +uint8_t iv[16]; > > > > what happens if the key or iv is longer ? > > Both are specified by common encryption to be exactly that size. To > be able to be > longer would require an updated spec. Plus it avoids having to store a > dynamic > string somewhere in the side data. It is difficult to change side data in the future as it is part of the ABI Including a value representing the block size even if you only support 16 would make it less painfull if it needs to be extended in the future. [...] > > > > > >> + > >> +/** > >> + * The number of sub-samples in this packet. If 0, then the whole > >> sample > >> + * is encrypted. > >> + */ > >> +unsigned int subsample_count; > >> + > >> +struct { > >> + /** The number of bytes that are clear. */ > >> + unsigned int bytes_of_clear_data; > >> + > >> + /** > >> + * The number of bytes that are protected. If using pattern > >> encryption, > >> + * the pattern applies to only the protected bytes; if not using > >> pattern > >> + * encryption, all these bytes are encrypted. > >> + */ > >> + unsigned int bytes_of_protected_data; > >> +} *subsamples; > > > > Are these patterns random in practice ? > > if not they possibly would be better not repeated per packet > > They are unique per packet. > > For example, in H.264, certain NAL unit types should be kept in the clear, > while > others should be encrypted. Plus even for encrypted NAL units, the header > should be kept in the clear even when the payload is encrypted. ok [...] > @@ -1327,6 +1384,19 @@ enum AVPacketSideDataType { > */ > AV_PKT_DATA_A53_CC, > > +/** > + * This side data is encryption "initialization data". > + * For MP4 this is the entire 'pssh' box. > + * For WebM this is the key ID. > + */ > +AV_PKT_DATA_ENCRYPTION_INIT_DATA, So its basically like extradata is for a codec ? If so it should be defined similarly as opaque encryption scheme specific data. It should not be container specific. Data taken from one container should be storable in another if both support the features used thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version
On 12/16/17, Martin Vignali wrote: > 2017-12-16 14:48 GMT+01:00 Carl Eugen Hoyos : > >> 2017-12-16 14:17 GMT+01:00 Martin Vignali : >> >> > 002 : Checkasm test for lowpass_line >> >> The change to checkasm.mak contains unexpected tabs iiuc. >> > > New patch in attach > > >> I can confirm that avx is not faster than sse2 here. >> >> >> Thanks for testing, i will post a patch to remove avx version Please don't. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] avfilter/vf_interlace and vf_tinterlace : remove avx version
Hello, Following discussion "avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version" the AVX version seems to be slower than SSE Patch in attach remove it, for vf_interlace and vf_tinterlace (both use the same SIMD) Martin 0004-avfilter-vf_interlace-and-vf_tinterlace.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 08/25] fftools/ffplay: support only limited color range
On 12/16/17, Nicolas George wrote: > Marton Balint (2017-12-16): >> I am afraid this wont work, because ffplay supports full range RGB as >> well. >> Unless there is a way to specify allowed pixel format / color range >> combinations (which is the only way to mimic existing behaviour as far as >> I >> see), you have to use hacks like configure the filter graph once without a >> range restriction, and if you get an invalid pixel format / color range >> combination, you have to configure the graph again with the supported >> color >> range list for that pixel format, hoping that the pixel format will remain >> the same. > > It seems you are confirming something that I suspected and needed to > check, i.e. that negotiating range separately from pixel format (or at > least RGB / YUV) will not give satisfactory results. I fear a combined > negotiation will be necessary. Not really. This is just ffplay nuisance. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version
2017-12-16 14:48 GMT+01:00 Carl Eugen Hoyos : > 2017-12-16 14:17 GMT+01:00 Martin Vignali : > > > 002 : Checkasm test for lowpass_line > > The change to checkasm.mak contains unexpected tabs iiuc. > New patch in attach > I can confirm that avx is not faster than sse2 here. > > > Thanks for testing, i will post a patch to remove avx version Martin 0001-avfilter-vf_interlace-move-func-init-in.patch Description: Binary data 0002-checkasm-vf_interlace-add-test-for-lowpass_line-8-an.patch Description: Binary data 0003-avfilter-vf_interlace-add-AVX2-for-lowpass_line-8-an.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 08/25] fftools/ffplay: support only limited color range
Marton Balint (2017-12-16): > I am afraid this wont work, because ffplay supports full range RGB as well. > Unless there is a way to specify allowed pixel format / color range > combinations (which is the only way to mimic existing behaviour as far as I > see), you have to use hacks like configure the filter graph once without a > range restriction, and if you get an invalid pixel format / color range > combination, you have to configure the graph again with the supported color > range list for that pixel format, hoping that the pixel format will remain > the same. It seems you are confirming something that I suspected and needed to check, i.e. that negotiating range separately from pixel format (or at least RGB / YUV) will not give satisfactory results. I fear a combined negotiation will be necessary. Regards, -- Nicolas George ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/hevcdsp_template: Fix undefined shift in put_hevc_qpel_bi_w_hv()
On Fri, Dec 15, 2017 at 07:45:19PM +0100, Michael Niedermayer wrote: > Fixes: runtime error: left shift of negative value -3 > Fixes: 4524/clusterfuzz-testcase-minimized-6055590120914944 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/hevcdsp_template.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply the patchset [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 03/14] configure: fix probing armv6zk
On Fri, Dec 15, 2017 at 03:05:13PM +0800, wbse...@gmail.com wrote: > From: wang-bin > > clang reports 6kz: https://reviews.llvm.org/D14568 > --- > configure | 1 + > 1 file changed, 1 insertion(+) will apply thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc: enable hwaccel_flags option
On Mon, Oct 09, 2017 at 10:24:30PM +, Jun Zhao wrote: > ffmpeg | branch: master | Jun Zhao | Mon Oct 9 > 15:49:58 2017 +0800| [71e2ec017a1b51987d50b97d48b6a6114a58507d] | committer: > Mark Thompson > > lavc: enable hwaccel_flags option > > Enable per-stream hwaccel_flags. > > Signed-off-by: Jun Zhao > Signed-off-by: Mark Thompson > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71e2ec017a1b51987d50b97d48b6a6114a58507d > --- > > libavcodec/options_table.h | 4 > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h > index 12712fb541..2ac37c3ff1 100644 > --- a/libavcodec/options_table.h > +++ b/libavcodec/options_table.h > @@ -576,6 +576,10 @@ static const AVOption avcodec_options[] = { > {"pixel_format", "set pixel format", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, > {.i64=AV_PIX_FMT_NONE}, -1, INT_MAX, 0 }, > {"video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, > {.str=NULL}, 0, INT_MAX, 0 }, > {"max_pixels", "Maximum number of pixels", OFFSET(max_pixels), > AV_OPT_TYPE_INT64, {.i64 = INT_MAX }, 0, INT_MAX, A|V|S|D|E }, > +{"hwaccel_flags", NULL, OFFSET(hwaccel_flags), AV_OPT_TYPE_FLAGS, {.i64 = > AV_HWACCEL_FLAG_IGNORE_LEVEL }, 0, UINT_MAX, V|D, "hwaccel_flags"}, > +{"ignore_level", "ignore level even if the codec level used is unknown or > higher than the maximum supported level reported by the hardware driver", 0, > AV_OPT_TYPE_CONST, { .i64 = AV_HWACCEL_FLAG_IGNORE_LEVEL }, INT_MIN, INT_MAX, > V | D, "hwaccel_flags" }, > +{"allow_high_depth", "allow to output YUV pixel formats with a different > chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, > AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, > INT_MAX, V | D, "hwaccel_flags"}, > +{"allow_profile_mismatch", "attempt to decode anyway if HW accelerated > decoder's supported profiles do not exactly match the stream", 0, > AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, > INT_MAX, V | D, "hwaccel_flags"}, These flags are not documented in doc/* as other flags are, it seems it was forgotten to document them. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] configure: Fix case of static libmp3lame
Fixes #6918. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index d5bbb5b..20ca792 100755 --- a/configure +++ b/configure @@ -5853,7 +5853,7 @@ enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" kv enabled libmfx&& { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit || { require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } enabled libmodplug&& require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load -enabled libmp3lame&& require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame +enabled libmp3lame&& require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame -lm enabled libmysofa && require libmysofa "mysofa.h" mysofa_load -lmysofa $zlib_extralibs enabled libnpp&& { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc || check_lib libnpp npp.h nppGetLibVersion -lnppi -lnppc || -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH][RFC] avcodec/dpxenc: add option to force color transfer characteristics
2017-12-15 22:22 GMT+01:00 Tobias Rapp : > +{ "dpx_color_trc", "Transfer Characteristics", OFFSET(color_trc), > AV_OPT_TYPE_INT, { .i64 = DPX_TRC_UNDEFINED }, DPX_TRC_UNDEFINED, > DPX_TRC_NB-1, VE, "trc" }, This seems wrong to me, we have colour characteristics in general code. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 07/14] mediacodec: check whether cropping is set before use
On Sat, Dec 16, 2017 at 07:20:53PM +0800, Wang Bin wrote: > 2017-12-16 17:12 GMT+08:00 Matthieu Bouron : > > On Sat, Dec 16, 2017 at 01:40:18PM +0800, Wang Bin wrote: > >> > > +width = s->crop_right + 1 - s->crop_left; > >> > > +else > >> > > +width = s->width; > >> > > > >> > > av_log(avctx, AV_LOG_INFO, > >> > > "Output crop parameters top=%d bottom=%d left=%d right=%d, " > >> > > >> > On which device does this happen ? > >> > >> > >> None of my devices have such problem. It happens if replace jni by ndk > >> mediacodec functions(maybe another patch later). original code: > >> https://github.com/aosp-mirror/platform_frameworks_base/blob/master/media/java/android/media/MediaCodec.java#L190 > > > > OK. I will soon apply the patch. > > > > I'm however not in favor of replacing the MediaCodec jni code by its ndk > > counterpart now as it would drop compatibility with Android 4.4. > > Just load libmediandk.so and resolve symbols at runtime, and fallback > to jni if the library does not exist, i.e. on android < 5.0 I don't really want to maintain both code paths as it will add complexity. If we are to use the ndk I would also prefer to link against the library directly instead of loading its symbols at runtime. Note: I'm not against switching to the NDK in the future as it would allow us to remove the jni dependency, but it's a bit too early IMHO. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version
2017-12-16 14:17 GMT+01:00 Martin Vignali : > 002 : Checkasm test for lowpass_line The change to checkasm.mak contains unexpected tabs iiuc. I can confirm that avx is not faster than sse2 here. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 08/25] fftools/ffplay: support only limited color range
On 12/16/17, Marton Balint wrote: > > > On Sat, 16 Dec 2017, Paul B Mahol wrote: > >> Signed-off-by: Paul B Mahol >> --- >> fftools/ffplay.c | 6 +- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/fftools/ffplay.c b/fftools/ffplay.c >> index 10a917194d..f023c81575 100644 >> --- a/fftools/ffplay.c >> +++ b/fftools/ffplay.c >> @@ -1822,6 +1822,7 @@ fail: >> static int configure_video_filters(AVFilterGraph *graph, VideoState *is, >> const char *vfilters, AVFrame *frame) >> { >> enum AVPixelFormat pix_fmts[FF_ARRAY_ELEMS(sdl_texture_format_map)]; >> +enum AVColorRange color_ranges[2] = { AVCOL_RANGE_MPEG, >> AVCOL_RANGE_UNSPECIFIED }; >> char sws_flags_str[512] = ""; >> char buffersrc_args[256]; >> int ret; >> @@ -1876,7 +1877,10 @@ static int configure_video_filters(AVFilterGraph >> *graph, VideoState *is, const c >> if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts, >> AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0) >> goto fail; >> >> -last_filter = filt_out; >> +if ((ret = av_opt_set_int_list(filt_out, "color_ranges", >> color_ranges, AVCOL_RANGE_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 0) >> +goto fail; >> + >> + last_filter = filt_out; > > I am afraid this wont work, because ffplay supports full range RGB as > well. Unless there is a way to specify allowed pixel format / color range > combinations (which is the only way to mimic existing behaviour as far as > I see), you have to use hacks like configure the filter graph once without > a range restriction, and if you get an invalid pixel format / color range > combination, you have to configure the graph again with the supported > color range list for that pixel format, hoping that the pixel format will > remain the same. If you actually checked output, it will appear same as before patchset. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version
Hello, In attach patch to add a checkasm test, for lowpass_line (8 and 16) and AVX2 version for lowpass_line (8 and 16) 001 : Modify init part of vf_interlace (add ff_interlace_init and modify ff_interlace_init_x86) 002 : Checkasm test for lowpass_line can be test with ./tests/checkasm/checkasm --test=vf_interlace --bench or make fate-checkasm 003 : AVX2 version for lowpass_line (8 and 16) For the checkasm test, i add an align test (related to ticket 6491) but i only "unalign" the "mref value" (if i unalign src in this test, i have a crash) I can't find a "real" filter command line who reproduce the same crash (if someone have a command line example for that, i will modify the checkasm and the asm) Checkasm result : (in my tests the AVX version is always slower, than SSE version (not sure it's interested to keep AVX version) ./tests/checkasm/checkasm --test=vf_interlace --bench benchmarking with native FFmpeg timers nop: 36.2 checkasm: using random seed 1323076929 SSE2: - vf_interlace.lowpass_line_8 [OK] - vf_interlace.lowpass_line_16 [OK] AVX: - vf_interlace.lowpass_line_8 [OK] - vf_interlace.lowpass_line_16 [OK] AVX2: - vf_interlace.lowpass_line_8 [OK] - vf_interlace.lowpass_line_16 [OK] checkasm: all 6 tests passed lowpass_line_8_c: 311.2 lowpass_line_8_sse2: 44.4 lowpass_line_8_avx: 46.9 lowpass_line_8_avx2: 26.7 lowpass_line_16_c: 182.9 lowpass_line_16_sse2: 44.4 lowpass_line_16_avx: 48.4 lowpass_line_16_avx2: 28.2 Martin 0001-avfilter-vf_interlace-move-func-init-in.patch Description: Binary data 0002-checkasm-vf_interlace-add-test-for-lowpass_line-8-an.patch Description: Binary data 0003-avfilter-vf_interlace-add-AVX2-for-lowpass_line-8-an.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 13/14] mmal: add option copy_frame to support retrieving sw frames w/o copy
On Sat, 16 Dec 2017 20:26:56 +0800 Wang Bin wrote: > 2017-12-16 19:47 GMT+08:00 wm4 : > > On Sat, 16 Dec 2017 13:48:05 +0800 > > Wang Bin wrote: > > > >> 2017-12-16 2:50 GMT+08:00 wm4 : > >> > On Fri, 15 Dec 2017 15:05:50 +0800 > >> > wbse...@gmail.com wrote: > >> > > >> >> From: wang-bin > >> >> > >> >> mmal buffer->data is already in host memory. AFAIK decoders implemented > >> >> in omx must > >> >> be configured to output frames to either memory or something directly > >> >> used by renderer, > >> >> for example mediacodec surface, mmal buffer and omxil eglimage. > >> >> test result: big buck bunny 1080p fps increases from about 100 to 110 > >> >> if copy_frame is > >> >> turned off > >> >> --- > >> >> libavcodec/mmaldec.c | 31 +++ > >> >> 1 file changed, 23 insertions(+), 8 deletions(-) > >> >> > >> >> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c > >> >> index c1cfb09283..9cd6c6558f 100644 > >> >> --- a/libavcodec/mmaldec.c > >> >> +++ b/libavcodec/mmaldec.c > >> >> @@ -69,6 +69,7 @@ typedef struct MMALDecodeContext { > >> >> AVClass *av_class; > >> >> int extra_buffers; > >> >> int extra_decoder_buffers; > >> >> +int copy_frame; > >> >> > >> >> MMAL_COMPONENT_T *decoder; > >> >> MMAL_QUEUE_T *queue_decoded_frames; > >> >> @@ -139,7 +140,6 @@ static int ffmmal_set_ref(AVFrame *frame, FFPoolRef > >> >> *pool, > >> >> atomic_fetch_add_explicit(&ref->pool->refcount, 1, > >> >> memory_order_relaxed); > >> >> mmal_buffer_header_acquire(buffer); > >> >> > >> >> -frame->format = AV_PIX_FMT_MMAL; > >> >> frame->data[3] = (uint8_t *)ref->buffer; > >> >> return 0; > >> >> } > >> >> @@ -650,20 +650,34 @@ static int ffmal_copy_frame(AVCodecContext > >> >> *avctx, AVFrame *frame, > >> >> > >> >> if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) > >> >> goto done; > >> >> +frame->format = AV_PIX_FMT_MMAL; > >> >> } else { > >> >> int w = FFALIGN(avctx->width, 32); > >> >> int h = FFALIGN(avctx->height, 16); > >> >> uint8_t *src[4]; > >> >> int linesize[4]; > >> >> > >> >> -if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) > >> >> -goto done; > >> >> +if (ctx->copy_frame) { > >> >> +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) > >> >> +goto done; > >> >> > >> >> -av_image_fill_arrays(src, linesize, > >> >> - buffer->data + > >> >> buffer->type->video.offset[0], > >> >> - avctx->pix_fmt, w, h, 1); > >> >> -av_image_copy(frame->data, frame->linesize, src, linesize, > >> >> - avctx->pix_fmt, avctx->width, avctx->height); > >> >> +av_image_fill_arrays(src, linesize, > >> >> +buffer->data + > >> >> buffer->type->video.offset[0], > >> >> +avctx->pix_fmt, w, h, 1); > >> >> +av_image_copy(frame->data, frame->linesize, src, linesize, > >> >> +avctx->pix_fmt, avctx->width, avctx->height); > >> >> +} else { > >> >> +if ((ret = ff_decode_frame_props(avctx, frame)) < 0) > >> >> +goto done; > >> >> +/* buffer->type->video.offset/pitch[i]; is always 0 */ > >> >> +av_image_fill_arrays(src, linesize, > >> >> +buffer->data + > >> >> buffer->type->video.offset[0], > >> >> +avctx->pix_fmt, w, h, 1); > >> >> +if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < > >> >> 0) > >> >> +goto done; > >> >> +memcpy(frame->data, src, sizeof(src)); > >> >> +memcpy(frame->linesize, linesize, sizeof(linesize)); > >> >> +} > >> >> } > >> >> > >> >> frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : > >> >> buffer->pts; > >> >> @@ -842,6 +856,7 @@ AVHWAccel ff_wmv3_mmal_hwaccel = { > >> >> static const AVOption options[]={ > >> >> {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, > >> >> extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, > >> >> {"extra_decoder_buffers", "extra MMAL internal buffered frames", > >> >> offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, > >> >> {.i64 = 10}, 0, 256, 0}, > >> >> +{"copy_frame", "copy deocded data to avframe", > >> >> offsetof(MMALDecodeContext, copy_frame), AV_OPT_TYPE_BOOL, {.i64 = 1}, > >> >> 0, 256, 0}, > >> >> {NULL} > >> >> }; > >> >> > >> > > >> > Didn't check too closely what exactly the patch does, but adding an > >> > option for it sounds very wrong. The user select in the get_format > >> > callback whether a GPU surface is output (MMAL pixfmt), or software. > >> > >> Avoid copying data from mmal buffer->data to avframe data. Instead, > >> just fill strides and addr
Re: [FFmpeg-devel] [PATCH 13/14] mmal: add option copy_frame to support retrieving sw frames w/o copy
2017-12-16 19:47 GMT+08:00 wm4 : > On Sat, 16 Dec 2017 13:48:05 +0800 > Wang Bin wrote: > >> 2017-12-16 2:50 GMT+08:00 wm4 : >> > On Fri, 15 Dec 2017 15:05:50 +0800 >> > wbse...@gmail.com wrote: >> > >> >> From: wang-bin >> >> >> >> mmal buffer->data is already in host memory. AFAIK decoders implemented >> >> in omx must >> >> be configured to output frames to either memory or something directly >> >> used by renderer, >> >> for example mediacodec surface, mmal buffer and omxil eglimage. >> >> test result: big buck bunny 1080p fps increases from about 100 to 110 if >> >> copy_frame is >> >> turned off >> >> --- >> >> libavcodec/mmaldec.c | 31 +++ >> >> 1 file changed, 23 insertions(+), 8 deletions(-) >> >> >> >> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c >> >> index c1cfb09283..9cd6c6558f 100644 >> >> --- a/libavcodec/mmaldec.c >> >> +++ b/libavcodec/mmaldec.c >> >> @@ -69,6 +69,7 @@ typedef struct MMALDecodeContext { >> >> AVClass *av_class; >> >> int extra_buffers; >> >> int extra_decoder_buffers; >> >> +int copy_frame; >> >> >> >> MMAL_COMPONENT_T *decoder; >> >> MMAL_QUEUE_T *queue_decoded_frames; >> >> @@ -139,7 +140,6 @@ static int ffmmal_set_ref(AVFrame *frame, FFPoolRef >> >> *pool, >> >> atomic_fetch_add_explicit(&ref->pool->refcount, 1, >> >> memory_order_relaxed); >> >> mmal_buffer_header_acquire(buffer); >> >> >> >> -frame->format = AV_PIX_FMT_MMAL; >> >> frame->data[3] = (uint8_t *)ref->buffer; >> >> return 0; >> >> } >> >> @@ -650,20 +650,34 @@ static int ffmal_copy_frame(AVCodecContext *avctx, >> >> AVFrame *frame, >> >> >> >> if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) >> >> goto done; >> >> +frame->format = AV_PIX_FMT_MMAL; >> >> } else { >> >> int w = FFALIGN(avctx->width, 32); >> >> int h = FFALIGN(avctx->height, 16); >> >> uint8_t *src[4]; >> >> int linesize[4]; >> >> >> >> -if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) >> >> -goto done; >> >> +if (ctx->copy_frame) { >> >> +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) >> >> +goto done; >> >> >> >> -av_image_fill_arrays(src, linesize, >> >> - buffer->data + >> >> buffer->type->video.offset[0], >> >> - avctx->pix_fmt, w, h, 1); >> >> -av_image_copy(frame->data, frame->linesize, src, linesize, >> >> - avctx->pix_fmt, avctx->width, avctx->height); >> >> +av_image_fill_arrays(src, linesize, >> >> +buffer->data + >> >> buffer->type->video.offset[0], >> >> +avctx->pix_fmt, w, h, 1); >> >> +av_image_copy(frame->data, frame->linesize, src, linesize, >> >> +avctx->pix_fmt, avctx->width, avctx->height); >> >> +} else { >> >> +if ((ret = ff_decode_frame_props(avctx, frame)) < 0) >> >> +goto done; >> >> +/* buffer->type->video.offset/pitch[i]; is always 0 */ >> >> +av_image_fill_arrays(src, linesize, >> >> +buffer->data + >> >> buffer->type->video.offset[0], >> >> +avctx->pix_fmt, w, h, 1); >> >> +if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) >> >> +goto done; >> >> +memcpy(frame->data, src, sizeof(src)); >> >> +memcpy(frame->linesize, linesize, sizeof(linesize)); >> >> +} >> >> } >> >> >> >> frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : >> >> buffer->pts; >> >> @@ -842,6 +856,7 @@ AVHWAccel ff_wmv3_mmal_hwaccel = { >> >> static const AVOption options[]={ >> >> {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, >> >> extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, >> >> {"extra_decoder_buffers", "extra MMAL internal buffered frames", >> >> offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, >> >> {.i64 = 10}, 0, 256, 0}, >> >> +{"copy_frame", "copy deocded data to avframe", >> >> offsetof(MMALDecodeContext, copy_frame), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, >> >> 256, 0}, >> >> {NULL} >> >> }; >> >> >> > >> > Didn't check too closely what exactly the patch does, but adding an >> > option for it sounds very wrong. The user select in the get_format >> > callback whether a GPU surface is output (MMAL pixfmt), or software. >> >> Avoid copying data from mmal buffer->data to avframe data. Instead, >> just fill strides and address of each plane in avframe, and add a >> reference to mmal buffer. > > Does it make sure to keep the mmal buffer pool alive then? Otherwise a > decoded AVFrame would become invalid after closing and destroying the > decoder. Yes. ffmmal_set_ref() is called like hw pixfmt code and mmal buffe
Re: [FFmpeg-devel] [PATCH 13/14] mmal: add option copy_frame to support retrieving sw frames w/o copy
On Sat, 16 Dec 2017 13:48:05 +0800 Wang Bin wrote: > 2017-12-16 2:50 GMT+08:00 wm4 : > > On Fri, 15 Dec 2017 15:05:50 +0800 > > wbse...@gmail.com wrote: > > > >> From: wang-bin > >> > >> mmal buffer->data is already in host memory. AFAIK decoders implemented in > >> omx must > >> be configured to output frames to either memory or something directly used > >> by renderer, > >> for example mediacodec surface, mmal buffer and omxil eglimage. > >> test result: big buck bunny 1080p fps increases from about 100 to 110 if > >> copy_frame is > >> turned off > >> --- > >> libavcodec/mmaldec.c | 31 +++ > >> 1 file changed, 23 insertions(+), 8 deletions(-) > >> > >> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c > >> index c1cfb09283..9cd6c6558f 100644 > >> --- a/libavcodec/mmaldec.c > >> +++ b/libavcodec/mmaldec.c > >> @@ -69,6 +69,7 @@ typedef struct MMALDecodeContext { > >> AVClass *av_class; > >> int extra_buffers; > >> int extra_decoder_buffers; > >> +int copy_frame; > >> > >> MMAL_COMPONENT_T *decoder; > >> MMAL_QUEUE_T *queue_decoded_frames; > >> @@ -139,7 +140,6 @@ static int ffmmal_set_ref(AVFrame *frame, FFPoolRef > >> *pool, > >> atomic_fetch_add_explicit(&ref->pool->refcount, 1, > >> memory_order_relaxed); > >> mmal_buffer_header_acquire(buffer); > >> > >> -frame->format = AV_PIX_FMT_MMAL; > >> frame->data[3] = (uint8_t *)ref->buffer; > >> return 0; > >> } > >> @@ -650,20 +650,34 @@ static int ffmal_copy_frame(AVCodecContext *avctx, > >> AVFrame *frame, > >> > >> if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) > >> goto done; > >> +frame->format = AV_PIX_FMT_MMAL; > >> } else { > >> int w = FFALIGN(avctx->width, 32); > >> int h = FFALIGN(avctx->height, 16); > >> uint8_t *src[4]; > >> int linesize[4]; > >> > >> -if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) > >> -goto done; > >> +if (ctx->copy_frame) { > >> +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) > >> +goto done; > >> > >> -av_image_fill_arrays(src, linesize, > >> - buffer->data + buffer->type->video.offset[0], > >> - avctx->pix_fmt, w, h, 1); > >> -av_image_copy(frame->data, frame->linesize, src, linesize, > >> - avctx->pix_fmt, avctx->width, avctx->height); > >> +av_image_fill_arrays(src, linesize, > >> +buffer->data + > >> buffer->type->video.offset[0], > >> +avctx->pix_fmt, w, h, 1); > >> +av_image_copy(frame->data, frame->linesize, src, linesize, > >> +avctx->pix_fmt, avctx->width, avctx->height); > >> +} else { > >> +if ((ret = ff_decode_frame_props(avctx, frame)) < 0) > >> +goto done; > >> +/* buffer->type->video.offset/pitch[i]; is always 0 */ > >> +av_image_fill_arrays(src, linesize, > >> +buffer->data + > >> buffer->type->video.offset[0], > >> +avctx->pix_fmt, w, h, 1); > >> +if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) > >> +goto done; > >> +memcpy(frame->data, src, sizeof(src)); > >> +memcpy(frame->linesize, linesize, sizeof(linesize)); > >> +} > >> } > >> > >> frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : > >> buffer->pts; > >> @@ -842,6 +856,7 @@ AVHWAccel ff_wmv3_mmal_hwaccel = { > >> static const AVOption options[]={ > >> {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, > >> extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, > >> {"extra_decoder_buffers", "extra MMAL internal buffered frames", > >> offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 > >> = 10}, 0, 256, 0}, > >> +{"copy_frame", "copy deocded data to avframe", > >> offsetof(MMALDecodeContext, copy_frame), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, > >> 256, 0}, > >> {NULL} > >> }; > >> > > > > Didn't check too closely what exactly the patch does, but adding an > > option for it sounds very wrong. The user select in the get_format > > callback whether a GPU surface is output (MMAL pixfmt), or software. > > Avoid copying data from mmal buffer->data to avframe data. Instead, > just fill strides and address of each plane in avframe, and add a > reference to mmal buffer. Does it make sure to keep the mmal buffer pool alive then? Otherwise a decoded AVFrame would become invalid after closing and destroying the decoder. Why would this need a new option? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 6/7] avfilter/vf_framerate: do not calculate scene change score multiple times for the same frame
On Sun, 10 Dec 2017, Marton Balint wrote: This speeds up the filter, and also fixes scene change detection score which is reduced based on the difference of the current MAFD to the preivous MAFD. Obviously if we compare two frames twice, the difference will be 0... Paul, you missed this one by mistake, or do you need more time to review? Thanks, Marton Signed-off-by: Marton Balint --- libavfilter/vf_framerate.c | 45 +++-- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index dd106f8e5b..5fffc2a172 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -71,6 +71,7 @@ typedef struct FrameRateContext { AVFrame *srce[N_SRCE]; ///< buffered source frames int64_t srce_pts_dest[N_SRCE]; ///< pts for source frames scaled to output timebase +double scre_score[N_SRCE]; ///< scene change score compared to the next scre frame int64_t pts;///< pts of frame we are working on int max; @@ -113,9 +114,11 @@ static void next_source(AVFilterContext *ctx) for (i = s->last; i > s->frst; i--) { ff_dlog(ctx, "next_source() copy %d to %d\n", i - 1, i); s->srce[i] = s->srce[i - 1]; +s->scre_score[i] = s->scre_score[i - 1]; } ff_dlog(ctx, "next_source() make %d null\n", s->frst); s->srce[s->frst] = NULL; +s->scre_score[s->frst] = -1.0; } static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t stride1, @@ -171,8 +174,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next ff_dlog(ctx, "get_scene_score()\n"); -if (crnt && -crnt->height == next->height && +if (crnt->height == next->height && crnt->width == next->width) { int64_t sad; double mafd, diff; @@ -304,21 +306,26 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs) } static int blend_frames(AVFilterContext *ctx, float interpolate, -AVFrame *copy_src1, AVFrame *copy_src2) +int src1, int src2) { FrameRateContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; double interpolate_scene_score = 0; -if ((s->flags & FRAMERATE_FLAG_SCD) && copy_src2) { -interpolate_scene_score = get_scene_score(ctx, copy_src1, copy_src2); +if ((s->flags & FRAMERATE_FLAG_SCD) && s->srce[src1] && s->srce[src2]) { +int i1 = src1 < src2 ? src1 : src2; +int i2 = src1 < src2 ? src2 : src1; +if (i2 == i1 + 1 && s->scre_score[i1] >= 0.0) +interpolate_scene_score = s->scre_score[i1]; +else +interpolate_scene_score = s->scre_score[i1] = get_scene_score(ctx, s->srce[i1], s->srce[i2]); ff_dlog(ctx, "blend_frames() interpolate scene score:%f\n", interpolate_scene_score); } // decide if the shot-change detection allows us to blend two frames -if (interpolate_scene_score < s->scene_score && copy_src2) { +if (interpolate_scene_score < s->scene_score && s->srce[src2]) { ThreadData td; -td.copy_src1 = copy_src1; -td.copy_src2 = copy_src2; +td.copy_src1 = s->srce[src1]; +td.copy_src2 = s->srce[src2]; td.src2_factor = fabsf(interpolate) * (1 << (s->bitdepth - 8)); td.src1_factor = s->max - td.src2_factor; @@ -340,8 +347,8 @@ static int process_work_frame(AVFilterContext *ctx, int stop) { FrameRateContext *s = ctx->priv; int64_t work_next_pts; -AVFrame *copy_src1; float interpolate; +int src1, src2; ff_dlog(ctx, "process_work_frame()\n"); @@ -385,28 +392,26 @@ static int process_work_frame(AVFilterContext *ctx, int stop) // calculate interpolation interpolate = ((s->pts - s->srce_pts_dest[s->crnt]) * 256.0 / s->average_srce_pts_dest_delta); ff_dlog(ctx, "process_work_frame() interpolate:%f/256\n", interpolate); -copy_src1 = s->srce[s->crnt]; +src1 = s->crnt; if (interpolate > s->interp_end) { ff_dlog(ctx, "process_work_frame() source is:NEXT\n"); -copy_src1 = s->srce[s->next]; +src1 = s->next; } if (s->srce[s->prev] && interpolate < -s->interp_end) { ff_dlog(ctx, "process_work_frame() source is:PREV\n"); -copy_src1 = s->srce[s->prev]; +src1 = s->prev; } // decide whether to blend two frames if ((interpolate >= s->interp_start && interpolate <= s->interp_end) || (interpolate <= -s->interp_start && interpolate >= -s->interp_end)) { -AVFrame *copy_src2; - if (interpolate > 0) { ff_dlog(ctx, "process_work_frame() interpolate source is:NEXT\n"); -copy_src2 = s->srce[s->next]; +src2 = s->next; } else { ff_dlog(ctx, "process_work_frame() interpolate source is:PREV\n"); -copy_src2 = s->srce[s->prev]; +src
Re: [FFmpeg-devel] [PATCH 08/25] fftools/ffplay: support only limited color range
On Sat, 16 Dec 2017, Paul B Mahol wrote: Signed-off-by: Paul B Mahol --- fftools/ffplay.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 10a917194d..f023c81575 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1822,6 +1822,7 @@ fail: static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters, AVFrame *frame) { enum AVPixelFormat pix_fmts[FF_ARRAY_ELEMS(sdl_texture_format_map)]; +enum AVColorRange color_ranges[2] = { AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }; char sws_flags_str[512] = ""; char buffersrc_args[256]; int ret; @@ -1876,7 +1877,10 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0) goto fail; -last_filter = filt_out; +if ((ret = av_opt_set_int_list(filt_out, "color_ranges", color_ranges, AVCOL_RANGE_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 0) +goto fail; + + last_filter = filt_out; I am afraid this wont work, because ffplay supports full range RGB as well. Unless there is a way to specify allowed pixel format / color range combinations (which is the only way to mimic existing behaviour as far as I see), you have to use hacks like configure the filter graph once without a range restriction, and if you get an invalid pixel format / color range combination, you have to configure the graph again with the supported color range list for that pixel format, hoping that the pixel format will remain the same. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 07/14] mediacodec: check whether cropping is set before use
2017-12-16 17:12 GMT+08:00 Matthieu Bouron : > On Sat, Dec 16, 2017 at 01:40:18PM +0800, Wang Bin wrote: >> > > +width = s->crop_right + 1 - s->crop_left; >> > > +else >> > > +width = s->width; >> > > >> > > av_log(avctx, AV_LOG_INFO, >> > > "Output crop parameters top=%d bottom=%d left=%d right=%d, " >> > >> > On which device does this happen ? >> >> >> None of my devices have such problem. It happens if replace jni by ndk >> mediacodec functions(maybe another patch later). original code: >> https://github.com/aosp-mirror/platform_frameworks_base/blob/master/media/java/android/media/MediaCodec.java#L190 > > OK. I will soon apply the patch. > > I'm however not in favor of replacing the MediaCodec jni code by its ndk > counterpart now as it would drop compatibility with Android 4.4. Just load libmediandk.so and resolve symbols at runtime, and fallback to jni if the library does not exist, i.e. on android < 5.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 05/25] avfilter/vf_scale: make use of color_range from filter links
Signed-off-by: Paul B Mahol --- libavfilter/vf_scale.c | 8 1 file changed, 8 insertions(+) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 9f45032e85..802f841cc3 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -303,9 +303,15 @@ static int config_props(AVFilterLink *outlink) if (scale->in_range != AVCOL_RANGE_UNSPECIFIED) av_opt_set_int(*s, "src_range", scale->in_range == AVCOL_RANGE_JPEG, 0); +else +av_opt_set_int(*s, "src_range", + inlink->color_range == AVCOL_RANGE_JPEG, 0); if (scale->out_range != AVCOL_RANGE_UNSPECIFIED) av_opt_set_int(*s, "dst_range", scale->out_range == AVCOL_RANGE_JPEG, 0); + else +av_opt_set_int(*s, "dst_range", + outlink->color_range == AVCOL_RANGE_JPEG, 0); if (scale->opts) { AVDictionaryEntry *e = NULL; @@ -416,6 +422,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) if( in->width != link->w || in->height != link->h || in->format != link->format + || in->color_range != link->color_range || in->sample_aspect_ratio.den != link->sample_aspect_ratio.den || in->sample_aspect_ratio.num != link->sample_aspect_ratio.num) { int ret; @@ -429,6 +436,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) link->dst->inputs[0]->format = in->format; link->dst->inputs[0]->w = in->width; link->dst->inputs[0]->h = in->height; +link->dst->inputs[0]->color_range = in->color_range; link->dst->inputs[0]->sample_aspect_ratio.den = in->sample_aspect_ratio.den; link->dst->inputs[0]->sample_aspect_ratio.num = in->sample_aspect_ratio.num; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 10/25] avcodec/mpeg4videoenc: mark as limited color range only
lavf-mkv changes only because of metadata. Signed-off-by: Paul B Mahol --- libavcodec/mpeg4videoenc.c | 1 + libavcodec/mpegvideo_enc.c | 4 tests/ref/lavf/mkv | 8 tests/ref/seek/lavf-mkv| 44 ++-- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 494452c938..80279bb3a2 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1396,6 +1396,7 @@ AVCodec ff_mpeg4_encoder = { .encode2= ff_mpv_encode_picture, .close = ff_mpv_encode_end, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]) { AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }, .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .priv_class = &mpeg4enc_class, }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index f1f4989231..46a52d3930 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -4864,6 +4864,7 @@ AVCodec ff_h263p_encoder = { .close = ff_mpv_encode_end, .capabilities = AV_CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }, .priv_class = &h263p_class, }; @@ -4884,6 +4885,7 @@ AVCodec ff_msmpeg4v2_encoder = { .encode2= ff_mpv_encode_picture, .close = ff_mpv_encode_end, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }, .priv_class = &msmpeg4v2_class, }; @@ -4904,6 +4906,7 @@ AVCodec ff_msmpeg4v3_encoder = { .encode2= ff_mpv_encode_picture, .close = ff_mpv_encode_end, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }, .priv_class = &msmpeg4v3_class, }; @@ -4924,5 +4927,6 @@ AVCodec ff_wmv1_encoder = { .encode2= ff_mpv_encode_picture, .close = ff_mpv_encode_end, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }, .priv_class = &wmv1_class, }; diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv index 0083033958..bd0302b14f 100644 --- a/tests/ref/lavf/mkv +++ b/tests/ref/lavf/mkv @@ -1,6 +1,6 @@ -7c8697c324e8ad79c5ea14364a6c39b8 *./tests/data/lavf/lavf.mkv -472759 ./tests/data/lavf/lavf.mkv +80092ba5b6833704dd04bd9f7f75366d *./tests/data/lavf/lavf.mkv +472766 ./tests/data/lavf/lavf.mkv ./tests/data/lavf/lavf.mkv CRC=0xec6c3c68 -9767a3b526d7e56d7400164cb888990c *./tests/data/lavf/lavf.mkv -320603 ./tests/data/lavf/lavf.mkv +b919b159a2dd7c9c7cd45cc36f204754 *./tests/data/lavf/lavf.mkv +320610 ./tests/data/lavf/lavf.mkv ./tests/data/lavf/lavf.mkv CRC=0xec6c3c68 diff --git a/tests/ref/seek/lavf-mkv b/tests/ref/seek/lavf-mkv index cea34e99ac..368e86cd14 100644 --- a/tests/ref/seek/lavf-mkv +++ b/tests/ref/seek/lavf-mkv @@ -1,48 +1,48 @@ -ret: 0 st: 1 flags:1 dts: 0.00 pts: 0.00 pos:834 size: 208 +ret: 0 st: 1 flags:1 dts: 0.00 pts: 0.00 pos:841 size: 208 ret: 0 st:-1 flags:0 ts:-1.00 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1057 size: 27837 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292483 size: 27834 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292483 size: 27834 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1057 size: 27837 ret:-1 st: 1 flags:0 ts: 2.577000 ret: 0 st: 1 flags:1 ts: 1.471000 -ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320317 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320324 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147023 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147030 size: 27925 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000
[FFmpeg-devel] [PATCH 07/25] avfilter: negotiate color_range between filters
Signed-off-by: Paul B Mahol --- fftools/ffmpeg.c| 2 ++ fftools/ffmpeg.h| 1 + fftools/ffmpeg_filter.c | 57 +++--- fftools/ffmpeg_opt.c| 2 ++ libavcodec/utils.c | 11 +++ libavfilter/avfilter.c | 9 -- libavfilter/avfilter.h | 4 ++- libavfilter/avfiltergraph.c | 53 libavfilter/buffersink.c| 16 ++ libavfilter/buffersink.h| 1 + libavfilter/buffersrc.c | 4 +++ libavfilter/formats.c | 75 ++--- libavfilter/formats.h | 31 +++ libavfilter/internal.h | 11 +++ libavfilter/vf_format.c | 46 ++- libavfilter/vf_noise.c | 6 +++- libavfilter/vf_scale.c | 17 -- libavfilter/vsrc_testsrc.c | 15 +++-- tests/fate/filter-video.mak | 2 +- tests/fate/pixlet.mak | 2 +- 20 files changed, 343 insertions(+), 22 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aff3366c5..64de55d9a5 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3390,6 +3390,8 @@ static int init_output_stream_encode(OutputStream *ost) enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth); +enc_ctx->color_range = av_buffersink_get_color_range(ost->filter->filter); + enc_ctx->framerate = ost->frame_rate; ost->st->avg_frame_rate = ost->frame_rate; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 4e73d59082..071f3651f8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -271,6 +271,7 @@ typedef struct OutputFilter { /* desired output stream properties */ int width, height; +enum AVColorRange color_range; AVRational frame_rate; int format; int sample_rate; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 877fd670e6..16ad79625b 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -89,6 +89,28 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCod return target; } +static enum AVColorRange choose_color_range(AVStream *st, AVCodecContext *enc_ctx, AVCodec *codec, enum AVColorRange target) +{ +if (codec && codec->color_ranges) { +const enum AVColorRange *p = codec->color_ranges; + +for (; *p != AVCOL_RANGE_UNSPECIFIED; p++) { +if (*p == target) +break; +} +if (*p == AVCOL_RANGE_UNSPECIFIED) { +if (target != AVCOL_RANGE_UNSPECIFIED) +av_log(NULL, AV_LOG_WARNING, + "Incompatible color range '%s' for codec '%s', auto-selecting color range '%s'\n", + av_color_range_name(target), + codec->name, + av_color_range_name(codec->color_ranges[0])); +return codec->color_ranges[0]; +} +} +return target; +} + void choose_sample_fmt(AVStream *st, AVCodec *codec) { if (codec && codec->sample_fmts) { @@ -127,7 +149,19 @@ static char *choose_pix_fmts(OutputFilter *ofilter) return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt)); } if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { -return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt))); +AVIOContext *s = NULL; +uint8_t *ret; +int len; + +if (avio_open_dyn_buf(&s) < 0) +exit_program(1); + +avio_printf(s, "%s:%s", av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)), + av_color_range_name(choose_color_range(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->color_range))); + +len = avio_close_dyn_buf(s, &ret); +ret[len] = 0; +return ret; } else if (ost->enc && ost->enc->pix_fmts) { const enum AVPixelFormat *p; AVIOContext *s = NULL; @@ -144,7 +178,20 @@ static char *choose_pix_fmts(OutputFilter *ofilter) for (; *p != AV_PIX_FMT_NONE; p++) { const char *name = av_get_pix_fmt_name(*p); -avio_printf(s, "%s|", name); +avio_printf(s, "%s", name); +if (*(p + 1) != AV_PIX_FMT_NONE) +avio_printf(s, "|"); +else +avio_printf(s, ":"); +} + +if (ost->enc->color_ranges) { +const enum AVColorRange *c = ost->enc->color_ranges; + +for (; *c != AVCOL_RANGE_UNSPECIFIED; c++) { +const char *name = av_color_range_name(*c); +avio_printf(s, "%s|", name); +} } len = avio_close_dyn_buf(s, &ret); ret[len - 1] = 0; @@ -777,10 +824,11 @@ static int configure_input_video_filter(FilterGraph *fg,
[FFmpeg-devel] [PATCH 11/25] avcodec/mjpegdec: replace YUVJ pixel formats
Signed-off-by: Paul B Mahol --- libavcodec/mjpegdec.c| 18 +- libavcodec/tdsc.c| 2 +- tests/fate/vcodec.mak| 4 ++-- tests/ref/fate/api-mjpeg-codec-param | 4 ++-- tests/ref/fate/exif-image-embedded | 2 +- tests/ref/fate/exif-image-jpg| 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index e005dd0cd3..55676d8576 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -467,7 +467,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') { s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : AV_PIX_FMT_GBRP16; } else { -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P; else s->avctx->pix_fmt = AV_PIX_FMT_YUV444P16; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } @@ -509,7 +509,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) case 0x22122100: case 0x21211100: case 0x22211200: -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P; else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; @@ -517,7 +517,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) case 0x1100: case 0x22112200: case 0x1100: -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P; else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; @@ -549,7 +549,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) } else { if (pix_fmt_id == 0x1400) s->upscale_v[1] = s->upscale_v[2] = 1; -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV440P; else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; @@ -562,7 +562,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) goto unk_pixfmt; s->upscale_h[0] = s->upscale_h[1] = 1; } else { -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV422P; else s->avctx->pix_fmt = AV_PIX_FMT_YUV422P16; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } @@ -570,13 +570,13 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) case 0x3100: if (s->bits > 8) goto unk_pixfmt; -s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; +s->avctx->pix_fmt = AV_PIX_FMT_YUV444P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; s->upscale_h[1] = s->upscale_h[2] = 2; break; case 0x22121100: case 0x22111200: -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV422P; else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; @@ -584,7 +584,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) case 0x2200: case 0x4200: case 0x2400: -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV420P; else s->avctx->pix_fmt = AV_PIX_FMT_YUV420P16; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; if (pix_fmt_id == 0x4200) { @@ -598,7 +598,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) } break; case 0x4100: -if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV411P : AV_PIX_FMT_YUVJ411P; +if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV411P; else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c index 4182404cf0..af92ef6ccc 100644 --- a/libavcodec/tdsc.c +++ b/libavcodec/tdsc.c @@ -357,7 +357,7 @@ static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, in
[FFmpeg-devel] [PATCH 04/25] avfilter/buffersink: export color_range from filtergraph output
Signed-off-by: Paul B Mahol --- libavfilter/buffersink.c | 1 + libavfilter/buffersink.h | 1 + 2 files changed, 2 insertions(+) diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 0f87b5439a..897396cac4 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -194,6 +194,7 @@ MAKE_AVFILTERLINK_ACCESSOR(AVRational , frame_rate ) MAKE_AVFILTERLINK_ACCESSOR(int , w ) MAKE_AVFILTERLINK_ACCESSOR(int , h ) MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio) +MAKE_AVFILTERLINK_ACCESSOR(enum AVColorRange, color_range) MAKE_AVFILTERLINK_ACCESSOR(int , channels ) MAKE_AVFILTERLINK_ACCESSOR(uint64_t , channel_layout ) diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 21d6bb505b..e6d6504832 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -114,6 +114,7 @@ AVRational av_buffersink_get_frame_rate (const AVFilterContext *c int av_buffersink_get_w (const AVFilterContext *ctx); int av_buffersink_get_h (const AVFilterContext *ctx); AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx); +enum AVColorRange av_buffersink_get_color_range(const AVFilterContext *ctx); int av_buffersink_get_channels(const AVFilterContext *ctx); uint64_t av_buffersink_get_channel_layout (const AVFilterContext *ctx); -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 01/25] avcodec: add color_range to AVCodec struct
Signed-off-by: Paul B Mahol --- libavcodec/avcodec.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ce089b7c4a..a58ef3b83b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3390,6 +3390,7 @@ typedef struct AVCodec { uint8_t max_lowres; ///< maximum value for lowres supported by the decoder const AVClass *priv_class; ///< AVClass for the private context const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} +const enum AVColorRange *color_ranges; ///< array of supported color ranges by encoder, or NULL if unknown, array is terminated by AVCOL_RANGE_UNSPECIFIED /** * Group name of the codec implementation. -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 02/25] avfilter/avfilter: add color_range to AVFilterLink struct
Signed-off-by: Paul B Mahol --- libavfilter/avfilter.c | 2 ++ libavfilter/avfilter.h | 2 ++ libavfilter/video.c| 8 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index b98b32bacb..4a579bb49d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -336,6 +336,8 @@ int avfilter_config_links(AVFilterContext *filter) link->w = inlink->w; if (!link->h) link->h = inlink->h; +if (!link->color_range) +link->color_range = inlink->color_range; } else if (!link->w || !link->h) { av_log(link->src, AV_LOG_ERROR, "Video source filters must set their output link's " diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 47546c15e5..40ad28ffd8 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -584,6 +584,8 @@ struct AVFilterLink { */ AVBufferRef *hw_frames_ctx; +enum AVColorRange color_range;///< color range type, video only + #ifndef FF_INTERNAL_FIELDS /** diff --git a/libavfilter/video.c b/libavfilter/video.c index 6f9020b9fe..8f12cb7080 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -43,6 +43,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h) AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) { +AVFrame *frame = NULL; int pool_width = 0; int pool_height = 0; int pool_align = 0; @@ -86,7 +87,12 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) } } -return ff_frame_pool_get(link->frame_pool); +frame = ff_frame_pool_get(link->frame_pool); +if (!frame) +return NULL; +frame->color_range = link->color_range; + +return frame; } AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h) -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 03/25] avfilter/buffersrc: recognize color_range as additonal parameter and set it to input link
Signed-off-by: Paul B Mahol --- libavfilter/buffersrc.c | 18 ++ libavfilter/buffersrc.h | 5 + 2 files changed, 23 insertions(+) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index cd56f8ca45..51a1a9fb49 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -52,6 +52,7 @@ typedef struct BufferSourceContext { int w, h; enum AVPixelFormat pix_fmt; AVRationalpixel_aspect; +int color_range; char *sws_param; AVBufferRef *hw_frames_ctx; @@ -109,6 +110,8 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par s->h = param->height; if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0) s->pixel_aspect = param->sample_aspect_ratio; +if (param->color_range > AVCOL_RANGE_UNSPECIFIED) +s->color_range = param->color_range; if (param->frame_rate.num > 0 && param->frame_rate.den > 0) s->frame_rate = param->frame_rate; if (param->hw_frames_ctx) { @@ -279,6 +282,11 @@ static av_cold int init_video(AVFilterContext *ctx) return AVERROR(EINVAL); } +if (!av_color_range_name(c->color_range)) { +av_log(ctx, AV_LOG_ERROR, "Invalid color_range parameter provided.\n"); +return AVERROR(EINVAL); +} + if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame* return AVERROR(ENOMEM); @@ -309,6 +317,15 @@ static const AVOption buffer_options[] = { { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, { "frame_rate",NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, { "sws_param", NULL, OFFSET(sws_param), AV_OPT_TYPE_STRING,.flags = V }, +{ "color_range", NULL, OFFSET(color_range), AV_OPT_TYPE_INT, { .i64 = AVCOL_RANGE_UNSPECIFIED }, 0, INT_MAX, V, "range" }, +{ "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, "range"}, +{ "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, "range"}, +{ "limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"}, +{ "tv",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"}, +{ "mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"}, +{ "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"}, +{ "pc",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"}, +{ "jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"}, { NULL }, }; @@ -434,6 +451,7 @@ static int config_props(AVFilterLink *link) link->w = c->w; link->h = c->h; link->sample_aspect_ratio = c->pixel_aspect; +link->color_range = c->color_range; if (c->hw_frames_ctx) { link->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx); diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h index 0652113f2b..7129db6bd9 100644 --- a/libavfilter/buffersrc.h +++ b/libavfilter/buffersrc.h @@ -114,6 +114,11 @@ typedef struct AVBufferSrcParameters { * Audio only, the audio channel layout */ uint64_t channel_layout; + + /** + * Video only + */ +enum AVColorRange color_range; } AVBufferSrcParameters; /** -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 06/25] avcodec/pngdec: set full color range only for gray formats
Signed-off-by: Paul B Mahol --- libavcodec/pngdec.c| 8 ++-- tests/ref/fate/api-png-codec-param | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index f93f200bb1..dbf986de50 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -641,9 +641,11 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, } else if ((s->bit_depth == 2 || s->bit_depth == 4 || s->bit_depth == 8) && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_GRAY8; +avctx->color_range = AVCOL_RANGE_JPEG; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_GRAY16BE; +avctx->color_range = AVCOL_RANGE_JPEG; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_RGB) { avctx->pix_fmt = AV_PIX_FMT_RGB48BE; @@ -658,9 +660,11 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_YA8; +avctx->color_range = AVCOL_RANGE_JPEG; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_YA16BE; +avctx->color_range = AVCOL_RANGE_JPEG; } else { avpriv_report_missing_feature(avctx, "Bit depth %d color type %d", @@ -680,10 +684,12 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, case AV_PIX_FMT_GRAY8: avctx->pix_fmt = AV_PIX_FMT_YA8; +avctx->color_range = AVCOL_RANGE_JPEG; break; case AV_PIX_FMT_GRAY16BE: avctx->pix_fmt = AV_PIX_FMT_YA16BE; +avctx->color_range = AVCOL_RANGE_JPEG; break; default: @@ -1575,8 +1581,6 @@ static av_cold int png_dec_init(AVCodecContext *avctx) { PNGDecContext *s = avctx->priv_data; -avctx->color_range = AVCOL_RANGE_JPEG; - s->avctx = avctx; s->previous_picture.f = av_frame_alloc(); s->last_picture.f = av_frame_alloc(); diff --git a/tests/ref/fate/api-png-codec-param b/tests/ref/fate/api-png-codec-param index c6ea7c6296..a04b77fa43 100644 --- a/tests/ref/fate/api-png-codec-param +++ b/tests/ref/fate/api-png-codec-param @@ -115,7 +115,7 @@ stream=0, decode=0 color_primaries=2 color_trc=2 colorspace=2 -color_range=2 +color_range=0 chroma_sample_location=0 log_level_offset=0 slices=0 @@ -254,7 +254,7 @@ stream=0, decode=1 color_primaries=2 color_trc=2 colorspace=2 -color_range=2 +color_range=0 chroma_sample_location=0 log_level_offset=0 slices=0 -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 08/25] fftools/ffplay: support only limited color range
Signed-off-by: Paul B Mahol --- fftools/ffplay.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 10a917194d..f023c81575 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1822,6 +1822,7 @@ fail: static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters, AVFrame *frame) { enum AVPixelFormat pix_fmts[FF_ARRAY_ELEMS(sdl_texture_format_map)]; +enum AVColorRange color_ranges[2] = { AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }; char sws_flags_str[512] = ""; char buffersrc_args[256]; int ret; @@ -1876,7 +1877,10 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0) goto fail; -last_filter = filt_out; +if ((ret = av_opt_set_int_list(filt_out, "color_ranges", color_ranges, AVCOL_RANGE_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 0) +goto fail; + + last_filter = filt_out; /* Note: this macro adds a filter before the lastly added filter, so the * processing order of the filters is in reverse */ -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 09/25] avcodec/proresenc: prores supports limited color range only
Add .color_range field to encoder's AVCodec struct. Signed-off-by: Paul B Mahol --- libavcodec/proresenc_anatoliy.c | 2 ++ libavcodec/proresenc_kostya.c | 1 + 2 files changed, 3 insertions(+) diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 0516066163..cb86d2df44 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -611,6 +611,7 @@ AVCodec ff_prores_aw_encoder = { .close = prores_encode_close, .encode2= prores_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV422P10, AV_PIX_FMT_NONE}, +.color_ranges = (const enum AVColorRange[]){AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED}, .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .profiles = profiles }; @@ -625,6 +626,7 @@ AVCodec ff_prores_encoder = { .close = prores_encode_close, .encode2= prores_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV422P10, AV_PIX_FMT_NONE}, +.color_ranges = (const enum AVColorRange[]){AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED}, .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .profiles = profiles }; diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index 149dc81b3c..807f9c9c84 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -1367,5 +1367,6 @@ AVCodec ff_prores_ks_encoder = { AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED }, .priv_class = &proresenc_class, }; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 12/25] avcodec/mjpegdec: remove YUVJ pixel format usage
Signed-off-by: Paul B Mahol --- libavcodec/mjpegdec.c | 11 ++- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 55676d8576..160bbfd34b 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2415,12 +2415,9 @@ the_end: if (AV_RB32(s->upscale_h)) { int p; -av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || - avctx->pix_fmt == AV_PIX_FMT_YUV444P || - avctx->pix_fmt == AV_PIX_FMT_YUVJ440P || +av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUV440P || avctx->pix_fmt == AV_PIX_FMT_YUVA444P || - avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16|| avctx->pix_fmt == AV_PIX_FMT_YUVA420P || @@ -2476,14 +2473,10 @@ the_end: } if (AV_RB32(s->upscale_v)) { int p; -av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || - avctx->pix_fmt == AV_PIX_FMT_YUV444P || - avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || +av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUV422P || - avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV440P || - avctx->pix_fmt == AV_PIX_FMT_YUVJ440P || avctx->pix_fmt == AV_PIX_FMT_YUVA444P || avctx->pix_fmt == AV_PIX_FMT_YUVA420P || avctx->pix_fmt == AV_PIX_FMT_YUVA420P16|| -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 13/25] avcodec/mjpegenc: add support for non-YUVJ formats
Signed-off-by: Paul B Mahol --- libavcodec/mjpegenc.c| 5 - tests/lavf-regression.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index d2fcb8e191..c31985efd3 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -415,8 +415,10 @@ AVCodec ff_mjpeg_encoder = { .close = ff_mpv_encode_end, .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]) { +AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){AVCOL_RANGE_JPEG, AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED}, .priv_class = &mjpeg_class, }; #endif @@ -439,8 +441,9 @@ AVCodec ff_amv_encoder = { .encode2= amv_encode_picture, .close = ff_mpv_encode_end, .pix_fmts = (const enum AVPixelFormat[]) { -AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE +AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED}, .priv_class = &amv_class, }; #endif diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 45c877e4ac..b03d5ac2e7 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -376,7 +376,7 @@ do_audio_only rso fi if [ -n "$do_smjpeg" ] ; then -do_lavf smjpeg "" "-f smjpeg" +do_lavf smjpeg "" "-vf format=yuv420p:pc -f smjpeg" fi if [ -n "$do_sox" ] ; then -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 22/25] avfilter/vf_blackdetect: use color_range from inlink
Remove YUVJ pixel format usage. Signed-off-by: Paul B Mahol --- libavfilter/vf_blackdetect.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c index 06ef9988d1..ff4b9eebb9 100644 --- a/libavfilter/vf_blackdetect.c +++ b/libavfilter/vf_blackdetect.c @@ -61,13 +61,6 @@ static const AVOption blackdetect_options[] = { AVFILTER_DEFINE_CLASS(blackdetect); -#define YUVJ_FORMATS \ -AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P - -static const enum AVPixelFormat yuvj_formats[] = { -YUVJ_FORMATS, AV_PIX_FMT_NONE -}; - static int query_formats(AVFilterContext *ctx) { static const enum AVPixelFormat pix_fmts[] = { @@ -76,7 +69,6 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NV12, AV_PIX_FMT_NV21, -YUVJ_FORMATS, AV_PIX_FMT_NONE }; @@ -94,7 +86,7 @@ static int config_input(AVFilterLink *inlink) blackdetect->black_min_duration = blackdetect->black_min_duration_time / av_q2d(inlink->time_base); -blackdetect->pixel_black_th_i = ff_fmt_is_in(inlink->format, yuvj_formats) ? +blackdetect->pixel_black_th_i = inlink->color_range == AVCOL_RANGE_JPEG ? // luminance_minimum_value + pixel_black_th * luminance_range_size blackdetect->pixel_black_th * 255 : 16 + blackdetect->pixel_black_th * (235 - 16); -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 24/25] avformat/rtpenc_jpeg: remove usage of YUVJ formats
Signed-off-by: Paul B Mahol --- libavformat/rtpenc_jpeg.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c index 38eb2e68eb..e0e7afebfc 100644 --- a/libavformat/rtpenc_jpeg.c +++ b/libavformat/rtpenc_jpeg.c @@ -46,13 +46,11 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size) h = AV_CEIL_RSHIFT(s1->streams[0]->codecpar->height, 3); /* get the pixel format type or fail */ -if (s1->streams[0]->codecpar->format == AV_PIX_FMT_YUVJ422P || -(s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG && - s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV422P)) { +if (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG && + s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV422P) { type = 0; -} else if (s1->streams[0]->codecpar->format == AV_PIX_FMT_YUVJ420P || - (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG && -s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV420P)) { +} else if (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG && +s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV420P) { type = 1; } else { av_log(s1, AV_LOG_ERROR, "Unsupported pixel format\n"); -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 23/25] avfilter/vf_setrange: change outlink color_range too
Signed-off-by: Paul B Mahol --- libavfilter/vf_setparams.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c index 8427f98ba8..98a4aa2ad3 100644 --- a/libavfilter/vf_setparams.c +++ b/libavfilter/vf_setparams.c @@ -56,6 +56,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) return ff_filter_frame(ctx->outputs[0], frame); } +static int config_output(AVFilterLink *outlink) +{ +SetParamsContext *s = outlink->src->priv; + +if (s->color_range >= 0) +outlink->color_range = s->color_range; + +return 0; +} + static const AVFilterPad inputs[] = { { .name = "default", @@ -69,6 +79,7 @@ static const AVFilterPad outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, +.config_props = config_output, }, { NULL } }; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 25/25] avfilter: remove YUVJ pixel format usage
Signed-off-by: Paul B Mahol --- libavfilter/avf_showspectrum.c | 2 +- libavfilter/vaf_spectrumsynth.c| 4 +--- libavfilter/vf_atadenoise.c| 3 --- libavfilter/vf_avgblur.c | 4 +--- libavfilter/vf_bitplanenoise.c | 2 -- libavfilter/vf_blend.c | 1 - libavfilter/vf_bwdif.c | 2 -- libavfilter/vf_colorspace.c| 1 - libavfilter/vf_convolution.c | 4 +--- libavfilter/vf_convolve.c | 4 +--- libavfilter/vf_cover_rect.c| 3 +-- libavfilter/vf_cropdetect.c| 6 +++--- libavfilter/vf_deband.c| 4 +--- libavfilter/vf_deflicker.c | 3 --- libavfilter/vf_deshake.c | 3 +-- libavfilter/vf_displace.c | 4 +--- libavfilter/vf_drawbox.c | 3 +-- libavfilter/vf_extractplanes.c | 6 -- libavfilter/vf_fade.c | 3 +-- libavfilter/vf_fftfilt.c | 6 +++--- libavfilter/vf_fillborders.c | 4 +--- libavfilter/vf_find_rect.c | 1 - libavfilter/vf_framepack.c | 3 +-- libavfilter/vf_framerate.c | 10 +- libavfilter/vf_fspp.c | 2 -- libavfilter/vf_gblur.c | 4 +--- libavfilter/vf_histogram.c | 8 libavfilter/vf_hqdn3d.c| 4 libavfilter/vf_hysteresis.c| 4 +--- libavfilter/vf_idet.c | 4 libavfilter/vf_interlace.c | 4 ++-- libavfilter/vf_lenscorrection.c| 4 ++-- libavfilter/vf_limiter.c | 4 +--- libavfilter/vf_lut.c | 2 -- libavfilter/vf_lut2.c | 4 +--- libavfilter/vf_maskedclamp.c | 4 +--- libavfilter/vf_maskedmerge.c | 4 +--- libavfilter/vf_mestimate.c | 3 --- libavfilter/vf_midequalizer.c | 4 +--- libavfilter/vf_minterpolate.c | 3 --- libavfilter/vf_mpdecimate.c| 2 -- libavfilter/vf_neighbor.c | 1 - libavfilter/vf_nlmeans.c | 3 --- libavfilter/vf_nnedi.c | 3 --- libavfilter/vf_ocr.c | 3 --- libavfilter/vf_overlay.c | 6 +++--- libavfilter/vf_perspective.c | 1 - libavfilter/vf_phase.c | 1 - libavfilter/vf_pp.c| 12 libavfilter/vf_pp7.c | 2 -- libavfilter/vf_premultiply.c | 10 +- libavfilter/vf_psnr.c | 2 -- libavfilter/vf_pullup.c| 4 +--- libavfilter/vf_readeia608.c| 3 --- libavfilter/vf_readvitc.c | 5 - libavfilter/vf_remap.c | 1 - libavfilter/vf_removegrain.c | 2 -- libavfilter/vf_rotate.c| 4 ++-- libavfilter/vf_signalstats.c | 2 -- libavfilter/vf_signature.c | 3 --- libavfilter/vf_spp.c | 2 -- libavfilter/vf_ssim.c | 2 -- libavfilter/vf_stereo3d.c | 5 - libavfilter/vf_threshold.c | 4 +--- libavfilter/vf_tinterlace.c| 11 ++- libavfilter/vf_unsharp.c | 4 ++-- libavfilter/vf_uspp.c | 2 -- libavfilter/vf_vaguedenoiser.c | 3 --- libavfilter/vf_vectorscope.c | 10 +- libavfilter/vf_w3fdif.c| 3 --- libavfilter/vf_waveform.c | 10 ++ libavfilter/vf_yadif.c | 4 libavfilter/vf_zoompan.c | 3 --- libavfilter/vf_zscale.c| 3 --- libavfilter/vsrc_testsrc.c | 2 +- tests/ref/fate/filter-pixfmts-lut | 4 tests/ref/fate/filter-pixfmts-pullup | 5 - tests/ref/fate/filter-pixfmts-rotate | 2 -- tests/ref/fate/filter-pixfmts-tinterlace_cvlpf | 4 tests/ref/fate/filter-pixfmts-tinterlace_merge | 4 tests/ref/fate/filter-pixfmts-tinterlace_pad | 4 tests/ref/fate/filter-pixfmts-tinterlace_vlpf | 4 82 files changed, 63 insertions(+), 250 deletions(-) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 956f62f3ad..33449df315 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/av
[FFmpeg-devel] [PATCH 21/25] avcodec/hevcdec: remove usage of YUVJ pixel format
Signed-off-by: Paul B Mahol --- libavcodec/hevcdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 433a7056ea..d1b54b1db5 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -363,7 +363,6 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) switch (sps->pix_fmt) { case AV_PIX_FMT_YUV420P: -case AV_PIX_FMT_YUVJ420P: #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 20/25] avcodec/roqvideoenc: do not use YUVJ pixel format
Signed-off-by: Paul B Mahol --- libavcodec/roqvideoenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index ac05123dc6..18ceef1b2c 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1132,7 +1132,8 @@ AVCodec ff_roq_encoder = { .init = roq_encode_init, .encode2 = roq_encode_frame, .close= roq_encode_end, -.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ444P, +.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, +.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED }, .priv_class = &roq_class, }; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 19/25] avcodec/hevc_ps: do not use YUVJ pixel format
Color range is already set. Signed-off-by: Paul B Mahol --- libavcodec/hevc_ps.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index a4f7ed60f7..19ec2d7ebf 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -578,8 +578,6 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, vui->video_format= get_bits(gb, 3); vui->video_full_range_flag = get_bits1(gb); vui->colour_description_present_flag = get_bits1(gb); -if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P) -sps->pix_fmt = AV_PIX_FMT_YUVJ420P; if (vui->colour_description_present_flag) { vui->colour_primaries= get_bits(gb, 8); vui->transfer_characteristic = get_bits(gb, 8); -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 18/25] avcodec/h264_slice: do not use YUVJ pixel formats
Signed-off-by: Paul B Mahol --- libavcodec/h264_slice.c | 22 ++ 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index aad5484588..a75ab08c29 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -820,15 +820,10 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) *fmt++ = AV_PIX_FMT_GBRP; -else if (h->avctx->color_range == AVCOL_RANGE_JPEG) -*fmt++ = AV_PIX_FMT_YUVJ444P; else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(h)) { -if (h->avctx->color_range == AVCOL_RANGE_JPEG) -*fmt++ = AV_PIX_FMT_YUVJ422P; -else -*fmt++ = AV_PIX_FMT_YUV422P; +*fmt++ = AV_PIX_FMT_YUV422P; } else { #if CONFIG_H264_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; @@ -845,8 +840,6 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #endif if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; -else if (h->avctx->color_range == AVCOL_RANGE_JPEG) -*fmt++ = AV_PIX_FMT_YUVJ420P; else *fmt++ = AV_PIX_FMT_YUV420P; } @@ -992,17 +985,6 @@ fail: return ret; } -static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a) -{ -switch (a) { -case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P; -case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P; -case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P; -default: -return a; -} -} - static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_slice) { const SPS *sps; @@ -1047,7 +1029,7 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl || h->mb_height != sps->mb_height )); if (h->avctx->pix_fmt == AV_PIX_FMT_NONE -|| (non_j_pixfmt(h->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h, 0 +|| (h->avctx->pix_fmt != get_pixel_format(h, 0))) must_reinit = 1; if (first_slice && av_cmp_q(sps->sar, h->avctx->sample_aspect_ratio)) -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 15/25] avcodec/fraps: replace YUVJ pixel format
Signed-off-by: Paul B Mahol --- libavcodec/fraps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 7a7673f73f..b2025b5d3f 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -218,7 +218,7 @@ static int decode_frame(AVCodecContext *avctx, f->pict_type = AV_PICTURE_TYPE_I; f->key_frame = 1; -avctx->pix_fmt = version & 1 ? is_pal ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_BGR24 : AV_PIX_FMT_YUVJ420P; +avctx->pix_fmt = version & 1 ? is_pal ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_BGR24 : AV_PIX_FMT_YUV420P; avctx->color_range = version & 1 ? AVCOL_RANGE_UNSPECIFIED : AVCOL_RANGE_JPEG; avctx->colorspace = version & 1 ? AVCOL_SPC_UNSPECIFIED : AVCOL_SPC_BT709; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 17/25] avcodec/mdec: replace YUVJ pixel format
Signed-off-by: Paul B Mahol --- libavcodec/mdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 330b761279..637158d231 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -227,7 +227,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ff_init_scantable(a->idsp.idct_permutation, &a->scantable, ff_zigzag_direct); -avctx->pix_fmt = AV_PIX_FMT_YUVJ420P; +avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->color_range = AVCOL_RANGE_JPEG; /* init q matrix */ -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 14/25] avcodec/svq3: replace YUVJ pixel format
Signed-off-by: Paul B Mahol --- libavcodec/svq3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index a937b2f951..4c6d838a15 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -1158,7 +1158,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_tpeldsp_init(&s->tdsp); -avctx->pix_fmt = AV_PIX_FMT_YUVJ420P; +avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->color_range = AVCOL_RANGE_JPEG; s->avctx = avctx; @@ -1652,6 +1652,6 @@ AVCodec ff_svq3_decoder = { .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, -.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, +.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, }; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 16/25] avcodec/roqvideodec: replace YUVJ pixel format
Signed-off-by: Paul B Mahol --- libavcodec/roqvideodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 0ab7d399d6..c5b7bbe236 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -190,7 +190,7 @@ static av_cold int roq_decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } -avctx->pix_fmt = AV_PIX_FMT_YUVJ444P; +avctx->pix_fmt = AV_PIX_FMT_YUV444P; avctx->color_range = AVCOL_RANGE_JPEG; return 0; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 07/14] mediacodec: check whether cropping is set before use
On Sat, Dec 16, 2017 at 01:40:18PM +0800, Wang Bin wrote: > > > +width = s->crop_right + 1 - s->crop_left; > > > +else > > > +width = s->width; > > > > > > av_log(avctx, AV_LOG_INFO, > > > "Output crop parameters top=%d bottom=%d left=%d right=%d, " > > > > On which device does this happen ? > > > None of my devices have such problem. It happens if replace jni by ndk > mediacodec functions(maybe another patch later). original code: > https://github.com/aosp-mirror/platform_frameworks_base/blob/master/media/java/android/media/MediaCodec.java#L190 OK. I will soon apply the patch. I'm however not in favor of replacing the MediaCodec jni code by its ndk counterpart now as it would drop compatibility with Android 4.4. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_aspect: change outlink sample aspect ratio instead of inlink
On 12/16/17, Nicolas George wrote: > Paul B Mahol (2017-12-15): >> More than 4 days passed. >> >> I assume this one is OK? > > Wrong assumption. If you assume instead that I had very little time > during the last five days, you are right. > What's wrong then your highness? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 14/14] videotoolbox: remove opengl compatibility attribute
2017-12-16 15:33 GMT+08:00 Xiaolei Yu : > On 12/16/2017 02:07 PM, Wang Bin wrote: >> 2017-12-16 2:52 GMT+08:00 wm4 : >>> On Fri, 15 Dec 2017 15:02:44 +0800 >>> wbse...@gmail.com wrote: >>> From: wang-bin 1. a cvpixelbuffer backed by iosurface can always be converted to an opengl texture, using CGLTexImageIOSurface2D for macOS, and undocumented api texImageIOSurface(which is internally used by public api CVOpenGLESTextureCacheCreateTextureFromImage) for iOS4.0+. 2. enabling the attribute can slow down decoding speed a lot. I tested many video clips on my macbook air. for example: ffmpeg -ss 00:00:00 -t 00:03:00 -hwaccel videotoolbox -an -i big_buck_bunny_1080p_h264.mov -f null ->/dev/null, result with the attribute enabled: frame= 2082 fps= 85 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A speed=7.34x disabled: frame= 2031 fps=104 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A speed=9.22x --- libavcodec/videotoolbox.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 9d2f0afa20..24631684d7 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -664,11 +664,6 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width, CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w); CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h); -#if TARGET_OS_IPHONE -CFDictionarySetValue(buffer_attributes, kCVPixelBufferOpenGLESCompatibilityKey, kCFBooleanTrue); -#else -CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfaceOpenGLTextureCompatibilityKey, kCFBooleanTrue); -#endif CFRelease(io_surface_properties); CFRelease(cv_pix_fmt); >>> >>> Does this have a negative effect on compatibility or performance? (In >>> both cases I'm asking about the case when actually using GL rendering.) >> >> Disabling the attribute improves performance in my tests. I can not >> find any document about these keys. What i know is the decoded >> cvpixelbuffer is backed by iosurface, and the api to create texture >> from iosurface is available since macOS10.6 > > Maybe you can add a flag to make them optional? > They are documented at: > https://developer.apple.com/documentation/corevideo/kcvpixelbufferopenglescompatibilitykey > https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfaceopengltexturecompatibilitykey > > Things may still work without them but I would like to follow the > documentation whenever possible. And I think iOS DOES require the flag for > those buffers to be consumed through GLES. > Your links explain nothing. iOS does not need it as mentioned in the patch. I tested on iphone4s+iOS9 and some new devices. > Pure speculation here. GPU texture units usually require special memory > layouts that may be suboptimal for the decoder. When these constraints are > not met either the driver has to perform the conversion or you pay the > penalty at access time. Not sure about memory layout. The fact is on mac the performance is much better without it. No difference on ios. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel