]> git.sesse.net Git - ffmpeg/blob - libavcodec/qsvdec_vc1.c
libavformat/matroskaenc: omit segment UID for webm
[ffmpeg] / libavcodec / qsvdec_vc1.c
1 /*
2  * Intel MediaSDK QSV based VC-1 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/fifo.h"
26 #include "libavutil/opt.h"
27
28 #include "avcodec.h"
29 #include "qsvdec.h"
30
31 typedef struct QSVVC1Context {
32     AVClass *class;
33     QSVContext qsv;
34 } QSVVC1Context;
35
36
37 static av_cold int qsv_decode_close(AVCodecContext *avctx)
38 {
39     QSVVC1Context *s = avctx->priv_data;
40
41     ff_qsv_decode_close(&s->qsv);
42
43     return 0;
44 }
45
46 static int qsv_decode_frame(AVCodecContext *avctx, void *data,
47                             int *got_frame, AVPacket *avpkt)
48 {
49     QSVVC1Context *s = avctx->priv_data;
50     AVFrame *frame    = data;
51
52     return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt);
53 }
54
55 static void qsv_decode_flush(AVCodecContext *avctx)
56 {
57     QSVVC1Context *s = avctx->priv_data;
58     ff_qsv_decode_reset(avctx, &s->qsv);
59 }
60
61 AVHWAccel ff_vc1_qsv_hwaccel = {
62     .name           = "vc1_qsv",
63     .type           = AVMEDIA_TYPE_VIDEO,
64     .id             = AV_CODEC_ID_VC1,
65     .pix_fmt        = AV_PIX_FMT_QSV,
66 };
67
68 #define OFFSET(x) offsetof(QSVVC1Context, x)
69 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
70 static const AVOption options[] = {
71     { "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 },
72     { NULL },
73 };
74
75 static const AVClass class = {
76     .class_name = "vc1_qsv",
77     .item_name  = av_default_item_name,
78     .option     = options,
79     .version    = LIBAVUTIL_VERSION_INT,
80 };
81
82 AVCodec ff_vc1_qsv_decoder = {
83     .name           = "vc1_qsv",
84     .long_name      = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync Video acceleration)"),
85     .priv_data_size = sizeof(QSVVC1Context),
86     .type           = AVMEDIA_TYPE_VIDEO,
87     .id             = AV_CODEC_ID_VC1,
88     .init           = NULL,
89     .decode         = qsv_decode_frame,
90     .flush          = qsv_decode_flush,
91     .close          = qsv_decode_close,
92     .capabilities   = AV_CODEC_CAP_DELAY,
93     .priv_class     = &class,
94     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
95                                                     AV_PIX_FMT_QSV,
96                                                     AV_PIX_FMT_NONE },
97 };