From patchwork Wed Apr 10 22:33:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Rusak X-Patchwork-Id: 12697 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 B14DC448C51 for ; Thu, 11 Apr 2019 01:39:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F0D368AD30; Thu, 11 Apr 2019 01:39:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A1FF068AD30 for ; Thu, 11 Apr 2019 01:38:56 +0300 (EEST) Received: by mail-pl1-f179.google.com with SMTP id f36so2282107plb.5 for ; Wed, 10 Apr 2019 15:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=PeWJU9dYs369ki86GYU9AcBor0Xi2KygdA5c6g6Ermk=; b=gn5B5m2bQSdslyplSWGQM22/YobDPQFyLOVVNbA6+ccy7CTCk+hOqv4hGXGIIB04oL Qm+uqVa85U30d+kyhgF8vVkbmVn/1IE2O/3Fvn4biymO7+EOk/9FZBvBbPE664YZPm+l xtIkWZkd9mnHHey31swY+77/I3sEzIkPZtuPvV9MRGw15tqG8eiiw2ZTaZZ4SXM2nM8I 7rvJBeqM8to0c9nFHeZ1hg4jEl11p99Usv2ZnnPbZLkRXASlxpCDiqb6v7y2fs21F+xo vvuUdN7+poqGDtXXgMdCa00wj7h3OEZlf6a4Hv8dxgwG/EXA0e5vkcA5KCWqSSywtp1J Ys9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=PeWJU9dYs369ki86GYU9AcBor0Xi2KygdA5c6g6Ermk=; b=p3dqyHagj6IZtCn3Qanj2E18oOK6RGG5OyWCMlMKVF2B0ecr4SEJhR9c8Z8jqEapFK aUy7xixRVEGoMXYQL2NFD72V1Xkr0lTeGRLfrkjJYO7WJcG/eN0nVb9bhWNc4fjgQn0U g7Fu8JZDwDQ4uMUEXT55ZZD2uun4wnCHWNC1Ate28qJOesKC0ZNl7CLvN/P4QgP8GwBi /ZTRvr54s07tuMceZIN8bAd2Ow3VtyM/7UFSuHlt73VRHtBZ0eWnw+k81mSn8izqkYUY R7aRF9wjhU0kZfbDZtK9EPlnpog69zEGyeY+Pl2l4y2Dc14CTezEwp3kFLXJegtAcdIG sMXA== X-Gm-Message-State: APjAAAVtPWWtE1Ae/j4pr6j1JpHL/51CaHuUDSwQmSzDyrca0xKLPqc6 o/ZldEKIz2Qjm/4hoNAEeU5/ifVIrHs= X-Google-Smtp-Source: APXvYqxV1hZ/RpOrJ950k6xMC9O8Bqe+MYwbd1FVsZjwMw4TcqmRYIb+nWdYk1l6ymITxvX1cv6G5A== X-Received: by 2002:a17:902:e683:: with SMTP id cn3mr45999882plb.115.1554935595797; Wed, 10 Apr 2019 15:33:15 -0700 (PDT) Received: from localhost.localdomain (d75-157-157-79.bchsia.telus.net. [75.157.157.79]) by smtp.gmail.com with ESMTPSA id v19sm66154324pfa.138.2019.04.10.15.33.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2019 15:33:15 -0700 (PDT) From: Lukas Rusak To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2019 15:33:14 -0700 Message-Id: <20190410223314.11735-1-lorusak@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavcodec/libdav1d: add libdav1d_get_format method to call ff_get_format 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This will allow applications to properly init the decoder in cases where a hardware decoder is tried first and and software decoder is tried after by calling the get_format callback. Even though there is no hardware pixel formats available we still need to return the software pixel format. Tested with Kodi by checking if multithreaded software decoding is properly activated. --- libavcodec/libdav1d.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 30c6eccfef..fa71834543 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -48,6 +48,16 @@ static const enum AVPixelFormat pix_fmt[][3] = { [DAV1D_PIXEL_LAYOUT_I444] = { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12 }, }; +static enum AVPixelFormat libdav1d_get_format(AVCodecContext *avctx, const Dav1dPicture *p) +{ + enum AVPixelFormat pix_fmts[2], *fmt = pix_fmts; + + *fmt++ = pix_fmt[p->p.layout][p->seq_hdr->hbd]; + *fmt = AV_PIX_FMT_NONE; + + return ff_get_format(avctx, pix_fmts); +} + static void libdav1d_log_callback(void *opaque, const char *fmt, va_list vl) { AVCodecContext *c = opaque; @@ -214,7 +224,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) frame->linesize[2] = p->stride[1]; c->profile = p->seq_hdr->profile; - frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd]; + frame->format = c->pix_fmt = libdav1d_get_format(c, p); frame->width = p->p.w; frame->height = p->p.h; if (c->width != p->p.w || c->height != p->p.h) {