SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
SKIPHEADERS-$(CONFIG_VDA) += vda.h
-SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
+SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
EXAMPLES = api
* @{
*/
-int ff_vdpau_common_start_frame(AVCodecContext *avctx,
+int ff_vdpau_common_start_frame(Picture *pic,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
- hwctx->bitstream_buffers_used = 0;
+ pic_ctx->bitstream_buffers_allocated = 0;
+ pic_ctx->bitstream_buffers_used = 0;
+ pic_ctx->bitstream_buffers = NULL;
return 0;
}
{
AVVDPAUContext *hwctx = avctx->hwaccel_context;
MpegEncContext *s = avctx->priv_data;
- VdpVideoSurface surf = ff_vdpau_get_surface_id(s->current_picture_ptr);
+ Picture *pic = s->current_picture_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
- hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
- hwctx->bitstream_buffers_used, hwctx->bitstream_buffers);
+ hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
+ pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
- hwctx->bitstream_buffers_used = 0;
+ av_freep(&pic_ctx->bitstream_buffers);
return 0;
}
#endif
-int ff_vdpau_add_buffer(AVCodecContext *avctx,
- const uint8_t *buf, uint32_t size)
+int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t size)
{
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
- VdpBitstreamBuffer *buffers = hwctx->bitstream_buffers;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpBitstreamBuffer *buffers = pic_ctx->bitstream_buffers;
- buffers = av_fast_realloc(buffers, &hwctx->bitstream_buffers_allocated,
- (hwctx->bitstream_buffers_used + 1) * sizeof(*buffers));
+ buffers = av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
+ (pic_ctx->bitstream_buffers_used + 1) * sizeof(*buffers));
if (!buffers)
return AVERROR(ENOMEM);
- hwctx->bitstream_buffers = buffers;
- buffers += hwctx->bitstream_buffers_used++;
+ pic_ctx->bitstream_buffers = buffers;
+ buffers += pic_ctx->bitstream_buffers_used++;
buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
buffers->bitstream = buf;
static void vdpau_h264_set_reference_frames(AVCodecContext *avctx)
{
H264Context * const h = avctx->priv_data;
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
- VdpPictureInfoH264 *info = &hwctx->info.h264;
+ struct vdpau_picture_context *pic_ctx = h->cur_pic_ptr->hwaccel_picture_private;
+ VdpPictureInfoH264 *info = &pic_ctx->info.h264;
int list;
VdpReferenceFrameH264 *rf = &info->referenceFrames[0];
const uint8_t *buffer, uint32_t size)
{
H264Context * const h = avctx->priv_data;
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
- VdpPictureInfoH264 *info = &hwctx->info.h264;
Picture *pic = h->cur_pic_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpPictureInfoH264 *info = &pic_ctx->info.h264;
/* init VdpPictureInfoH264 */
info->slice_count = 0;
vdpau_h264_set_reference_frames(avctx);
- return ff_vdpau_common_start_frame(avctx, buffer, size);
+ return ff_vdpau_common_start_frame(pic, buffer, size);
}
static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 };
static int vdpau_h264_decode_slice(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
+ H264Context *h = avctx->priv_data;
+ Picture *pic = h->cur_pic_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_add_buffer(avctx, start_code_prefix, 3);
+ val = ff_vdpau_add_buffer(pic, start_code_prefix, 3);
if (val)
return val;
- val = ff_vdpau_add_buffer(avctx, buffer, size);
+ val = ff_vdpau_add_buffer(pic, buffer, size);
if (val)
return val;
- hwctx->info.h264.slice_count++;
+ pic_ctx->info.h264.slice_count++;
return 0;
}
{
AVVDPAUContext *hwctx = avctx->hwaccel_context;
H264Context *h = avctx->priv_data;
- VdpVideoSurface surf = ff_vdpau_get_surface_id(h->cur_pic_ptr);
+ Picture *pic = h->cur_pic_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
- hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
- hwctx->bitstream_buffers_used, hwctx->bitstream_buffers);
+ hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
+ pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
ff_h264_draw_horiz_band(h, 0, h->avctx->height);
- hwctx->bitstream_buffers_used = 0;
+ av_freep(&pic_ctx->bitstream_buffers);
return 0;
}
.start_frame = vdpau_h264_start_frame,
.end_frame = vdpau_h264_end_frame,
.decode_slice = vdpau_h264_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};
#define AVCODEC_VDPAU_INTERNAL_H
#include <stdint.h>
+#include <vdpau/vdpau.h>
#include "h264.h"
#include "mpegvideo.h"
return (uintptr_t)pic->f.data[3];
}
-int ff_vdpau_common_start_frame(AVCodecContext *avctx,
+struct vdpau_picture_context {
+ /**
+ * VDPAU picture information.
+ */
+ union AVVDPAUPictureInfo info;
+
+ /**
+ * Allocated size of the bitstream_buffers table.
+ */
+ int bitstream_buffers_allocated;
+
+ /**
+ * Useful bitstream buffers in the bitstream buffers table.
+ */
+ int bitstream_buffers_used;
+
+ /**
+ * Table of bitstream buffers.
+ */
+ VdpBitstreamBuffer *bitstream_buffers;
+};
+
+int ff_vdpau_common_start_frame(Picture *pic,
const uint8_t *buffer, uint32_t size);
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
-int ff_vdpau_add_buffer(AVCodecContext *avctx,
- const uint8_t *buf, uint32_t buf_size);
+int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t buf_size);
#endif /* AVCODEC_VDPAU_INTERNAL_H */
const uint8_t *buffer, uint32_t size)
{
MpegEncContext * const s = avctx->priv_data;
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
- VdpPictureInfoMPEG1Or2 *info = &hwctx->info.mpeg;
+ Picture *pic = s->current_picture_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpPictureInfoMPEG1Or2 *info = &pic_ctx->info.mpeg;
VdpVideoSurface ref;
int i;
case AV_PICTURE_TYPE_B:
ref = ff_vdpau_get_surface_id(&s->next_picture);
assert(ref != VDP_INVALID_HANDLE);
- hwctx->info.mpeg.backward_reference = ref;
+ info->backward_reference = ref;
/* fall through to forward prediction */
case AV_PICTURE_TYPE_P:
ref = ff_vdpau_get_surface_id(&s->last_picture);
- hwctx->info.mpeg.forward_reference = ref;
+ info->forward_reference = ref;
}
info->slice_count = 0;
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
}
- return ff_vdpau_common_start_frame(avctx, buffer, size);
+ return ff_vdpau_common_start_frame(pic, buffer, size);
}
static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
+ MpegEncContext * const s = avctx->priv_data;
+ Picture *pic = s->current_picture_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_add_buffer(avctx, buffer, size);
+ val = ff_vdpau_add_buffer(pic, buffer, size);
if (val < 0)
return val;
- hwctx->info.mpeg.slice_count++;
+ pic_ctx->info.mpeg.slice_count++;
return 0;
}
.start_frame = vdpau_mpeg_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
.start_frame = vdpau_mpeg_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
const uint8_t *buffer, uint32_t size)
{
MpegEncContext * const s = avctx->priv_data;
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
- VdpPictureInfoMPEG4Part2 *info = &hwctx->info.mpeg4;
+ Picture *pic = s->current_picture_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpPictureInfoMPEG4Part2 *info = &pic_ctx->info.mpeg4;
VdpVideoSurface ref;
int i;
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
}
- ff_vdpau_common_start_frame(avctx, buffer, size);
- return ff_vdpau_add_buffer(avctx, buffer, size);
+ ff_vdpau_common_start_frame(pic, buffer, size);
+ return ff_vdpau_add_buffer(pic, buffer, size);
}
static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx,
.start_frame = vdpau_mpeg4_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg4_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
.start_frame = vdpau_mpeg4_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg4_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
const uint8_t *buffer, uint32_t size)
{
VC1Context * const v = avctx->priv_data;
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
MpegEncContext * const s = &v->s;
- VdpPictureInfoVC1 *info = &hwctx->info.vc1;
+ Picture *pic = s->current_picture_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+ VdpPictureInfoVC1 *info = &pic_ctx->info.vc1;
VdpVideoSurface ref;
/* fill LvPictureInfoVC1 struct */
info->deblockEnable = v->postprocflag & 1;
info->pquant = v->pq;
- return ff_vdpau_common_start_frame(avctx, buffer, size);
+ return ff_vdpau_common_start_frame(pic, buffer, size);
}
static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
+ VC1Context * const v = avctx->priv_data;
+ MpegEncContext * const s = &v->s;
+ Picture *pic = s->current_picture_ptr;
+ struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_add_buffer(avctx, buffer, size);
+ val = ff_vdpau_add_buffer(pic, buffer, size);
if (val < 0)
return val;
- hwctx->info.vc1.slice_count++;
+ pic_ctx->info.vc1.slice_count++;
return 0;
}
.start_frame = vdpau_vc1_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_vc1_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
.start_frame = vdpau_vc1_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_vc1_decode_slice,
+ .priv_data_size = sizeof(struct vdpau_picture_context),
};