From patchwork Thu Feb 11 17:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 25576 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 83E0D44A462 for ; Thu, 11 Feb 2021 20:01:47 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 63E7468AB46; Thu, 11 Feb 2021 20:01:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CAE2F68A22C for ; Thu, 11 Feb 2021 20:01:40 +0200 (EET) Received: by mail-ed1-f50.google.com with SMTP id y18so7853993edw.13 for ; Thu, 11 Feb 2021 10:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=3IyaCOXPNepSegw3kBgRVrPRSwMFD7l8MPRysS3LhEo=; b=drNyi162Sit7NqFISTU03uwSPuSOPZReW8a3cjnmpwTTrb71OSosCyl2VqZkWpshT2 XkUxL9xenoHyO5h4hRihZe1M5yKx4P3zB9RDOZ8YXcZR1hn8ID0F+3Y2X9ITSOMnGOBf 94QeZP0yRKrDdzas8g+0bwx1FqlCTk9IyhY7vUCcc+p1HNoUNJz4lG7Xoib778RcXU7E ozrMxW+jUyHNsGS9+G5+VFopKxs7zeTYP8S2brCENbtSWUrV71rg63qh7ab0/+osduwT BUb+nZKFySBI/4DvDRLP39dUcRTSEjmKVSNqDMDEYv0r97z9vy9zHw0d//ReAtLPbARl JKVw== 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; bh=3IyaCOXPNepSegw3kBgRVrPRSwMFD7l8MPRysS3LhEo=; b=q7CqgfS+CyhUTZmUynLffKX5T96LeM5aWIiIhoxklo5FSddR6aJFM0avpB501vbqqu NUZenYRN2clYOrPpWAEnJHfkJImFpmIEFxmtrZDt0Mdsa2VAFk/bclaiPZkbh9EYVdnN JKUNq/zMnbKreLsARPnbujSU9/t+pV7PuPkqdhNAKcANq8LXVE4/segrrmdB2CYamXrZ gdF1aUy9MMp7mnFynE8FG1uO/IBOm+EvJGAhCV2yuY5DabbnlwqFzjmuMRlOvo1Vf7g5 g6v1BXqnK/Lme/3xEHMI6FiNiGj+0eT6SQDzDhD9EISvbkBUtmFKpnUbYaUvjfu5qT1b NZ9A== X-Gm-Message-State: AOAM5321BRblpgQ+vLN6obYl5591c73R0LRj7D63F3+aNbk4K2Ikc1df pm/abP3uvv4zliqgmbX9SDACqdLKTLPOMw== X-Google-Smtp-Source: ABdhPJxT7OcqEChspopsB9ml2+jhYYVlHdZsUHe5D4D7d5/p8hXXsPTIdAFwklNfWzWXl3wmiZPXTQ== X-Received: by 2002:a05:6402:3198:: with SMTP id di24mr9382368edb.340.1613066010047; Thu, 11 Feb 2021 09:53:30 -0800 (PST) Received: from localhost.localdomain ([212.15.167.195]) by smtp.gmail.com with ESMTPSA id i18sm4665455eds.19.2021.02.11.09.53.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 09:53:29 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Feb 2021 18:53:19 +0100 Message-Id: <20210211175320.1045-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/dpx: add float support for single components and rgb(a) 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavcodec/dpx.c | 71 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 12bc165415..702caa385e 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -159,8 +159,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *const p = data; uint8_t *ptr[AV_NUM_DATA_POINTERS]; uint32_t header_version, version = 0; - char creator[101]; - char input_device[33]; + char creator[101] = { 0 }; + char input_device[33] = { 0 }; unsigned int offset; int magic_num, endian; @@ -327,6 +327,10 @@ static int decode_frame(AVCodecContext *avctx, } switch (descriptor) { + case 1: // R + case 2: // G + case 3: // B + case 4: // A case 6: // Y elements = 1; yuv = 1; @@ -385,8 +389,10 @@ static int decode_frame(AVCodecContext *avctx, case 16: stride = 2 * avctx->width * elements; break; - case 1: case 32: + stride = 4 * avctx->width * elements; + break; + case 1: case 64: avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color); return AVERROR_PATCHWELCOME; @@ -499,6 +505,20 @@ static int decode_frame(AVCodecContext *avctx, case 6120: avctx->pix_fmt = AV_PIX_FMT_GRAY12; break; + case 1320: + case 2320: + case 3320: + case 4320: + case 6320: + avctx->pix_fmt = AV_PIX_FMT_GRAYF32LE; + break; + case 1321: + case 2321: + case 3321: + case 4321: + case 6321: + avctx->pix_fmt = AV_PIX_FMT_GRAYF32BE; + break; case 50081: case 50080: avctx->pix_fmt = AV_PIX_FMT_RGB24; @@ -549,6 +569,18 @@ static int decode_frame(AVCodecContext *avctx, case 51160: avctx->pix_fmt = AV_PIX_FMT_RGBA64LE; break; + case 50320: + avctx->pix_fmt = AV_PIX_FMT_GBRPF32LE; + break; + case 50321: + avctx->pix_fmt = AV_PIX_FMT_GBRPF32BE; + break; + case 51320: + avctx->pix_fmt = AV_PIX_FMT_GBRAPF32LE; + break; + case 51321: + avctx->pix_fmt = AV_PIX_FMT_GBRAPF32BE; + break; case 100081: avctx->pix_fmt = AV_PIX_FMT_UYVY422; break; @@ -559,7 +591,8 @@ static int decode_frame(AVCodecContext *avctx, avctx->pix_fmt = AV_PIX_FMT_YUVA444P; break; default: - av_log(avctx, AV_LOG_ERROR, "Unsupported format\n"); + av_log(avctx, AV_LOG_ERROR, "Unsupported format %d\n", + 1000 * descriptor + 10 * bits_per_color + endian); return AVERROR_PATCHWELCOME; } @@ -657,6 +690,36 @@ static int decode_frame(AVCodecContext *avctx, buf += need_align; } break; + case 32: + if (elements == 1) { + av_image_copy_plane(ptr[0], p->linesize[0], + buf, stride, + elements * avctx->width * 4, avctx->height); + } else { + for (y = 0; y < avctx->height; y++) { + ptr[0] = p->data[0] + y * p->linesize[0]; + ptr[1] = p->data[1] + y * p->linesize[1]; + ptr[2] = p->data[2] + y * p->linesize[2]; + ptr[3] = p->data[3] + y * p->linesize[3]; + for (x = 0; x < avctx->width; x++) { + AV_WN32(ptr[2], AV_RN32(buf)); + AV_WN32(ptr[0], AV_RN32(buf + 4)); + AV_WN32(ptr[1], AV_RN32(buf + 8)); + if (avctx->pix_fmt == AV_PIX_FMT_GBRAPF32BE || + avctx->pix_fmt == AV_PIX_FMT_GBRAPF32LE) { + AV_WN32(ptr[3], AV_RN32(buf + 12)); + buf += 4; + ptr[3] += 4; + } + + buf += 12; + ptr[2] += 4; + ptr[0] += 4; + ptr[1] += 4; + } + } + } + break; case 16: elements *= 2; case 8: