From patchwork Fri Feb 1 00:28:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niki Bowe X-Patchwork-Id: 11936 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E369244C3B9 for ; Fri, 1 Feb 2019 02:58:43 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 098C868ABA3; Fri, 1 Feb 2019 02:58:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 761D268ABA3 for ; Fri, 1 Feb 2019 02:58:24 +0200 (EET) Received: by mail-pg1-f194.google.com with SMTP id v28so2114491pgk.10 for ; Thu, 31 Jan 2019 16:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3Ui+cIXS5lYNE1bvkoNCJBJOym/cEIEnw6ZdbiS+5v0=; b=q4eppuZc6Ugi//EeY4sAYfpWndYNAS3tdzcQ4Nn17hkdW0DtwMurK4t0pFWNdrovDI RFMq/m+jkkLDXCJtzc0kQOAV+ZRFcFNHVWXa1UmgsoUr3ikC+eQE81bzMOmSyOKjgqQ2 VKipfm/VdOKxJvsKeq1HNCgEbnWzNidg05vIXMalI/Jm3dYapwzFqilSG2IugR3/NddC 2U+Nvq3yNvQrDVzL5Ayyi3Qyl2whtsQX2qWZk+MKVDmWq+ZeFg/lobrDtKQ6BCPxPCyI /vRzWwoEO1SB2uqF0PR8LFIaK0n3qkiEqqAgzdmzHHCniAzvumWv9OKsDZvavDhVcIDP UB5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3Ui+cIXS5lYNE1bvkoNCJBJOym/cEIEnw6ZdbiS+5v0=; b=V8h6G73ZAyAQ7/L5kkvWjKTzZrRjCmi1k89IgUyS64k97pEbrGZJfX8jB06vG2noi3 KiOCUu0QnaYK6tblSNJ6jEfpxy3k9C0NT4MquEk2g775PS/vjMebhj5iJX1mEzq1mDlB 6LJJLsJX65/JF8So77voj5LAfDDVLSWr5pFLyb8ThoyR6e5g/drLtPSTL+AKF0voV+hx clIfL8NkMhtvW/D6JmhXzh2YsjQn6HrTjDJBody1WXlbYo4bO/5bbxm2DpMpkxnzb0Zg jZ3UNSPjcShuy3u7zUDEs4u0DA+zJ5+anQCkdXGhYtoR0ZPNOf7IQw8C88vJCtA6+Yf9 HZpw== X-Gm-Message-State: AJcUukerDQj972d/zX1cOW3K5NmhyIcwiG2d0GwUXUZqFz1GuuUm5/6S FQDUsJTQToyCAo7UL9YK2523aI9YlxJ+Lg== X-Google-Smtp-Source: ALg8bN4ElwhS8v5IjOHp6qF+eiLF3FX6vN3y0PFRVsJKNf7bFLgBQb9hlYXb3AO7z3vWlqTQo3XVjA== X-Received: by 2002:a62:4b4d:: with SMTP id y74mr36546399pfa.186.1548980895633; Thu, 31 Jan 2019 16:28:15 -0800 (PST) Received: from nbowe.mtv.corp.google.com ([2620:0:1000:4011:fa9f:875c:58f2:5c3e]) by smtp.gmail.com with ESMTPSA id 186sm18248521pga.36.2019.01.31.16.28.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 16:28:14 -0800 (PST) From: Nikolas Bowe To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 Jan 2019 16:28:09 -0800 Message-Id: <20190201002809.236153-1-nbowe@google.com> X-Mailer: git-send-email 2.20.1.611.gfbb209baf1-goog MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] movenc: Fix VPCC bitdepth for hardware pixel formats 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: Nikolas Bowe Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If a hardware encoder is used, the pixel format may be a hardware pixel format. This leads to invalid VPCC atom being written, due to depth of hardware pixel formats being 0. To work around this, fallback on bits_per_raw_sample. Signed-off-by: Nikolas Bowe --- libavcodec/vaapi_encode.c | 2 +- libavformat/vpcc.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index b4e9fadaee..cfd9413f0f 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1116,7 +1116,7 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) ctx->input_frames->sw_format); return AVERROR(EINVAL); } - depth = desc->comp[0].depth; + avctx->bits_per_raw_sample = depth = desc->comp[0].depth; for (i = 1; i < desc->nb_components; i++) { if (desc->comp[i].depth != depth) { av_log(avctx, AV_LOG_ERROR, "Invalid input pixfmt (%s).\n", diff --git a/libavformat/vpcc.c b/libavformat/vpcc.c index e0b7f288a6..f667ca9c00 100644 --- a/libavformat/vpcc.c +++ b/libavformat/vpcc.c @@ -51,15 +51,20 @@ static int get_vpx_chroma_subsampling(AVFormatContext *s, return -1; } -static int get_bit_depth(AVFormatContext *s, enum AVPixelFormat pixel_format) +static int get_bit_depth(AVFormatContext *s, AVCodecParameters *par) { + enum AVPixelFormat pixel_format = par->format; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pixel_format); if (desc == NULL) { av_log(s, AV_LOG_ERROR, "Unsupported pixel format (%d)\n", pixel_format); return -1; } - return desc->comp[0].depth; + if (desc->comp[0].depth) { + return desc->comp[0].depth; + } + // Fallback on bits_per_raw_sample if pix_fmt is a hw format. + return par->bits_per_raw_sample; } static int get_vpx_video_full_range_flag(enum AVColorRange color_range) @@ -119,13 +124,13 @@ int ff_isom_get_vpcc_features(AVFormatContext *s, AVCodecParameters *par, int profile = par->profile; int level = par->level == FF_LEVEL_UNKNOWN ? get_vp9_level(par, frame_rate) : par->level; - int bit_depth = get_bit_depth(s, par->format); + int bit_depth = get_bit_depth(s, par); int vpx_chroma_subsampling = get_vpx_chroma_subsampling(s, par->format, par->chroma_location); int vpx_video_full_range_flag = get_vpx_video_full_range_flag(par->color_range); - if (bit_depth < 0 || vpx_chroma_subsampling < 0) + if (bit_depth <= 0 || vpx_chroma_subsampling < 0) return AVERROR_INVALIDDATA; if (profile == FF_PROFILE_UNKNOWN) {