Signed-off-by: Diego Biurrun <diego@biurrun.de>
RĂ©mi Denis-Courmont authored on 2013/01/13 00:53:43... | ... |
@@ -13,6 +13,9 @@ libavutil: 2012-10-22 |
13 | 13 |
|
14 | 14 |
API changes, most recent first: |
15 | 15 |
|
16 |
+2013-01-13 - xxxxxxx - lavc 54.36.0 - vdpau.h |
|
17 |
+ Add AVVDPAUContext struct for VDPAU hardware-accelerated decoding. |
|
18 |
+ |
|
16 | 19 |
2013-01-12 - 169fb94 - lavu 52.4.0 - pixdesc.h |
17 | 20 |
Add AV_PIX_FMT_VDPAU flag. |
18 | 21 |
|
... | ... |
@@ -38,6 +38,55 @@ |
38 | 38 |
* @{ |
39 | 39 |
*/ |
40 | 40 |
|
41 |
+int ff_vdpau_common_start_frame(AVCodecContext *avctx, |
|
42 |
+ av_unused const uint8_t *buffer, |
|
43 |
+ av_unused uint32_t size) |
|
44 |
+{ |
|
45 |
+ AVVDPAUContext *hwctx = avctx->hwaccel_context; |
|
46 |
+ |
|
47 |
+ hwctx->bitstream_buffers_used = 0; |
|
48 |
+ return 0; |
|
49 |
+} |
|
50 |
+ |
|
51 |
+int ff_vdpau_common_end_frame(AVCodecContext *avctx) |
|
52 |
+{ |
|
53 |
+ MpegEncContext * const s = avctx->priv_data; |
|
54 |
+ AVVDPAUContext *hwctx = avctx->hwaccel_context; |
|
55 |
+ |
|
56 |
+ if (hwctx->bitstream_buffers_used) { |
|
57 |
+ VdpVideoSurface surf = ff_vdpau_get_surface_id(s->current_picture_ptr); |
|
58 |
+ |
|
59 |
+ hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info, |
|
60 |
+ hwctx->bitstream_buffers_used, hwctx->bitstream_buffers); |
|
61 |
+ |
|
62 |
+ ff_draw_horiz_band(s, 0, s->avctx->height); |
|
63 |
+ hwctx->bitstream_buffers_used = 0; |
|
64 |
+ } |
|
65 |
+ return 0; |
|
66 |
+} |
|
67 |
+ |
|
68 |
+int ff_vdpau_add_buffer(AVCodecContext *avctx, |
|
69 |
+ const uint8_t *buf, uint32_t size) |
|
70 |
+{ |
|
71 |
+ AVVDPAUContext *hwctx = avctx->hwaccel_context; |
|
72 |
+ VdpBitstreamBuffer *buffers = hwctx->bitstream_buffers; |
|
73 |
+ |
|
74 |
+ buffers = av_fast_realloc(buffers, &hwctx->bitstream_buffers_allocated, |
|
75 |
+ (hwctx->bitstream_buffers_used + 1) * sizeof(*buffers)); |
|
76 |
+ if (!buffers) |
|
77 |
+ return AVERROR(ENOMEM); |
|
78 |
+ |
|
79 |
+ hwctx->bitstream_buffers = buffers; |
|
80 |
+ buffers += hwctx->bitstream_buffers_used++; |
|
81 |
+ |
|
82 |
+ buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION; |
|
83 |
+ buffers->bitstream = buf; |
|
84 |
+ buffers->bitstream_bytes = size; |
|
85 |
+ return 0; |
|
86 |
+} |
|
87 |
+ |
|
88 |
+/* Obsolete non-hwaccel VDPAU support below... */ |
|
89 |
+ |
|
41 | 90 |
void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) |
42 | 91 |
{ |
43 | 92 |
H264Context *h = s->avctx->priv_data; |
... | ... |
@@ -52,6 +52,68 @@ |
52 | 52 |
#include <vdpau/vdpau.h> |
53 | 53 |
#include <vdpau/vdpau_x11.h> |
54 | 54 |
|
55 |
+union VdpPictureInfo { |
|
56 |
+ VdpPictureInfoH264 h264; |
|
57 |
+ VdpPictureInfoMPEG1Or2 mpeg; |
|
58 |
+ VdpPictureInfoVC1 vc1; |
|
59 |
+ VdpPictureInfoMPEG4Part2 mpeg4; |
|
60 |
+}; |
|
61 |
+ |
|
62 |
+/** |
|
63 |
+ * This structure is used to share data between the libavcodec library and |
|
64 |
+ * the client video application. |
|
65 |
+ * The user shall zero-allocate the structure and make it available as |
|
66 |
+ * AVCodecContext.hwaccel_context. Members can be set by the user once |
|
67 |
+ * during initialization or through each AVCodecContext.get_buffer() |
|
68 |
+ * function call. In any case, they must be valid prior to calling |
|
69 |
+ * decoding functions. |
|
70 |
+ */ |
|
71 |
+typedef struct AVVDPAUContext { |
|
72 |
+ /** |
|
73 |
+ * VDPAU decoder handle |
|
74 |
+ * |
|
75 |
+ * Set by user. |
|
76 |
+ */ |
|
77 |
+ VdpDecoder decoder; |
|
78 |
+ |
|
79 |
+ /** |
|
80 |
+ * VDPAU decoder render callback |
|
81 |
+ * |
|
82 |
+ * Set by the user. |
|
83 |
+ */ |
|
84 |
+ VdpDecoderRender *render; |
|
85 |
+ |
|
86 |
+ /** |
|
87 |
+ * VDPAU picture information |
|
88 |
+ * |
|
89 |
+ * Set by libavcodec. |
|
90 |
+ */ |
|
91 |
+ union VdpPictureInfo info; |
|
92 |
+ |
|
93 |
+ /** |
|
94 |
+ * Allocated size of the bitstream_buffers table. |
|
95 |
+ * |
|
96 |
+ * Set by libavcodec. |
|
97 |
+ */ |
|
98 |
+ int bitstream_buffers_allocated; |
|
99 |
+ |
|
100 |
+ /** |
|
101 |
+ * Useful bitstream buffers in the bitstream buffers table. |
|
102 |
+ * |
|
103 |
+ * Set by libavcodec. |
|
104 |
+ */ |
|
105 |
+ int bitstream_buffers_used; |
|
106 |
+ |
|
107 |
+ /** |
|
108 |
+ * Table of bitstream buffers. |
|
109 |
+ * The user is responsible for freeing this buffer using av_freep(). |
|
110 |
+ * |
|
111 |
+ * Set by libavcodec. |
|
112 |
+ */ |
|
113 |
+ VdpBitstreamBuffer *bitstream_buffers; |
|
114 |
+} AVVDPAUContext; |
|
115 |
+ |
|
116 |
+ |
|
55 | 117 |
/** @brief The videoSurface is used for rendering. */ |
56 | 118 |
#define FF_VDPAU_STATE_USED_FOR_RENDER 1 |
57 | 119 |
|
... | ... |
@@ -74,12 +136,7 @@ struct vdpau_render_state { |
74 | 74 |
int state; ///< Holds FF_VDPAU_STATE_* values. |
75 | 75 |
|
76 | 76 |
/** picture parameter information for all supported codecs */ |
77 |
- union VdpPictureInfo { |
|
78 |
- VdpPictureInfoH264 h264; |
|
79 |
- VdpPictureInfoMPEG1Or2 mpeg; |
|
80 |
- VdpPictureInfoVC1 vc1; |
|
81 |
- VdpPictureInfoMPEG4Part2 mpeg4; |
|
82 |
- } info; |
|
77 |
+ union VdpPictureInfo info; |
|
83 | 78 |
|
84 | 79 |
/** Describe size/location of the compressed video data. |
85 | 80 |
Set to 0 when freeing bitstream_buffers. */ |
... | ... |
@@ -27,6 +27,20 @@ |
27 | 27 |
#include <stdint.h> |
28 | 28 |
#include "mpegvideo.h" |
29 | 29 |
|
30 |
+/** Extract VdpVideoSurface from a Picture */ |
|
31 |
+static inline uintptr_t ff_vdpau_get_surface_id(Picture *pic) |
|
32 |
+{ |
|
33 |
+ return (uintptr_t)pic->f.data[3]; |
|
34 |
+} |
|
35 |
+ |
|
36 |
+int ff_vdpau_common_start_frame(AVCodecContext *avctx, |
|
37 |
+ av_unused const uint8_t *buffer, |
|
38 |
+ av_unused uint32_t size); |
|
39 |
+int ff_vdpau_common_end_frame(AVCodecContext *avctx); |
|
40 |
+int ff_vdpau_add_buffer(AVCodecContext *avctx, |
|
41 |
+ const uint8_t *buf, uint32_t buf_size); |
|
42 |
+ |
|
43 |
+ |
|
30 | 44 |
void ff_vdpau_add_data_chunk(MpegEncContext *s, const uint8_t *buf, |
31 | 45 |
int buf_size); |
32 | 46 |
|