From patchwork Thu Oct 20 00:45:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 1084 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp431215vsd; Wed, 19 Oct 2016 17:46:04 -0700 (PDT) X-Received: by 10.28.149.209 with SMTP id x200mr4531259wmd.123.1476924364778; Wed, 19 Oct 2016 17:46:04 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ez12si49510168wjc.249.2016.10.19.17.46.04; Wed, 19 Oct 2016 17:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A3CC6898B3; Thu, 20 Oct 2016 03:45:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDC18689885 for ; Thu, 20 Oct 2016 03:45:52 +0300 (EEST) Received: by mail-pf0-f193.google.com with SMTP id r16so3790010pfg.3 for ; Wed, 19 Oct 2016 17:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=1d70TZaMGsUb7+NgjjLVMkfpJyTydJi5agblp29pKYQ=; b=1FQMCmDpIPKBIwudMOz7ZnZFVzI7T2r4mBfN47krkHSjwSP1I0DatenMLopF5dF4jJ pVbePfkd3zAfqzW9iqTaqIIuXBSkDt4LOK1tStaovbfVeH6iNI+QB3UeCaMjX3XD1C3k ICL0JzfeM+77ztUDBJcVDv5pFTCeVsv8hADtISyVpqg//K4zgkCYdU7uuU2myF3jN3E6 qW5aRsfgiX+R0GM47hRTZdbv7MNz3TGRccSYU7XibKT+F4eT5oNT8AnoGm3vgQ8r92HV kYF7kwB/1FXmonEgpXRz+pUKyQqmZvZPH6Spyy01V5RpvPr3PMmxIdu29zwFpwQ3zbqe WXSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=1d70TZaMGsUb7+NgjjLVMkfpJyTydJi5agblp29pKYQ=; b=iiqWYt6xDFou06PEbxhOiBqalqW9Kf90Vj3lcDKxlkkbcK/s9fyu2na4HtXwvCoX3W fJrh0+u1Ztgx9daSlhZ0Gf2MZFip394Y7+bd3OlCKa+xUrZ966+2lEC0N+Xm8IL6rQcW KHfbc3qEXBFIVzJt2BGKhYiVg8qgm/Dp2Ghhuer2xBr2PaUuijteF8yjRtpTlqcWOdcK UErAxlQJHhWNOApAXvO89utcQ/oeW5pYXhEDNLPdKK4Daau+2VSXuzdCbFqlquyerKRN mluJ+9mrB0T9scCCLLVOFzv3jtEPVrWQ8ktPdAhGLIeOO7cxMa8z+MKIZ2E5YRlpiVVq RG3A== X-Gm-Message-State: AA6/9Rkh5hmIfmqheJUh/23XdZF8Kmi0qXqq+ioipJ/PEzZJ/Xqb64BAOvLg3fGlLnjTFg== X-Received: by 10.98.159.130 with SMTP id v2mr16368573pfk.48.1476924353747; Wed, 19 Oct 2016 17:45:53 -0700 (PDT) Received: from tmm1-macbook.local.net (c-73-170-238-81.hsd1.ca.comcast.net. [73.170.238.81]) by smtp.gmail.com with ESMTPSA id x1sm66651911pay.41.2016.10.19.17.45.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 19 Oct 2016 17:45:53 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Oct 2016 17:45:48 -0700 Message-Id: <1476924348-55856-1-git-send-email-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.8.1 Subject: [FFmpeg-devel] [PATCH] lavc/videotoolbox: fix avcc creation for h264 streams missing extradata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta ff_videotoolbox_avcc_extradata_create() was never being called if avctx->extradata_size==0, even though the function does not need or use the avctx->extradata. This manifested itself only on h264 streams in specific containers, and only on iOS. I guess the macOS version of VideoToolbox is more forgiving, atleast on my specific combination of OS version and hardware. I also added an error log message when VTDecompressionSessionCreate() fails, to help the next poor soul who runs into a bug in this area of the code. The native OSStatus error codes are much easier to google than their AVERROR counterparts (especially in this case, with AVERROR_UNKNOWN). --- libavcodec/videotoolbox.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 1288aa5..b21eccb 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -413,7 +413,7 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder, kCFBooleanTrue); - if (avctx->extradata_size) { + if (avctx->extradata_size || codec_type == kCMVideoCodecType_H264) { CFMutableDictionaryRef avc_info; CFDataRef data = NULL; @@ -572,13 +572,16 @@ static int videotoolbox_default_init(AVCodecContext *avctx) if (buf_attr) CFRelease(buf_attr); + if (status != 0) + av_log(avctx, AV_LOG_ERROR, "Error creating videotoolbox decompression session: %d\n", status); + switch (status) { case kVTVideoDecoderNotAvailableNowErr: case kVTVideoDecoderUnsupportedDataFormatErr: return AVERROR(ENOSYS); case kVTVideoDecoderMalfunctionErr: return AVERROR(EINVAL); - case kVTVideoDecoderBadDataErr : + case kVTVideoDecoderBadDataErr: return AVERROR_INVALIDDATA; case 0: return 0;