FFmpeg
Loading...
Searching...
No Matches
vdpau_vc1.c
Go to the documentation of this file.
1/*
2 * VC-1 decode acceleration through VDPAU
3 *
4 * Copyright (c) 2008 NVIDIA
5 * Copyright (c) 2013 Rémi Denis-Courmont
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include "config_components.h"
25
26#include <vdpau/vdpau.h>
27
28#include "avcodec.h"
29#include "hwaccel_internal.h"
31#include "vc1.h"
32#include "vdpau.h"
33#include "vdpau_internal.h"
34
36 const AVBufferRef *buffer_ref,
37 const uint8_t *buffer, uint32_t size)
38{
39 VC1Context * const v = avctx->priv_data;
40 MpegEncContext * const s = &v->s;
41 MPVPicture *pic = s->cur_pic.ptr;
43 VdpPictureInfoVC1 *info = &pic_ctx->info.vc1;
44 VdpVideoSurface ref;
45
46 /* fill LvPictureInfoVC1 struct */
47 info->forward_reference = VDP_INVALID_HANDLE;
48 info->backward_reference = VDP_INVALID_HANDLE;
49
50 switch (s->pict_type) {
52 if (s->next_pic.ptr) {
53 ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f);
54 assert(ref != VDP_INVALID_HANDLE);
55 info->backward_reference = ref;
56 }
59 if (s->last_pic.ptr) {
60 ref = ff_vdpau_get_surface_id(s->last_pic.ptr->f);
61 assert(ref != VDP_INVALID_HANDLE);
62 info->forward_reference = ref;
63 }
64 }
65
66 info->slice_count = 0;
67 if (v->bi_type)
68 info->picture_type = 4;
69 else
70 info->picture_type = s->pict_type - 1 + s->pict_type / 3;
71
72 info->frame_coding_mode = v->fcm ? (v->fcm + 1) : 0;
73 info->postprocflag = v->postprocflag;
74 info->pulldown = v->broadcast;
75 info->interlace = v->interlace;
76 info->tfcntrflag = v->tfcntrflag;
77 info->finterpflag = v->finterpflag;
78 info->psf = v->psf;
79 info->dquant = v->dquant;
80 info->panscan_flag = v->panscanflag;
81 info->refdist_flag = v->refdist_flag;
82 info->quantizer = v->quantizer_mode;
83 info->extended_mv = v->extended_mv;
84 info->extended_dmv = v->extended_dmv;
85 info->overlap = v->overlap;
86 info->vstransform = v->vstransform;
87 info->loopfilter = v->loop_filter;
88 info->fastuvmc = v->fastuvmc;
89 info->range_mapy_flag = v->range_mapy_flag;
90 info->range_mapy = v->range_mapy;
91 info->range_mapuv_flag = v->range_mapuv_flag;
92 info->range_mapuv = v->range_mapuv;
93 /* Specific to simple/main profile only */
94 info->multires = v->multires;
95 info->syncmarker = v->resync_marker;
96 info->rangered = v->rangered | (v->rangeredfrm << 1);
97 info->maxbframes = v->max_b_frames;
98 info->deblockEnable = v->postprocflag & 1;
99 info->pquant = v->pq;
100
101 return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
102}
103
105 const uint8_t *buffer, uint32_t size)
106{
107 VC1Context * const v = avctx->priv_data;
108 MpegEncContext * const s = &v->s;
109 MPVPicture *pic = s->cur_pic.ptr;
110 struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
111 int val;
112
113 val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
114 if (val < 0)
115 return val;
116
117 pic_ctx->info.vc1.slice_count++;
118 return 0;
119}
120
122{
123 VdpDecoderProfile profile;
124
125 switch (avctx->profile) {
127 profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
128 break;
130 profile = VDP_DECODER_PROFILE_VC1_MAIN;
131 break;
133 profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
134 break;
135 default:
136 return AVERROR(ENOTSUP);
137 }
138
139 return ff_vdpau_common_init(avctx, profile, avctx->level);
140}
141
142#if CONFIG_WMV3_VDPAU_HWACCEL
144 .p.name = "wm3_vdpau",
145 .p.type = AVMEDIA_TYPE_VIDEO,
146 .p.id = AV_CODEC_ID_WMV3,
147 .p.pix_fmt = AV_PIX_FMT_VDPAU,
148 .start_frame = vdpau_vc1_start_frame,
149 .end_frame = ff_vdpau_mpeg_end_frame,
150 .decode_slice = vdpau_vc1_decode_slice,
151 .frame_priv_data_size = sizeof(struct vdpau_picture_context),
153 .uninit = ff_vdpau_common_uninit,
154 .frame_params = ff_vdpau_common_frame_params,
155 .priv_data_size = sizeof(VDPAUContext),
156 .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
157};
158#endif
159
161 .p.name = "vc1_vdpau",
162 .p.type = AVMEDIA_TYPE_VIDEO,
163 .p.id = AV_CODEC_ID_VC1,
164 .p.pix_fmt = AV_PIX_FMT_VDPAU,
165 .start_frame = vdpau_vc1_start_frame,
166 .end_frame = ff_vdpau_mpeg_end_frame,
167 .decode_slice = vdpau_vc1_decode_slice,
168 .frame_priv_data_size = sizeof(struct vdpau_picture_context),
170 .uninit = ff_vdpau_common_uninit,
171 .frame_params = ff_vdpau_common_frame_params,
172 .priv_data_size = sizeof(VDPAUContext),
173 .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
174};
static double val(void *priv, double ch)
Definition aeval.c:77
Libavcodec external API header.
#define s(width, name)
Definition cbs_vp9.c:198
#define AV_PROFILE_VC1_ADVANCED
Definition defs.h:129
#define AV_PROFILE_VC1_SIMPLE
Definition defs.h:126
#define AV_PROFILE_VC1_MAIN
Definition defs.h:127
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
av_cold int ff_vdpau_common_uninit(AVCodecContext *avctx)
Definition vdpau.c:278
int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition vdpau.c:316
av_cold int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, int level)
Definition vdpau.c:127
int ff_vdpau_add_buffer(struct vdpau_picture_context *pic_ctx, const uint8_t *buf, uint32_t size)
Definition vdpau.c:373
int ff_vdpau_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition vdpau.c:108
@ AV_CODEC_ID_VC1
Definition codec_id.h:120
@ AV_CODEC_ID_WMV3
Definition codec_id.h:121
#define AVERROR(e)
Definition error.h:45
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AV_PICTURE_TYPE_P
Predicted.
Definition avutil.h:279
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition avutil.h:280
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
const struct FFHWAccel ff_wmv3_vdpau_hwaccel
const struct FFHWAccel ff_vc1_vdpau_hwaccel
Definition vdpau_vc1.c:160
Macro definitions for various function/variable attributes.
#define av_fallthrough
Definition attributes.h:67
#define av_cold
Definition attributes.h:117
int profile
Definition mxfenc.c:2299
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
Definition pixfmt.h:194
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
int level
Encoding level descriptor.
Definition avcodec.h:1646
int profile
profile
Definition avcodec.h:1636
void * priv_data
Definition avcodec.h:470
MPVPicture.
Definition mpegpicture.h:58
void * hwaccel_picture_private
RefStruct reference for hardware accelerator private data.
Definition mpegpicture.h:75
MpegEncContext.
Definition mpegvideo.h:67
The VC1 Context.
Definition vc1.h:176
int loop_filter
Definition vc1.h:223
int tfcntrflag
TFCNTR present.
Definition vc1.h:204
int dquant
How qscale varies with MBs, 2 bits (not in Simple)
Definition vc1.h:227
int multires
frame-level RESPIC syntax element present
Definition vc1.h:188
int finterpflag
INTERPFRM present.
Definition vc1.h:232
uint8_t range_mapuv_flag
Definition vc1.h:333
int extended_mv
Ext MV in P/B (not in Simple)
Definition vc1.h:226
uint8_t range_mapy_flag
Definition vc1.h:332
int bi_type
Definition vc1.h:389
uint8_t range_mapy
Definition vc1.h:334
uint8_t pq
Definition vc1.h:242
int extended_dmv
Additional extended dmv range at P/B-frame-level.
Definition vc1.h:207
int panscanflag
NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present.
Definition vc1.h:205
int psf
Progressive Segmented Frame.
Definition vc1.h:213
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
Definition vc1.h:312
int quantizer_mode
2 bits, quantizer mode used for sequence, see QUANT_*
Definition vc1.h:231
int broadcast
TFF/RFF present.
Definition vc1.h:202
int refdist_flag
REFDIST syntax element present in II, IP, PI or PP field picture headers.
Definition vc1.h:206
int max_b_frames
max number of B-frames
Definition vc1.h:230
MpegEncContext s
Definition vc1.h:177
int overlap
overlapped transforms in use
Definition vc1.h:229
uint8_t range_mapuv
Definition vc1.h:335
int postprocflag
Per-frame processing suggestion flag present.
Definition vc1.h:201
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
Definition vc1.h:318
int interlace
Progressive/interlaced (RPTFTM syntax element)
Definition vc1.h:203
int resync_marker
could this stream contain resync markers
Definition vc1.h:404
int fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
Definition vc1.h:225
int rangered
RANGEREDFRM (range reduction) syntax element present at frame level.
Definition vc1.h:191
int vstransform
variable-size [48]x[48] transform type + info
Definition vc1.h:228
union VDPAUPictureInfo info
VDPAU picture information.
static int ref[MAX_W *MAX_W]
static char buffer[20]
Definition seek.c:32
int size
VdpPictureInfoVC1 vc1
Public libavcodec VDPAU header.
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
static uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
Extract VdpVideoSurface from an AVFrame.
static int vdpau_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition vdpau_vc1.c:104
static int vdpau_vc1_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, const uint8_t *buffer, uint32_t size)
Definition vdpau_vc1.c:35
static av_cold int vdpau_vc1_init(AVCodecContext *avctx)
Definition vdpau_vc1.c:121