[FFmpeg-devel] [PATCH] lavfi/atempo: fix range check if tempo is set by command

2018-10-03 Thread wbsecg1
From: wang-bin 

---
 libavfilter/af_atempo.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index 52f15f2769..1a004212a7 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -331,9 +331,10 @@ static int yae_set_tempo(AVFilterContext *ctx, const char 
*arg_tempo)
 return AVERROR(EINVAL);
 }
 
-if (tempo < 0.5 || tempo > 2.0) {
-av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [0.5, 2.0] range\n",
-   tempo);
+const AVOption *o = av_opt_find(&atempo->class, "tempo", NULL, 0, 
AV_OPT_SEARCH_FAKE_OBJ);
+if (tempo < o->min || tempo > o->max) {
+av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%.1f, %.1f] 
range\n",
+   tempo, o->min, o->max);
 return AVERROR(EINVAL);
 }
 
@@ -439,8 +440,8 @@ static int yae_load_data(ATempoContext *atempo,
 return 0;
 }
 
-// samples are not expected to be skipped, unless tempo is greater than 2:
-av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0);
+// samples are not expected to be skipped:
+av_assert0(read_size <= atempo->ring);
 
 while (atempo->position[0] < stop_here && src < src_end) {
 int src_samples = (src_end - src) / atempo->stride;
-- 
2.17.1 (Apple Git-112)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 14/14] videotoolbox: remove opengl compatibility attribute

2017-12-14 Thread wbsecg1
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);
-- 
2.15.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 08/14] avcodec: add AV_HWACCEL_FLAG_ALLOW_SOFTWARE

2017-12-14 Thread wbsecg1
From: wang-bin 

a hw decoder may have software or hybrid implementation, for example 
videotoolbox hevc.
the performance may be better than ffmpeg sw decoder.
---
 libavcodec/avcodec.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ce089b7c4a..6d1f5ee532 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3725,6 +3725,10 @@ typedef struct AVHWAccel {
  */
 #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)
 
+/**
+ * Hardware acceleration can use it's software implementation.
+ */
+#define AV_HWACCEL_FLAG_ALLOW_SOFTWARE (1 << 3)
 /**
  * @}
  */
-- 
2.15.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 03/14] configure: fix probing armv6zk

2017-12-14 Thread wbsecg1
From: wang-bin 

clang reports 6kz: https://reviews.llvm.org/D14568
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index d5bbb5b7a9..6065f01c5c 100755
--- a/configure
+++ b/configure
@@ -4521,6 +4521,7 @@ elif enabled arm; then
 elif check_arm_arch 6J;   then echo armv6j
 elif check_arm_arch 6K;   then echo armv6k
 elif check_arm_arch 6Z;   then echo armv6z
+elif check_arm_arch 6KZ;  then echo armv6zk
 elif check_arm_arch 6ZK;  then echo armv6zk
 elif check_arm_arch 6T2;  then echo armv6t2
 elif check_arm_arch 7;then echo armv7
-- 
2.15.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 13/14] mmal: add option copy_frame to support retrieving sw frames w/o copy

2017-12-14 Thread wbsecg1
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}
 };
 
-- 
2.15.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 07/14] mediacodec: check whether cropping is set before use

2017-12-14 Thread wbsecg1
From: wang-bin 

---
 libavcodec/mediacodecdec_common.c | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index cb2f6ae5e5..05d3bcd4b5 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -412,20 +412,15 @@ static int mediacodec_dec_parse_format(AVCodecContext 
*avctx, MediaCodecDecConte
 }
 
 /* Optional fields */
-if (ff_AMediaFormat_getInt32(s->format, "crop-top", &value))
-s->crop_top = value;
-
-if (ff_AMediaFormat_getInt32(s->format, "crop-bottom", &value))
-s->crop_bottom = value;
-
-if (ff_AMediaFormat_getInt32(s->format, "crop-left", &value))
-s->crop_left = value;
-
-if (ff_AMediaFormat_getInt32(s->format, "crop-right", &value))
-s->crop_right = value;
-
-width = s->crop_right + 1 - s->crop_left;
-height = s->crop_bottom + 1 - s->crop_top;
+if (ff_AMediaFormat_getInt32(s->format, "crop-top", &s->crop_top) && 
ff_AMediaFormat_getInt32(s->format, "crop-bottom", &s->crop_bottom))
+height = s->crop_bottom + 1 - s->crop_top;
+else
+height = s->height;
+
+if (ff_AMediaFormat_getInt32(s->format, "crop-left", &s->crop_left) && 
ff_AMediaFormat_getInt32(s->format, "crop-right", &s->crop_right))
+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, "
-- 
2.15.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 09/14] videotoolbox: allow software implementation

2017-12-14 Thread wbsecg1
From: wang-bin 

hevc is supported on macOS 10.12+ and iOS11+. sw implementaion is
provided for old devices. vt sw decoder is more energy effecient than
ffmpeg sw decoder. the sum of program and vt service cpu usage is about
50% lower than ffmpeg. decoding speed is faster sometimes(if opengl
compatiblility attribute is disabled)
---
 libavcodec/videotoolbox.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index e66cd23451..9d2f0afa20 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -40,6 +40,9 @@
 #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder
 #  define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder 
CFSTR("RequireHardwareAcceleratedVideoDecoder")
 #endif
+#ifndef kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder
+#  define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder 
CFSTR("EnableHardwareAcceleratedVideoDecoder")
+#endif
 
 #if !HAVE_KCMVIDEOCODECTYPE_HEVC
 enum { kCMVideoCodecType_HEVC = 'hvc1' };
@@ -684,7 +687,9 @@ static CFDictionaryRef 
videotoolbox_decoder_config_create(CMVideoCodecType codec

&kCFTypeDictionaryValueCallBacks);
 
 CFDictionarySetValue(config_info,
- 
kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
+ (avctx->hwaccel_flags & 
AV_HWACCEL_FLAG_ALLOW_SOFTWARE)
+ ? 
kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder
+ : 
kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
  kCFBooleanTrue);
 
 CFMutableDictionaryRef avc_info;
-- 
2.15.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use zero-copy forAV_PIX_FMT_MMAL

2017-11-02 Thread wbsecg1

> On Sun, 3 Sep 2017 15:44:36 +0300
Yevhen Kyriukha  wrote:
>
>> Signed-off-by: Yevhen Kyriukha 
>> —
>> libavcodec/mmaldec.c | 5 -
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
>> index 0b1195dc3e..19ca6ce7e7 100644
>> --- a/libavcodec/mmaldec.c
>> +++ b/libavcodec/mmaldec.c
>> @@ -295,6 +295,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>> goto fail;
>>  
>> if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
>> + if ((status = mmal_port_parameter_set_boolean(decoder->output[0], 
>> MMAL_PARAMETER_ZERO_COPY, 1)))
>> + goto fail;
>> format_out->encoding = MMAL_ENCODING_OPAQUE;
>> } else {
>> format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
>> @@ -332,7 +334,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>> FFMAX(decoder->output[0]->buffer_size_min, 
>> decoder->output[0]->buffer_size_recommended);
>> decoder->output[0]->buffer_num =
>> FFMAX(decoder->output[0]->buffer_num_min, 
>> decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
>> - ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
>> + ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
>> + decoder->output[0]->buffer_num,
>> decoder->output[0]->buffer_size);
>> if (!ctx->pool_out->pool) {
>> ret = AVERROR(ENOMEM);

> Why the change, and what are the implications? (The commit message
> should contain this.)

I have confirmed with this patch EGLImage can be created from decoded mmal 
buffer. It’s really useful for players.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel