Signed-off-by: Anton Khirnov <anton@khirnov.net>
RĂ©mi Denis-Courmont authored on 2014/10/04 22:55:05... | ... |
@@ -139,11 +139,11 @@ int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx, |
139 | 139 |
int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, |
140 | 140 |
struct vdpau_picture_context *pic_ctx) |
141 | 141 |
{ |
142 |
- AVVDPAUContext *hwctx = avctx->hwaccel_context; |
|
142 |
+ VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; |
|
143 | 143 |
VdpVideoSurface surf = ff_vdpau_get_surface_id(frame); |
144 | 144 |
VdpStatus status; |
145 | 145 |
|
146 |
- status = hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info, |
|
146 |
+ status = vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info, |
|
147 | 147 |
pic_ctx->bitstream_buffers_used, |
148 | 148 |
pic_ctx->bitstream_buffers); |
149 | 149 |
|
... | ... |
@@ -24,6 +24,7 @@ |
24 | 24 |
#include <vdpau/vdpau.h> |
25 | 25 |
|
26 | 26 |
#include "avcodec.h" |
27 |
+#include "internal.h" |
|
27 | 28 |
#include "h264.h" |
28 | 29 |
#include "mpegutils.h" |
29 | 30 |
#include "vdpau.h" |
... | ... |
@@ -202,6 +203,32 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx) |
202 | 202 |
return 0; |
203 | 203 |
} |
204 | 204 |
|
205 |
+static int vdpau_h264_init(AVCodecContext *avctx) |
|
206 |
+{ |
|
207 |
+ VdpDecoderProfile profile; |
|
208 |
+ uint32_t level = avctx->level; |
|
209 |
+ |
|
210 |
+ switch (avctx->profile & ~FF_PROFILE_H264_INTRA) { |
|
211 |
+ case FF_PROFILE_H264_CONSTRAINED_BASELINE: |
|
212 |
+ case FF_PROFILE_H264_BASELINE: |
|
213 |
+ profile = VDP_DECODER_PROFILE_H264_BASELINE; |
|
214 |
+ break; |
|
215 |
+ case FF_PROFILE_H264_MAIN: |
|
216 |
+ profile = VDP_DECODER_PROFILE_H264_MAIN; |
|
217 |
+ break; |
|
218 |
+ case FF_PROFILE_H264_HIGH: |
|
219 |
+ profile = VDP_DECODER_PROFILE_H264_HIGH; |
|
220 |
+ break; |
|
221 |
+ default: |
|
222 |
+ return AVERROR(ENOTSUP); |
|
223 |
+ } |
|
224 |
+ |
|
225 |
+ if ((avctx->profile & FF_PROFILE_H264_INTRA) && avctx->level == 11) |
|
226 |
+ level = VDP_DECODER_LEVEL_H264_1b; |
|
227 |
+ |
|
228 |
+ return ff_vdpau_common_init(avctx, profile, level); |
|
229 |
+} |
|
230 |
+ |
|
205 | 231 |
AVHWAccel ff_h264_vdpau_hwaccel = { |
206 | 232 |
.name = "h264_vdpau", |
207 | 233 |
.type = AVMEDIA_TYPE_VIDEO, |
... | ... |
@@ -211,4 +238,7 @@ AVHWAccel ff_h264_vdpau_hwaccel = { |
211 | 211 |
.end_frame = vdpau_h264_end_frame, |
212 | 212 |
.decode_slice = vdpau_h264_decode_slice, |
213 | 213 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
214 |
+ .init = vdpau_h264_init, |
|
215 |
+ .uninit = ff_vdpau_common_uninit, |
|
216 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
214 | 217 |
}; |
... | ... |
@@ -95,6 +95,12 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx, |
95 | 95 |
} |
96 | 96 |
|
97 | 97 |
#if CONFIG_MPEG1_VDPAU_HWACCEL |
98 |
+static int vdpau_mpeg1_init(AVCodecContext *avctx) |
|
99 |
+{ |
|
100 |
+ return ff_vdpau_common_init(avctx, VDP_DECODER_PROFILE_MPEG1, |
|
101 |
+ VDP_DECODER_LEVEL_MPEG1_NA); |
|
102 |
+} |
|
103 |
+ |
|
98 | 104 |
AVHWAccel ff_mpeg1_vdpau_hwaccel = { |
99 | 105 |
.name = "mpeg1_vdpau", |
100 | 106 |
.type = AVMEDIA_TYPE_VIDEO, |
... | ... |
@@ -104,10 +110,31 @@ AVHWAccel ff_mpeg1_vdpau_hwaccel = { |
104 | 104 |
.end_frame = ff_vdpau_mpeg_end_frame, |
105 | 105 |
.decode_slice = vdpau_mpeg_decode_slice, |
106 | 106 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
107 |
+ .init = vdpau_mpeg1_init, |
|
108 |
+ .uninit = ff_vdpau_common_uninit, |
|
109 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
107 | 110 |
}; |
108 | 111 |
#endif |
109 | 112 |
|
110 | 113 |
#if CONFIG_MPEG2_VDPAU_HWACCEL |
114 |
+static int vdpau_mpeg2_init(AVCodecContext *avctx) |
|
115 |
+{ |
|
116 |
+ VdpDecoderProfile profile; |
|
117 |
+ |
|
118 |
+ switch (avctx->profile) { |
|
119 |
+ case FF_PROFILE_MPEG2_MAIN: |
|
120 |
+ profile = VDP_DECODER_PROFILE_MPEG2_MAIN; |
|
121 |
+ break; |
|
122 |
+ case FF_PROFILE_MPEG2_SIMPLE: |
|
123 |
+ profile = VDP_DECODER_PROFILE_MPEG2_SIMPLE; |
|
124 |
+ break; |
|
125 |
+ default: |
|
126 |
+ return AVERROR(EINVAL); |
|
127 |
+ } |
|
128 |
+ |
|
129 |
+ return ff_vdpau_common_init(avctx, profile, VDP_DECODER_LEVEL_MPEG2_HL); |
|
130 |
+} |
|
131 |
+ |
|
111 | 132 |
AVHWAccel ff_mpeg2_vdpau_hwaccel = { |
112 | 133 |
.name = "mpeg2_vdpau", |
113 | 134 |
.type = AVMEDIA_TYPE_VIDEO, |
... | ... |
@@ -117,5 +144,8 @@ AVHWAccel ff_mpeg2_vdpau_hwaccel = { |
117 | 117 |
.end_frame = ff_vdpau_mpeg_end_frame, |
118 | 118 |
.decode_slice = vdpau_mpeg_decode_slice, |
119 | 119 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
120 |
+ .init = vdpau_mpeg2_init, |
|
121 |
+ .uninit = ff_vdpau_common_uninit, |
|
122 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
120 | 123 |
}; |
121 | 124 |
#endif |
... | ... |
@@ -89,6 +89,12 @@ static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx, |
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
#if CONFIG_H263_VDPAU_HWACCEL |
92 |
+static int vdpau_h263_init(AVCodecContext *avctx) |
|
93 |
+{ |
|
94 |
+ return ff_vdpau_common_init(avctx, VDP_DECODER_PROFILE_MPEG4_PART2_ASP, |
|
95 |
+ VDP_DECODER_LEVEL_MPEG4_PART2_ASP_L5); |
|
96 |
+} |
|
97 |
+ |
|
92 | 98 |
AVHWAccel ff_h263_vdpau_hwaccel = { |
93 | 99 |
.name = "h263_vdpau", |
94 | 100 |
.type = AVMEDIA_TYPE_VIDEO, |
... | ... |
@@ -98,10 +104,31 @@ AVHWAccel ff_h263_vdpau_hwaccel = { |
98 | 98 |
.end_frame = ff_vdpau_mpeg_end_frame, |
99 | 99 |
.decode_slice = vdpau_mpeg4_decode_slice, |
100 | 100 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
101 |
+ .init = vdpau_h263_init, |
|
102 |
+ .uninit = ff_vdpau_common_uninit, |
|
103 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
101 | 104 |
}; |
102 | 105 |
#endif |
103 | 106 |
|
104 | 107 |
#if CONFIG_MPEG4_VDPAU_HWACCEL |
108 |
+static int vdpau_mpeg4_init(AVCodecContext *avctx) |
|
109 |
+{ |
|
110 |
+ VdpDecoderProfile profile; |
|
111 |
+ |
|
112 |
+ switch (avctx->profile) { |
|
113 |
+ case FF_PROFILE_MPEG4_SIMPLE: |
|
114 |
+ profile = VDP_DECODER_PROFILE_MPEG4_PART2_SP; |
|
115 |
+ break; |
|
116 |
+ case FF_PROFILE_MPEG4_ADVANCED_SIMPLE: |
|
117 |
+ profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP; |
|
118 |
+ break; |
|
119 |
+ default: |
|
120 |
+ return AVERROR(ENOTSUP); |
|
121 |
+ } |
|
122 |
+ |
|
123 |
+ return ff_vdpau_common_init(avctx, profile, avctx->level); |
|
124 |
+} |
|
125 |
+ |
|
105 | 126 |
AVHWAccel ff_mpeg4_vdpau_hwaccel = { |
106 | 127 |
.name = "mpeg4_vdpau", |
107 | 128 |
.type = AVMEDIA_TYPE_VIDEO, |
... | ... |
@@ -111,5 +138,8 @@ AVHWAccel ff_mpeg4_vdpau_hwaccel = { |
111 | 111 |
.end_frame = ff_vdpau_mpeg_end_frame, |
112 | 112 |
.decode_slice = vdpau_mpeg4_decode_slice, |
113 | 113 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
114 |
+ .init = vdpau_mpeg4_init, |
|
115 |
+ .uninit = ff_vdpau_common_uninit, |
|
116 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
114 | 117 |
}; |
115 | 118 |
#endif |
... | ... |
@@ -109,6 +109,27 @@ static int vdpau_vc1_decode_slice(AVCodecContext *avctx, |
109 | 109 |
return 0; |
110 | 110 |
} |
111 | 111 |
|
112 |
+static int vdpau_vc1_init(AVCodecContext *avctx) |
|
113 |
+{ |
|
114 |
+ VdpDecoderProfile profile; |
|
115 |
+ |
|
116 |
+ switch (avctx->profile) { |
|
117 |
+ case FF_PROFILE_VC1_SIMPLE: |
|
118 |
+ profile = VDP_DECODER_PROFILE_VC1_SIMPLE; |
|
119 |
+ break; |
|
120 |
+ case FF_PROFILE_VC1_MAIN: |
|
121 |
+ profile = VDP_DECODER_PROFILE_VC1_MAIN; |
|
122 |
+ break; |
|
123 |
+ case FF_PROFILE_VC1_ADVANCED: |
|
124 |
+ profile = VDP_DECODER_PROFILE_VC1_ADVANCED; |
|
125 |
+ break; |
|
126 |
+ default: |
|
127 |
+ return AVERROR(ENOTSUP); |
|
128 |
+ } |
|
129 |
+ |
|
130 |
+ return ff_vdpau_common_init(avctx, profile, avctx->level); |
|
131 |
+} |
|
132 |
+ |
|
112 | 133 |
#if CONFIG_WMV3_VDPAU_HWACCEL |
113 | 134 |
AVHWAccel ff_wmv3_vdpau_hwaccel = { |
114 | 135 |
.name = "wm3_vdpau", |
... | ... |
@@ -119,6 +140,9 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = { |
119 | 119 |
.end_frame = ff_vdpau_mpeg_end_frame, |
120 | 120 |
.decode_slice = vdpau_vc1_decode_slice, |
121 | 121 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
122 |
+ .init = vdpau_vc1_init, |
|
123 |
+ .uninit = ff_vdpau_common_uninit, |
|
124 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
122 | 125 |
}; |
123 | 126 |
#endif |
124 | 127 |
|
... | ... |
@@ -131,4 +155,7 @@ AVHWAccel ff_vc1_vdpau_hwaccel = { |
131 | 131 |
.end_frame = ff_vdpau_mpeg_end_frame, |
132 | 132 |
.decode_slice = vdpau_vc1_decode_slice, |
133 | 133 |
.frame_priv_data_size = sizeof(struct vdpau_picture_context), |
134 |
+ .init = vdpau_vc1_init, |
|
135 |
+ .uninit = ff_vdpau_common_uninit, |
|
136 |
+ .priv_data_size = sizeof(VDPAUContext), |
|
134 | 137 |
}; |