diff options
author | Rick Kern <kernrj@gmail.com> | 2019-05-12 23:04:37 +0300 |
---|---|---|
committer | Rick Kern <rick@8birdsvideo.com> | 2019-05-12 23:22:51 +0300 |
commit | 714c8b0766244f1a304fe05a9489929118787f58 (patch) | |
tree | 57917b70b04f7ba76ffbd33518f1c0eae4cd7a3a /libavcodec/videotoolboxenc.c | |
parent | 247bda442f51ee5c330bab1489c5a1edd875b53d (diff) |
lavc/videotoolboxenc: simplify frame creation logic between OS X and iOS.
Signed-off-by: Rick Kern <kernrj@gmail.com>
Diffstat (limited to 'libavcodec/videotoolboxenc.c')
-rw-r--r-- | libavcodec/videotoolboxenc.c | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 9e82f700f0..f501ee6746 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -2011,19 +2011,6 @@ static int get_cv_pixel_info( return 0; } -#if !TARGET_OS_IPHONE -//Not used on iOS - frame is always copied. -static void free_avframe( - void *release_ctx, - const void *data, - size_t size, - size_t plane_count, - const void *plane_addresses[]) -{ - AVFrame *frame = release_ctx; - av_frame_free(&frame); -} -#else //Not used on OSX - frame is never copied. static int copy_avframe_to_pixel_buffer(AVCodecContext *avctx, const AVFrame *frame, @@ -2116,7 +2103,6 @@ static int copy_avframe_to_pixel_buffer(AVCodecContext *avctx, return 0; } -#endif //!TARGET_OS_IPHONE static int create_cv_pixel_buffer(AVCodecContext *avctx, const AVFrame *frame, @@ -2129,18 +2115,8 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx, size_t strides[AV_NUM_DATA_POINTERS]; int status; size_t contiguous_buf_size; -#if TARGET_OS_IPHONE CVPixelBufferPoolRef pix_buf_pool; VTEncContext* vtctx = avctx->priv_data; -#else - CFMutableDictionaryRef pix_buf_attachments = CFDictionaryCreateMutable( - kCFAllocatorDefault, - 10, - &kCFCopyStringDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - if (!pix_buf_attachments) return AVERROR(ENOMEM); -#endif if (avctx->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX) { av_assert0(frame->format == AV_PIX_FMT_VIDEOTOOLBOX); @@ -2180,7 +2156,6 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx, return AVERROR_EXTERNAL; } -#if TARGET_OS_IPHONE pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session); if (!pix_buf_pool) { /* On iOS, the VT session is invalidated when the APP switches from @@ -2222,43 +2197,6 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx, *cv_img = NULL; return status; } -#else - AVFrame *enc_frame = av_frame_alloc(); - if (!enc_frame) return AVERROR(ENOMEM); - - status = av_frame_ref(enc_frame, frame); - if (status) { - av_frame_free(&enc_frame); - return status; - } - - status = CVPixelBufferCreateWithPlanarBytes( - kCFAllocatorDefault, - enc_frame->width, - enc_frame->height, - color, - NULL, - contiguous_buf_size, - plane_count, - (void **)enc_frame->data, - widths, - heights, - strides, - free_avframe, - enc_frame, - NULL, - cv_img - ); - - add_color_attr(avctx, pix_buf_attachments); - CVBufferSetAttachments(*cv_img, pix_buf_attachments, kCVAttachmentMode_ShouldPropagate); - CFRelease(pix_buf_attachments); - - if (status) { - av_log(avctx, AV_LOG_ERROR, "Error: Could not create CVPixelBuffer: %d\n", status); - return AVERROR_EXTERNAL; - } -#endif return 0; } |