summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/vdpau.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/vdpau.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/vdpau.c')
-rw-r--r--ffmpeg/libavcodec/vdpau.c116
1 files changed, 96 insertions, 20 deletions
diff --git a/ffmpeg/libavcodec/vdpau.c b/ffmpeg/libavcodec/vdpau.c
index 5606902..32a3843 100644
--- a/ffmpeg/libavcodec/vdpau.c
+++ b/ffmpeg/libavcodec/vdpau.c
@@ -38,44 +38,63 @@
* @{
*/
-int ff_vdpau_common_start_frame(AVCodecContext *avctx,
+AVVDPAUContext *av_alloc_vdpaucontext(void)
+{
+ return av_vdpau_alloc_context();
+}
+
+MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
+
+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;
}
+#if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG1_VDPAU_HWACCEL || \
+ CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
+ CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
{
+ int res = 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);
+ if (!hwctx->render) {
+ res = hwctx->render2(avctx, &pic->f, (void *)&pic_ctx->info,
+ pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
+ } else
+ 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;
+ return res;
}
+#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;
@@ -170,6 +189,7 @@ void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf, int buf_size)
render->bitstream_buffers_used++;
}
+#if CONFIG_H264_VDPAU_DECODER
void ff_vdpau_h264_picture_start(H264Context *h)
{
struct vdpau_render_state *render;
@@ -230,7 +250,9 @@ void ff_vdpau_h264_picture_complete(H264Context *h)
ff_h264_draw_horiz_band(h, 0, h->avctx->height);
render->bitstream_buffers_used = 0;
}
+#endif /* CONFIG_H264_VDPAU_DECODER */
+#if CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER
void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
int buf_size, int slice_count)
{
@@ -287,7 +309,9 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
}
+#endif /* CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER */
+#if CONFIG_VC1_VDPAU_DECODER
void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
int buf_size)
{
@@ -298,7 +322,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
assert(render);
/* fill LvPictureInfoVC1 struct */
- render->info.vc1.frame_coding_mode = v->fcm;
+ render->info.vc1.frame_coding_mode = v->fcm ? v->fcm + 1 : 0;
render->info.vc1.postprocflag = v->postprocflag;
render->info.vc1.pulldown = v->broadcast;
render->info.vc1.interlace = v->interlace;
@@ -321,7 +345,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
render->info.vc1.range_mapuv = v->range_mapuv;
/* Specific to simple/main profile only */
render->info.vc1.multires = v->multires;
- render->info.vc1.syncmarker = v->s.resync_marker;
+ render->info.vc1.syncmarker = v->resync_marker;
render->info.vc1.rangered = v->rangered | (v->rangeredfrm << 1);
render->info.vc1.maxbframes = v->s.max_b_frames;
@@ -356,10 +380,13 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
}
+#endif /* (CONFIG_VC1_VDPAU_DECODER */
-void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
+#if CONFIG_MPEG4_VDPAU_DECODER
+void ff_vdpau_mpeg4_decode_picture(Mpeg4DecContext *ctx, const uint8_t *buf,
int buf_size)
{
+ MpegEncContext *s = &ctx->m;
struct vdpau_render_state *render, *last, *next;
int i;
@@ -377,7 +404,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
render->info.mpeg4.vop_coding_type = 0;
render->info.mpeg4.vop_fcode_forward = s->f_code;
render->info.mpeg4.vop_fcode_backward = s->b_code;
- render->info.mpeg4.resync_marker_disable = !s->resync_marker;
+ render->info.mpeg4.resync_marker_disable = !ctx->resync_marker;
render->info.mpeg4.interlaced = !s->progressive_sequence;
render->info.mpeg4.quant_type = s->mpeg_quant;
render->info.mpeg4.quarter_sample = s->quarter_sample;
@@ -410,5 +437,54 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
}
+#endif /* CONFIG_MPEG4_VDPAU_DECODER */
+
+int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile)
+{
+#define PROFILE(prof) \
+do { \
+ *profile = prof; \
+ return 0; \
+} while (0)
+
+ switch (avctx->codec_id) {
+ case AV_CODEC_ID_MPEG1VIDEO: PROFILE(VDP_DECODER_PROFILE_MPEG1);
+ case AV_CODEC_ID_MPEG2VIDEO:
+ switch (avctx->profile) {
+ case FF_PROFILE_MPEG2_MAIN: PROFILE(VDP_DECODER_PROFILE_MPEG2_MAIN);
+ case FF_PROFILE_MPEG2_SIMPLE: PROFILE(VDP_DECODER_PROFILE_MPEG2_SIMPLE);
+ default: return AVERROR(EINVAL);
+ }
+ case AV_CODEC_ID_H263: PROFILE(VDP_DECODER_PROFILE_MPEG4_PART2_ASP);
+ case AV_CODEC_ID_MPEG4:
+ switch (avctx->profile) {
+ case FF_PROFILE_MPEG4_SIMPLE: PROFILE(VDP_DECODER_PROFILE_MPEG4_PART2_SP);
+ case FF_PROFILE_MPEG4_ADVANCED_SIMPLE: PROFILE(VDP_DECODER_PROFILE_MPEG4_PART2_ASP);
+ default: return AVERROR(EINVAL);
+ }
+ case AV_CODEC_ID_H264:
+ switch (avctx->profile) {
+ case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+ case FF_PROFILE_H264_BASELINE: PROFILE(VDP_DECODER_PROFILE_H264_BASELINE);
+ case FF_PROFILE_H264_MAIN: PROFILE(VDP_DECODER_PROFILE_H264_MAIN);
+ case FF_PROFILE_H264_HIGH: PROFILE(VDP_DECODER_PROFILE_H264_HIGH);
+ default: return AVERROR(EINVAL);
+ }
+ case AV_CODEC_ID_WMV3:
+ case AV_CODEC_ID_VC1:
+ switch (avctx->profile) {
+ case FF_PROFILE_VC1_SIMPLE: PROFILE(VDP_DECODER_PROFILE_VC1_SIMPLE);
+ case FF_PROFILE_VC1_MAIN: PROFILE(VDP_DECODER_PROFILE_VC1_MAIN);
+ case FF_PROFILE_VC1_ADVANCED: PROFILE(VDP_DECODER_PROFILE_VC1_ADVANCED);
+ default: return AVERROR(EINVAL);
+ }
+ }
+ return AVERROR(EINVAL);
+}
+
+AVVDPAUContext *av_vdpau_alloc_context(void)
+{
+ return av_mallocz(sizeof(AVVDPAUContext));
+}
/* @}*/