FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qsvdec_mpeg2.c
Go to the documentation of this file.
1 /*
2  * Intel MediaSDK QSV based MPEG-2 video decoder
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stdint.h>
22 #include <string.h>
23 
24 #include "libavutil/common.h"
25 #include "libavutil/opt.h"
26 
27 #include "avcodec.h"
28 #include "qsvdec.h"
29 
30 typedef struct QSVMPEG2Context {
31  AVClass *class;
34 
36 {
37  QSVMPEG2Context *s = avctx->priv_data;
38 
40 
41  return 0;
42 }
43 
45 {
46  return 0;
47 }
48 
49 static int qsv_decode_frame(AVCodecContext *avctx, void *data,
50  int *got_frame, AVPacket *avpkt)
51 {
52  QSVMPEG2Context *s = avctx->priv_data;
53  AVFrame *frame = data;
54 
55  return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt);
56 }
57 
58 static void qsv_decode_flush(AVCodecContext *avctx)
59 {
60  QSVMPEG2Context *s = avctx->priv_data;
61  ff_qsv_decode_reset(avctx, &s->qsv);
62 }
63 
65  .name = "mpeg2_qsv",
66  .type = AVMEDIA_TYPE_VIDEO,
68  .pix_fmt = AV_PIX_FMT_QSV,
69 };
70 
71 #define OFFSET(x) offsetof(QSVMPEG2Context, x)
72 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
73 static const AVOption options[] = {
74  { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD },
75  { NULL },
76 };
77 
78 static const AVClass class = {
79  .class_name = "mpeg2_qsv",
80  .item_name = av_default_item_name,
81  .option = options,
83 };
84 
86  .name = "mpeg2_qsv",
87  .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"),
88  .priv_data_size = sizeof(QSVMPEG2Context),
94  .close = qsv_decode_close,
95  .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
96  .priv_class = &class,
97  .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
100 };
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:631
int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: qsvdec.c:493
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
AVOption.
Definition: opt.h:245
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
static void flush(AVCodecContext *avctx)
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
AVCodec.
Definition: avcodec.h:3542
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:981
void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)
Definition: qsvdec.c:549
#define av_cold
Definition: attributes.h:82
AVOptions.
int ff_qsv_decode_close(QSVContext *q)
Definition: qsvdec.c:592
static AVFrame * frame
static void qsv_decode_flush(AVCodecContext *avctx)
Definition: qsvdec_mpeg2.c:58
static const AVOption options[]
Definition: qsvdec_mpeg2.c:73
av_default_item_name
AVCodec ff_mpeg2_qsv_decoder
Definition: qsvdec_mpeg2.c:85
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
QSVContext qsv
Definition: qsvdec_mpeg2.c:32
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:90
#define VD
Definition: qsvdec_mpeg2.c:72
const char * name
Name of the codec implementation.
Definition: avcodec.h:3549
AVHWAccel ff_mpeg2_qsv_hwaccel
Definition: qsvdec_mpeg2.c:64
#define ASYNC_DEPTH_DEFAULT
Definition: qsv_internal.h:48
static av_cold int qsv_decode_init(AVCodecContext *avctx)
Definition: qsvdec_mpeg2.c:44
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:3668
static av_cold int qsv_decode_close(AVCodecContext *avctx)
Definition: qsvdec_mpeg2.c:35
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:194
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1649
GLint GLenum type
Definition: opengl_enc.c:105
Describe the class of an AVClass context structure.
Definition: log.h:67
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:235
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:722
common internal and external API header
void * priv_data
Definition: avcodec.h:1691
#define OFFSET(x)
Definition: qsvdec_mpeg2.c:71
static int qsv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: qsvdec_mpeg2.c:49
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
This structure stores compressed data.
Definition: avcodec.h:1557
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:956