From patchwork Thu Mar 4 15:42:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26095 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 66AD2449EC7 for ; Thu, 4 Mar 2021 17:43:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5281768ABC8; Thu, 4 Mar 2021 17:43:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7A5868AB90 for ; Thu, 4 Mar 2021 17:43:10 +0200 (EET) Received: by mail-ed1-f46.google.com with SMTP id h10so35386975edl.6 for ; Thu, 04 Mar 2021 07:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=QpFhXEWhKW38DTvZ2+OfP8JAKLiEeaP+DXC5cNvJLzE=; b=SfmYN2xB7Gr8s9QbgJ0e3kzjSdIM57aEEHkL5FQLVppQ37yJ3sQ2CG1sr/6J0NH7dh B+P6Z9UVjCycSEPUbZOXD+2FRN9zd1k8uEyQ0ysFZsQfGe/HmhS/tTak7yxk73XsnuHE cNIfqwyD/ufmsLxOxL+oT6Q8xA3sqBuOPmMvOrJCBadwyrsm/F1O3MraiA/TJf0vG1jt S+FNBHE1FEMS7p+1PeCbBycZ5zCZFJ87jmmOqmt6v8xDSbHbpf8Y2bGlxsQZlnczIzdW 3OMgJGmGaI+2Pindo8a3FqfSxYziyFYXZ10RmNpWPo7dsetnIWjJhP0VIGWdfS+42r7/ r7+Q== 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:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=QpFhXEWhKW38DTvZ2+OfP8JAKLiEeaP+DXC5cNvJLzE=; b=c3Xoy2MSZePAoNKijxkPQJYZYLlXCuW4RaiQCSgRhkYMhesdWlJJ4xv7niRmh0xyYF nLxZcSqggGkYlEovIn6V2AXN7cEJAC/cwW6S2/T9//+xXMgXvLBoe9T+K05mqFjEvFyX HBagt7GH5ORdDZe96T1iznQz75lpmxG/UA91cM2lDmXyUrs9GyoVQzW1W+6MhEU2XwTK V3EOdvOx9bkCwnTLCUShdg69ebkfmW21rM4uH10SXM1DCZNNrqb0HoiSaLb+fZ3Z6U0A OUu1QFX6cSQ/QXblJHTod+1zqKPL6axmKzvDGTdhOfgV/e4fLcVFHPEJyBuwcK67aqFQ FTzQ== X-Gm-Message-State: AOAM5327/84fVSKPC90+ENqhfLH8hIl/cDwLP59OJcVhk/WmgXqo3iMj yqQjQaTxuMN0C6ABuaGJ5Nen0Y9Lo60= X-Google-Smtp-Source: ABdhPJxLHW6gppCtnTzff6Bjc6qZu4sONGnGkB6jdCDqrxRnrYxZ/3cvNCv0k/CgmX5OIEsjAa1iKw== X-Received: by 2002:a05:6402:3083:: with SMTP id de3mr5000140edb.241.1614872590008; Thu, 04 Mar 2021 07:43:10 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id y24sm22673391eds.23.2021.03.04.07.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 07:43:09 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Mar 2021 16:42:33 +0100 Message-Id: <20210304154233.934640-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210304154233.934640-1-andreas.rheinhardt@gmail.com> References: <20210304154233.934640-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] avcodec/qsvdec: Make functions used only here static, remove header 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Forgotten after d78ecf10bd745cb69a71b32419e0661bfdcfb1fd. (Also mark some AVPackets as const.) Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 1 - libavcodec/qsvdec.c | 83 +++++++++++++++++++++++++++++++------------ libavcodec/qsvdec.h | 86 --------------------------------------------- 3 files changed, 60 insertions(+), 110 deletions(-) delete mode 100644 libavcodec/qsvdec.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b7e456b59f..3607001639 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1204,7 +1204,6 @@ SKIPHEADERS-$(CONFIG_MEDIAFOUNDATION) += mf_utils.h SKIPHEADERS-$(CONFIG_NVDEC) += nvdec.h SKIPHEADERS-$(CONFIG_NVENC) += nvenc.h SKIPHEADERS-$(CONFIG_QSV) += qsv.h qsv_internal.h -SKIPHEADERS-$(CONFIG_QSVDEC) += qsvdec.h SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_hevc.h vaapi_encode.h diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index d10f90a0db..5f2e641373 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -21,18 +21,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include #include "libavutil/common.h" +#include "libavutil/fifo.h" +#include "libavutil/frame.h" #include "libavutil/hwcontext.h" #include "libavutil/hwcontext_qsv.h" #include "libavutil/mem.h" #include "libavutil/log.h" #include "libavutil/opt.h" -#include "libavutil/pixdesc.h" #include "libavutil/pixfmt.h" #include "libavutil/time.h" #include "libavutil/imgutils.h" @@ -40,11 +42,49 @@ #include "avcodec.h" #include "internal.h" #include "decode.h" +#include "hwconfig.h" #include "qsv.h" #include "qsv_internal.h" -#include "qsvdec.h" -const AVCodecHWConfigInternal *const ff_qsv_hw_configs[] = { +typedef struct QSVContext { + // the session used for decoding + mfxSession session; + + // the session we allocated internally, in case the caller did not provide + // one + QSVSession internal_qs; + + QSVFramesContext frames_ctx; + + /** + * a linked list of frames currently being used by QSV + */ + QSVFrame *work_frames; + + AVFifoBuffer *async_fifo; + int zero_consume_run; + int buffered_count; + int reinit_flag; + + enum AVPixelFormat orig_pix_fmt; + uint32_t fourcc; + mfxFrameInfo frame_info; + AVBufferPool *pool; + + int initialized; + + // options set by the caller + int async_depth; + int iopattern; + int gpu_copy; + + char *load_plugins; + + mfxExtBuffer **ext_buffers; + int nb_ext_buffers; +} QSVContext; + +static const AVCodecHWConfigInternal *const qsv_hw_configs[] = { &(const AVCodecHWConfigInternal) { .public = { .pix_fmt = AV_PIX_FMT_QSV, @@ -57,7 +97,8 @@ const AVCodecHWConfigInternal *const ff_qsv_hw_configs[] = { NULL }; -static int ff_qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, AVBufferPool *pool) +static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, + AVBufferPool *pool) { int ret = 0; @@ -255,7 +296,9 @@ static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q, mfxVide return 0; } -static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt, enum AVPixelFormat pix_fmt, mfxVideoParam *param) +static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, + const AVPacket *avpkt, enum AVPixelFormat pix_fmt, + mfxVideoParam *param) { int ret; @@ -299,7 +342,7 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame) int ret; if (q->pool) - ret = ff_qsv_get_continuous_buffer(avctx, frame->frame, q->pool); + ret = qsv_get_continuous_buffer(avctx, frame->frame, q->pool); else ret = ff_get_buffer(avctx, frame->frame, AV_GET_BUFFER_FLAG_REF); @@ -400,7 +443,7 @@ static QSVFrame *find_frame(QSVContext *q, mfxFrameSurface1 *surf) static int qsv_decode(AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, - AVPacket *avpkt) + const AVPacket *avpkt) { QSVFrame *out_frame; mfxFrameSurface1 *insurf; @@ -531,7 +574,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return bs.DataOffset; } -int ff_qsv_decode_close(QSVContext *q) +static void qsv_decode_close_qsvcontext(QSVContext *q) { QSVFrame *cur = q->work_frames; @@ -563,12 +606,10 @@ int ff_qsv_decode_close(QSVContext *q) av_buffer_unref(&q->frames_ctx.hw_frames_ctx); av_buffer_unref(&q->frames_ctx.mids_buf); av_buffer_pool_uninit(&q->pool); - - return 0; } -int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, - AVFrame *frame, int *got_frame, AVPacket *pkt) +static int qsv_process_data(AVCodecContext *avctx, QSVContext *q, + AVFrame *frame, int *got_frame, const AVPacket *pkt) { int ret; mfxVideoParam param = { 0 }; @@ -629,12 +670,6 @@ reinit_fail: return ret; } -void ff_qsv_decode_flush(AVCodecContext *avctx, QSVContext *q) -{ - q->orig_pix_fmt = AV_PIX_FMT_NONE; - q->initialized = 0; -} - enum LoadPlugin { LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_SW, @@ -669,7 +704,7 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx) av_freep(&s->qsv.load_plugins); - ff_qsv_decode_close(&s->qsv); + qsv_decode_close_qsvcontext(&s->qsv); qsv_clear_buffers(s); @@ -754,7 +789,7 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data, if (s->buffer_pkt.size <= 0) { /* no more data */ if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket)) - return avpkt->size ? avpkt->size : ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, avpkt); + return avpkt->size ? avpkt->size : qsv_process_data(avctx, &s->qsv, frame, got_frame, avpkt); /* in progress of reinit, no read from fifo and keep the buffer_pkt */ if (!s->qsv.reinit_flag) { av_packet_unref(&s->buffer_pkt); @@ -762,7 +797,7 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data, } } - ret = ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->buffer_pkt); + ret = qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->buffer_pkt); if (ret < 0){ /* Drop buffer_pkt when failed to decode the packet. Otherwise, the decoder will keep decoding the failure packet. */ @@ -784,7 +819,9 @@ static void qsv_decode_flush(AVCodecContext *avctx) QSVDecContext *s = avctx->priv_data; qsv_clear_buffers(s); - ff_qsv_decode_flush(avctx, &s->qsv); + + s->qsv.orig_pix_fmt = AV_PIX_FMT_NONE; + s->qsv.initialized = 0; } #define OFFSET(x) offsetof(QSVDecContext, x) @@ -814,7 +851,7 @@ AVCodec ff_##x##_qsv_decoder = { \ AV_PIX_FMT_P010, \ AV_PIX_FMT_QSV, \ AV_PIX_FMT_NONE }, \ - .hw_configs = ff_qsv_hw_configs, \ + .hw_configs = qsv_hw_configs, \ .wrapper_name = "qsv", \ }; \ diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h deleted file mode 100644 index f3b7344cba..0000000000 --- a/libavcodec/qsvdec.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Intel MediaSDK QSV utility functions - * - * copyright (c) 2013 Luca Barbato - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_QSVDEC_H -#define AVCODEC_QSVDEC_H - -#include -#include - -#include - -#include "libavutil/fifo.h" -#include "libavutil/frame.h" -#include "libavutil/pixfmt.h" - -#include "avcodec.h" -#include "hwconfig.h" -#include "qsv_internal.h" - -typedef struct QSVContext { - // the session used for decoding - mfxSession session; - - // the session we allocated internally, in case the caller did not provide - // one - QSVSession internal_qs; - - QSVFramesContext frames_ctx; - - /** - * a linked list of frames currently being used by QSV - */ - QSVFrame *work_frames; - - AVFifoBuffer *async_fifo; - int zero_consume_run; - int buffered_count; - int reinit_flag; - - enum AVPixelFormat orig_pix_fmt; - uint32_t fourcc; - mfxFrameInfo frame_info; - AVBufferPool *pool; - - int initialized; - - // options set by the caller - int async_depth; - int iopattern; - int gpu_copy; - - char *load_plugins; - - mfxExtBuffer **ext_buffers; - int nb_ext_buffers; -} QSVContext; - -extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[]; - -int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, - AVFrame *frame, int *got_frame, AVPacket *pkt); - -void ff_qsv_decode_flush(AVCodecContext *avctx, QSVContext *q); - -int ff_qsv_decode_close(QSVContext *q); - -#endif /* AVCODEC_QSVDEC_H */