1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Intel MediaSDK QSV public API 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * This file is part of FFmpeg. 5cabdff1aSopenharmony_ci * 6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 10cabdff1aSopenharmony_ci * 11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14cabdff1aSopenharmony_ci * Lesser General Public License for more details. 15cabdff1aSopenharmony_ci * 16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19cabdff1aSopenharmony_ci */ 20cabdff1aSopenharmony_ci 21cabdff1aSopenharmony_ci#ifndef AVCODEC_QSV_H 22cabdff1aSopenharmony_ci#define AVCODEC_QSV_H 23cabdff1aSopenharmony_ci 24cabdff1aSopenharmony_ci#include <mfx/mfxvideo.h> 25cabdff1aSopenharmony_ci 26cabdff1aSopenharmony_ci#include "libavutil/buffer.h" 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ci/** 29cabdff1aSopenharmony_ci * This struct is used for communicating QSV parameters between libavcodec and 30cabdff1aSopenharmony_ci * the caller. It is managed by the caller and must be assigned to 31cabdff1aSopenharmony_ci * AVCodecContext.hwaccel_context. 32cabdff1aSopenharmony_ci * - decoding: hwaccel_context must be set on return from the get_format() 33cabdff1aSopenharmony_ci * callback 34cabdff1aSopenharmony_ci * - encoding: hwaccel_context must be set before avcodec_open2() 35cabdff1aSopenharmony_ci */ 36cabdff1aSopenharmony_citypedef struct AVQSVContext { 37cabdff1aSopenharmony_ci /** 38cabdff1aSopenharmony_ci * If non-NULL, the session to use for encoding or decoding. 39cabdff1aSopenharmony_ci * Otherwise, libavcodec will try to create an internal session. 40cabdff1aSopenharmony_ci */ 41cabdff1aSopenharmony_ci mfxSession session; 42cabdff1aSopenharmony_ci 43cabdff1aSopenharmony_ci /** 44cabdff1aSopenharmony_ci * The IO pattern to use. 45cabdff1aSopenharmony_ci */ 46cabdff1aSopenharmony_ci int iopattern; 47cabdff1aSopenharmony_ci 48cabdff1aSopenharmony_ci /** 49cabdff1aSopenharmony_ci * Extra buffers to pass to encoder or decoder initialization. 50cabdff1aSopenharmony_ci */ 51cabdff1aSopenharmony_ci mfxExtBuffer **ext_buffers; 52cabdff1aSopenharmony_ci int nb_ext_buffers; 53cabdff1aSopenharmony_ci 54cabdff1aSopenharmony_ci /** 55cabdff1aSopenharmony_ci * Encoding only. If this field is set to non-zero by the caller, libavcodec 56cabdff1aSopenharmony_ci * will create an mfxExtOpaqueSurfaceAlloc extended buffer and pass it to 57cabdff1aSopenharmony_ci * the encoder initialization. This only makes sense if iopattern is also 58cabdff1aSopenharmony_ci * set to MFX_IOPATTERN_IN_OPAQUE_MEMORY. 59cabdff1aSopenharmony_ci * 60cabdff1aSopenharmony_ci * The number of allocated opaque surfaces will be the sum of the number 61cabdff1aSopenharmony_ci * required by the encoder and the user-provided value nb_opaque_surfaces. 62cabdff1aSopenharmony_ci * The array of the opaque surfaces will be exported to the caller through 63cabdff1aSopenharmony_ci * the opaque_surfaces field. 64cabdff1aSopenharmony_ci */ 65cabdff1aSopenharmony_ci int opaque_alloc; 66cabdff1aSopenharmony_ci 67cabdff1aSopenharmony_ci /** 68cabdff1aSopenharmony_ci * Encoding only, and only if opaque_alloc is set to non-zero. Before 69cabdff1aSopenharmony_ci * calling avcodec_open2(), the caller should set this field to the number 70cabdff1aSopenharmony_ci * of extra opaque surfaces to allocate beyond what is required by the 71cabdff1aSopenharmony_ci * encoder. 72cabdff1aSopenharmony_ci * 73cabdff1aSopenharmony_ci * On return from avcodec_open2(), this field will be set by libavcodec to 74cabdff1aSopenharmony_ci * the total number of allocated opaque surfaces. 75cabdff1aSopenharmony_ci */ 76cabdff1aSopenharmony_ci int nb_opaque_surfaces; 77cabdff1aSopenharmony_ci 78cabdff1aSopenharmony_ci /** 79cabdff1aSopenharmony_ci * Encoding only, and only if opaque_alloc is set to non-zero. On return 80cabdff1aSopenharmony_ci * from avcodec_open2(), this field will be used by libavcodec to export the 81cabdff1aSopenharmony_ci * array of the allocated opaque surfaces to the caller, so they can be 82cabdff1aSopenharmony_ci * passed to other parts of the pipeline. 83cabdff1aSopenharmony_ci * 84cabdff1aSopenharmony_ci * The buffer reference exported here is owned and managed by libavcodec, 85cabdff1aSopenharmony_ci * the callers should make their own reference with av_buffer_ref() and free 86cabdff1aSopenharmony_ci * it with av_buffer_unref() when it is no longer needed. 87cabdff1aSopenharmony_ci * 88cabdff1aSopenharmony_ci * The buffer data is an nb_opaque_surfaces-sized array of mfxFrameSurface1. 89cabdff1aSopenharmony_ci */ 90cabdff1aSopenharmony_ci AVBufferRef *opaque_surfaces; 91cabdff1aSopenharmony_ci 92cabdff1aSopenharmony_ci /** 93cabdff1aSopenharmony_ci * Encoding only, and only if opaque_alloc is set to non-zero. On return 94cabdff1aSopenharmony_ci * from avcodec_open2(), this field will be set to the surface type used in 95cabdff1aSopenharmony_ci * the opaque allocation request. 96cabdff1aSopenharmony_ci */ 97cabdff1aSopenharmony_ci int opaque_alloc_type; 98cabdff1aSopenharmony_ci} AVQSVContext; 99cabdff1aSopenharmony_ci 100cabdff1aSopenharmony_ci/** 101cabdff1aSopenharmony_ci * Allocate a new context. 102cabdff1aSopenharmony_ci * 103cabdff1aSopenharmony_ci * It must be freed by the caller with av_free(). 104cabdff1aSopenharmony_ci */ 105cabdff1aSopenharmony_ciAVQSVContext *av_qsv_alloc_context(void); 106cabdff1aSopenharmony_ci 107cabdff1aSopenharmony_ci#endif /* AVCODEC_QSV_H */ 108