56 case VDP_STATUS_NO_IMPLEMENTATION:
58 case VDP_STATUS_DISPLAY_PREEMPTED:
60 case VDP_STATUS_INVALID_HANDLE:
62 case VDP_STATUS_INVALID_POINTER:
64 case VDP_STATUS_RESOURCES:
66 case VDP_STATUS_HANDLE_DEVICE_MISMATCH:
68 case VDP_STATUS_ERROR:
87 uint32_t w = avctx->coded_width;
88 uint32_t
h = avctx->coded_height;
91 switch (avctx->sw_pix_fmt) {
94 t = VDP_CHROMA_TYPE_420;
100 t = VDP_CHROMA_TYPE_422;
106 t = VDP_CHROMA_TYPE_444;
127 VdpVideoSurfaceQueryCapabilities *surface_query_caps;
128 VdpDecoderQueryCapabilities *decoder_query_caps;
133 uint32_t max_level, max_mb, max_width, max_height;
138 vdctx->width = UINT32_MAX;
139 vdctx->height = UINT32_MAX;
142 vdctx->device = VDP_INVALID_HANDLE;
143 av_log(avctx,
AV_LOG_WARNING,
"hwaccel_context has not been setup by the user application, cannot initialize\n");
147 if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
148 vdctx->decoder = hwctx->context.decoder;
149 vdctx->render = hwctx->context.render;
150 vdctx->device = VDP_INVALID_HANDLE;
155 vdctx->device = hwctx->device;
156 vdctx->get_proc_address = hwctx->get_proc_address;
167 type != VDP_CHROMA_TYPE_420)
170 status = vdctx->get_proc_address(vdctx->device,
171 VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
173 if (status != VDP_STATUS_OK)
176 surface_query_caps =
func;
178 status = surface_query_caps(vdctx->device, type, &supported,
179 &max_width, &max_height);
180 if (status != VDP_STATUS_OK)
182 if (supported != VDP_TRUE ||
183 max_width < width || max_height < height)
186 status = vdctx->get_proc_address(vdctx->device,
187 VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
189 if (status != VDP_STATUS_OK)
192 decoder_query_caps =
func;
194 status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
195 &max_mb, &max_width, &max_height);
196 #ifdef VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE
197 if ((status != VDP_STATUS_OK || supported != VDP_TRUE) && profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE) {
198 profile = VDP_DECODER_PROFILE_H264_MAIN;
199 status = decoder_query_caps(vdctx->device, profile, &supported,
201 &max_width, &max_height);
204 if (status != VDP_STATUS_OK)
207 if (supported != VDP_TRUE || max_level < level ||
208 max_width < width || max_height < height)
211 status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
213 if (status != VDP_STATUS_OK)
218 status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
220 if (status != VDP_STATUS_OK)
223 vdctx->render =
func;
225 status =
create(vdctx->device, profile, width, height, avctx->
refs,
227 if (status == VDP_STATUS_OK) {
242 if (vdctx->device == VDP_INVALID_HANDLE)
244 if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
247 status = vdctx->get_proc_address(vdctx->device,
248 VDP_FUNC_ID_DECODER_DESTROY, &func);
249 if (status != VDP_STATUS_OK)
254 status =
destroy(vdctx->decoder);
263 if (vdctx->device == VDP_INVALID_HANDLE)
277 pic_ctx->bitstream_buffers_allocated = 0;
278 pic_ctx->bitstream_buffers_used = 0;
279 pic_ctx->bitstream_buffers =
NULL;
284 struct vdpau_picture_context *pic_ctx)
296 #if FF_API_BUFS_VDPAU
299 memcpy(&hwctx->
info, &pic_ctx->info,
sizeof(hwctx->
info));
307 status = hwctx->
render2(avctx, frame, (
void *)&pic_ctx->info,
308 pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
310 status = vdctx->render(vdctx->decoder, surf, (
void *)&pic_ctx->info,
311 pic_ctx->bitstream_buffers_used,
312 pic_ctx->bitstream_buffers);
314 av_freep(&pic_ctx->bitstream_buffers);
316 #if FF_API_BUFS_VDPAU
327 #if CONFIG_MPEG1_VDPAU_HWACCEL || \
328 CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
329 CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
349 VdpBitstreamBuffer *
buffers = pic_ctx->bitstream_buffers;
351 buffers =
av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
352 (pic_ctx->bitstream_buffers_used + 1) *
sizeof(*buffers));
356 pic_ctx->bitstream_buffers =
buffers;
357 buffers += pic_ctx->bitstream_buffers_used++;
359 buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
360 buffers->bitstream =
buf;
361 buffers->bitstream_bytes =
size;
385 #if CONFIG_H264_VDPAU_DECODER
389 VdpReferenceFrameH264 *rf, *rf2;
391 int i, list, pic_frame_idx;
396 rf = &render->
info.
h264.referenceFrames[0];
397 #define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
399 for (list = 0; list < 2; ++list) {
403 for (i = 0; i < ls; ++i) {
412 rf2 = &render->
info.
h264.referenceFrames[0];
415 (rf2->surface == render_ref->
surface)
416 && (rf2->is_long_term == pic->
long_ref)
417 && (rf2->frame_idx == pic_frame_idx)
431 rf->surface = render_ref->
surface;
435 rf->field_order_cnt[0] = pic->
field_poc[0];
436 rf->field_order_cnt[1] = pic->
field_poc[1];
437 rf->frame_idx = pic_frame_idx;
444 rf->surface = VDP_INVALID_HANDLE;
445 rf->is_long_term = 0;
446 rf->top_is_reference = 0;
447 rf->bottom_is_reference = 0;
448 rf->field_order_cnt[0] = 0;
449 rf->field_order_cnt[1] = 0;
462 for (i = 0; i < 2; ++i) {
466 render->
info.
h264.field_order_cnt[i] = foc;
480 if (render->
info.
h264.slice_count < 1)
516 #if CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER
518 int buf_size,
int slice_count)
544 for (i = 0; i < 64; ++i) {
549 render->
info.
mpeg.forward_reference = VDP_INVALID_HANDLE;
550 render->
info.
mpeg.backward_reference = VDP_INVALID_HANDLE;
567 render->
info.
mpeg.slice_count = slice_count;
575 #if CONFIG_VC1_VDPAU_DECODER
586 render->
info.
vc1.frame_coding_mode = v->
fcm ? v->
fcm + 1 : 0;
616 render->
info.
vc1.forward_reference = VDP_INVALID_HANDLE;
617 render->
info.
vc1.backward_reference = VDP_INVALID_HANDLE;
620 render->
info.
vc1.picture_type = 4;
639 render->
info.
vc1.slice_count = 1;
646 #if CONFIG_MPEG4_VDPAU_DECODER
676 for (i = 0; i < 64; ++i) {
680 render->
info.
mpeg4.forward_reference = VDP_INVALID_HANDLE;
681 render->
info.
mpeg4.backward_reference = VDP_INVALID_HANDLE;
704 #if FF_API_VDPAU_PROFILE
707 #define PROFILE(prof) \
709 *profile = VDP_DECODER_PROFILE_##prof; \
719 default:
return AVERROR(EINVAL);
726 default:
return AVERROR(EINVAL);
734 #ifdef VDP_DECODER_PROFILE_H264_EXTENDED
737 default:
return AVERROR(EINVAL);
745 default:
return AVERROR(EINVAL);
759 VdpGetProcAddress *get_proc,
unsigned flags)
761 VDPAUHWContext *hwctx;
771 memset(hwctx, 0,
sizeof(*hwctx));
772 hwctx->context.decoder = VDP_INVALID_HANDLE;
773 hwctx->device = device;
774 hwctx->get_proc_address = get_proc;
775 hwctx->flags =
flags;
#define FF_PROFILE_H264_MAIN
#define FF_PROFILE_MPEG4_SIMPLE
const struct AVCodec * codec
const char const char void * val
void ff_vdpau_h264_picture_complete(H264Context *h)
int long_ref
1->long term reference 0->short term reference
#define FF_PROFILE_MPEG2_MAIN
This structure describes decoded (raw) audio or video data.
int(* init)(AVCodecContext *avctx)
Initialize the hwaccel private data.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int chroma_qp_index_offset[2]
int resync_marker
could this stream contain resync markers
int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
int extended_mv
Ext MV in P/B (not in Simple)
int broadcast
TFF/RFF present.
#define FF_PROFILE_H264_INTRA
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
VdpPictureInfoMPEG1Or2 mpeg
attribute_deprecated VdpBitstreamBuffer * bitstream_buffers
Table of bitstream buffers.
Public libavcodec VDPAU header.
int fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
H264Picture * long_ref[32]
AVVDPAUContext * av_vdpau_alloc_context(void)
Allocate an AVVDPAUContext.
AVVDPAUContext * av_alloc_vdpaucontext(void)
allocation function for AVVDPAUContext
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, uint32_t *width, uint32_t *height)
Gets the parameters to create an adequate VDPAU video surface for the codec context using VDPAU hardw...
struct AVHWAccel * hwaccel
Hardware accelerator in use.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
uint8_t scaling_matrix4[6][16]
int deblocking_filter_parameters_present
deblocking_filter_parameters_present_flag
#define FF_PROFILE_H264_BASELINE
int ff_vdpau_common_uninit(AVCodecContext *avctx)
void * hwaccel_context
Hardware accelerator context.
int panscanflag
NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present.
int interlace
Progressive/interlaced (RPTFTM syntax element)
void ff_vdpau_mpeg4_decode_picture(Mpeg4DecContext *s, const uint8_t *buf, int buf_size)
int cabac
entropy_coding_mode_flag
int no_rounding
apply no rounding to motion compensation (MPEG-4, msmpeg4, ...) for B-frames rounding mode is always ...
Picture current_picture
copy of the current picture structure.
attribute_deprecated int bitstream_buffers_used
Useful bitstream buffers in the bitstream buffers table.
#define PICT_BOTTOM_FIELD
int refdist_flag
REFDIST syntax element present in II, IP, PI or PP field picture headers.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
int redundant_pic_cnt_present
redundant_pic_cnt_present_flag
#define FF_PROFILE_H264_EXTENDED
uint16_t pp_time
time distance between the last 2 p,s,i frames
void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, int buf_size, int slice_count)
int psf
Progressive Segmented Frame.
int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile)
Get a decoder profile that should be used for initializing a VDPAU decoder.
H.264 / AVC / MPEG-4 part10 codec.
attribute_deprecated union AVVDPAUPictureInfo info
VDPAU picture information.
#define AV_HWACCEL_FLAG_IGNORE_LEVEL
Hardware acceleration should be used for decoding even if the codec level used is unknown or higher t...
#define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH
Hardware acceleration can output YUV pixel formats with a different chroma sampling than 4:2:0 and/or...
int mb_aff
mb_adaptive_frame_field_flag
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, int level)
VdpBitstreamBuffer * bitstream_buffers
The user is responsible for freeing this buffer using av_freep().
int overlap
overlapped transforms in use
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
This structure is used to share data between the libavcodec library and the client video application...
int poc_type
pic_order_cnt_type
int constrained_intra_pred
constrained_intra_pred_flag
#define MAKE_ACCESSORS(str, name, type, field)
#define FF_PROFILE_H264_HIGH
simple assert() macros that are a bit more flexible than ISO C assert().
int weighted_pred
weighted_pred_flag
int quarter_sample
1->qpel, 0->half pel ME/MC
int frame_num
frame_num (raw frame_num from slice header)
int resync_marker
could this stream contain resync markers
int postprocflag
Per-frame processing suggestion flag present.
int delta_pic_order_always_zero_flag
attribute_deprecated int bitstream_buffers_allocated
Allocated size of the bitstream_buffers table.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
uint8_t scaling_matrix8[6][64]
int refs
number of reference frames
void ff_vdpau_h264_picture_start(H264Context *h)
union AVVDPAUPictureInfo info
picture parameter information for all supported codecs
int ref_frame_count
num_ref_frames
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int tfcntrflag
TFCNTR present.
#define FF_PROFILE_VC1_MAIN
Picture * current_picture_ptr
pointer to the current picture
void * hwaccel_picture_private
Hardware accelerator private data.
static int vdpau_error(VdpStatus status)
static struct ResampleContext * create(struct ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational)
int init_qp
pic_init_qp_minus26 + 26
H264SliceContext * slice_ctx
int direct_8x8_inference_flag
#define FF_PROFILE_VC1_SIMPLE
VdpPictureInfoMPEG4Part2 mpeg4
preferred ID for MPEG-1/2 video decoding
int pic_order_present
pic_order_present_flag
int rangered
RANGEREDFRM (range reduction) syntax element present at frame level.
static void destroy(struct ResampleContext **c)
int finterpflag
INTERPFRM present.
uint16_t inter_matrix[64]
int concealment_motion_vectors
Libavcodec external API header.
H264Picture * short_ref[32]
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
int multires
frame-level RESPIC syntax element present
int field_poc[2]
top/bottom POC
main external API structure.
#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE
int bitstream_buffers_used
void ff_vdpau_h264_set_reference_frames(H264Context *h)
int extended_dmv
Additional extended dmv range at P/B-frame-level.
int bitstream_buffers_allocated
Describe size/location of the compressed video data.
int(* func)(AVBPrint *dst, const char *in, const char *arg)
H264Picture * cur_pic_ptr
VdpDecoderRender * render
VDPAU decoder render callback.
int quantizer_mode
2 bits, quantizer mode used for sequence, see QUANT_*
int f_code
forward MV resolution
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
int max_b_frames
max number of B-frames for encoding
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
int(* AVVDPAU_Render2)(struct AVCodecContext *, struct AVFrame *, const VdpPictureInfo *, uint32_t, const VdpBitstreamBuffer *)
int vstransform
variable-size [48]x[48] transform type + info
int transform_8x8_mode
transform_8x8_mode_flag
uint16_t pb_field_time
like above, just for interlaced
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, VdpGetProcAddress *get_proc, unsigned flags)
Associate a VDPAU device with a codec context for hardware acceleration.
struct AVCodecContext * avctx
int pic_id
pic_num (short -> no wrap version of pic_num, pic_num & max_pic_num; long -> long_pic_num) ...
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
This structure is used as a callback between the FFmpeg decoder (vd_) and presentation (vo_) module...
int ff_vdpau_add_buffer(struct vdpau_picture_context *pic_ctx, const uint8_t *buf, uint32_t size)
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
void * hwaccel_priv_data
hwaccel-specific private data
Picture last_picture
copy of the previous picture structure.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, struct vdpau_picture_context *pic_ctx)
#define FF_PROFILE_VC1_ADVANCED
#define FF_ENABLE_DEPRECATION_WARNINGS
struct AVCodecInternal * internal
Private context used for internal data.
#define FF_PROFILE_MPEG2_SIMPLE
Picture next_picture
copy of the next picture structure.
int current_slice
current slice number, used to initialize slice_num of each thread/context
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
int dquant
How qscale varies with MBs, 2 bits (not in Simple)
void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf, int buf_size)
#define FF_PROFILE_H264_CONSTRAINED_BASELINE
int b_code
backward MV resolution for B-frames (MPEG-4)
void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, int buf_size)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int ff_vdpau_common_reinit(AVCodecContext *avctx)
VdpVideoSurface surface
Used as rendered surface, never changed.
uint16_t pb_time
time distance between the last b and p,s,i frame
static uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
Extract VdpVideoSurface from an AVFrame.
int short_ref_count
number of actual short term references