* commit '89ac99ba5f2dc9f69ad3bc294753930eb0b3e4a4': vdpau: pass codec-specific parameters from hwaccel Conflicts: libavcodec/vdpau.c
Unified · Split
| @@ -146,6 +146,7 @@ int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx, · 145 unmodified lines | ||
| 146 | 146 | int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, |
| 147 | 147 | struct vdpau_picture_context *pic_ctx) |
| 148 | 148 | { |
| 149 | + VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; | |
| 149 | 150 | AVVDPAUContext *hwctx = avctx->hwaccel_context; |
| 150 | 151 | VdpVideoSurface surf = ff_vdpau_get_surface_id(frame); |
| 151 | 152 | VdpStatus status; |
| @@ -163,7 +164,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 11 unmodified lines | ||
| 163 | 164 | status = hwctx->render2(avctx, frame, (void *)&pic_ctx->info, |
| 164 | 165 | pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers); |
| 165 | 166 | } else |
| 166 | − status = hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info, | |
| 167 | + status = vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info, | |
| 167 | 168 | pic_ctx->bitstream_buffers_used, |
| 168 | 169 | pic_ctx->bitstream_buffers); |
| 169 | 170 | |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 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) · 172 unmodified lines | ||
| 202 | 203 | return 0; |
| 203 | 204 | } |
| 204 | 205 | |
| 206 | +static int vdpau_h264_init(AVCodecContext *avctx) | |
| 207 | +{ | |
| 208 | + VdpDecoderProfile profile; | |
| 209 | + uint32_t level = avctx->level; | |
| 210 | + | |
| 211 | + switch (avctx->profile & ~FF_PROFILE_H264_INTRA) { | |
| 212 | + case FF_PROFILE_H264_CONSTRAINED_BASELINE: | |
| 213 | + case FF_PROFILE_H264_BASELINE: | |
| 214 | + profile = VDP_DECODER_PROFILE_H264_BASELINE; | |
| 215 | + break; | |
| 216 | + case FF_PROFILE_H264_MAIN: | |
| 217 | + profile = VDP_DECODER_PROFILE_H264_MAIN; | |
| 218 | + break; | |
| 219 | + case FF_PROFILE_H264_HIGH: | |
| 220 | + profile = VDP_DECODER_PROFILE_H264_HIGH; | |
| 221 | + break; | |
| 222 | + default: | |
| 223 | + return AVERROR(ENOTSUP); | |
| 224 | + } | |
| 225 | + | |
| 226 | + if ((avctx->profile & FF_PROFILE_H264_INTRA) && avctx->level == 11) | |
| 227 | + level = VDP_DECODER_LEVEL_H264_1b; | |
| 228 | + | |
| 229 | + return ff_vdpau_common_init(avctx, profile, level); | |
| 230 | +} | |
| 231 | + | |
| 205 | 232 | AVHWAccel ff_h264_vdpau_hwaccel = { |
| 206 | 233 | .name = "h264_vdpau", |
| 207 | 234 | .type = AVMEDIA_TYPE_VIDEO, |
| @@ -211,4 +238,7 @@ AVHWAccel ff_h264_vdpau_hwaccel = { · 3 unmodified lines | ||
| 211 | 238 | .end_frame = vdpau_h264_end_frame, |
| 212 | 239 | .decode_slice = vdpau_h264_decode_slice, |
| 213 | 240 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 241 | + .init = vdpau_h264_init, | |
| 242 | + .uninit = ff_vdpau_common_uninit, | |
| 243 | + .priv_data_size = sizeof(VDPAUContext), | |
| 214 | 244 | }; |
| @@ -95,6 +95,12 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx, · 94 unmodified lines | ||
| 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 = { · 3 unmodified lines | ||
| 104 | 110 | .end_frame = ff_vdpau_mpeg_end_frame, |
| 105 | 111 | .decode_slice = vdpau_mpeg_decode_slice, |
| 106 | 112 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 113 | + .init = vdpau_mpeg1_init, | |
| 114 | + .uninit = ff_vdpau_common_uninit, | |
| 115 | + .priv_data_size = sizeof(VDPAUContext), | |
| 107 | 116 | }; |
| 108 | 117 | #endif |
| 109 | 118 | |
| 110 | 119 | #if CONFIG_MPEG2_VDPAU_HWACCEL |
| 120 | +static int vdpau_mpeg2_init(AVCodecContext *avctx) | |
| 121 | +{ | |
| 122 | + VdpDecoderProfile profile; | |
| 123 | + | |
| 124 | + switch (avctx->profile) { | |
| 125 | + case FF_PROFILE_MPEG2_MAIN: | |
| 126 | + profile = VDP_DECODER_PROFILE_MPEG2_MAIN; | |
| 127 | + break; | |
| 128 | + case FF_PROFILE_MPEG2_SIMPLE: | |
| 129 | + profile = VDP_DECODER_PROFILE_MPEG2_SIMPLE; | |
| 130 | + break; | |
| 131 | + default: | |
| 132 | + return AVERROR(EINVAL); | |
| 133 | + } | |
| 134 | + | |
| 135 | + return ff_vdpau_common_init(avctx, profile, VDP_DECODER_LEVEL_MPEG2_HL); | |
| 136 | +} | |
| 137 | + | |
| 111 | 138 | AVHWAccel ff_mpeg2_vdpau_hwaccel = { |
| 112 | 139 | .name = "mpeg2_vdpau", |
| 113 | 140 | .type = AVMEDIA_TYPE_VIDEO, |
| @@ -117,5 +144,8 @@ AVHWAccel ff_mpeg2_vdpau_hwaccel = { · 3 unmodified lines | ||
| 117 | 144 | .end_frame = ff_vdpau_mpeg_end_frame, |
| 118 | 145 | .decode_slice = vdpau_mpeg_decode_slice, |
| 119 | 146 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 147 | + .init = vdpau_mpeg2_init, | |
| 148 | + .uninit = ff_vdpau_common_uninit, | |
| 149 | + .priv_data_size = sizeof(VDPAUContext), | |
| 120 | 150 | }; |
| 121 | 151 | #endif |
| @@ -89,6 +89,12 @@ static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx, · 88 unmodified lines | ||
| 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 = { · 3 unmodified lines | ||
| 98 | 104 | .end_frame = ff_vdpau_mpeg_end_frame, |
| 99 | 105 | .decode_slice = vdpau_mpeg4_decode_slice, |
| 100 | 106 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 107 | + .init = vdpau_h263_init, | |
| 108 | + .uninit = ff_vdpau_common_uninit, | |
| 109 | + .priv_data_size = sizeof(VDPAUContext), | |
| 101 | 110 | }; |
| 102 | 111 | #endif |
| 103 | 112 | |
| 104 | 113 | #if CONFIG_MPEG4_VDPAU_HWACCEL |
| 114 | +static int vdpau_mpeg4_init(AVCodecContext *avctx) | |
| 115 | +{ | |
| 116 | + VdpDecoderProfile profile; | |
| 117 | + | |
| 118 | + switch (avctx->profile) { | |
| 119 | + case FF_PROFILE_MPEG4_SIMPLE: | |
| 120 | + profile = VDP_DECODER_PROFILE_MPEG4_PART2_SP; | |
| 121 | + break; | |
| 122 | + case FF_PROFILE_MPEG4_ADVANCED_SIMPLE: | |
| 123 | + profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP; | |
| 124 | + break; | |
| 125 | + default: | |
| 126 | + return AVERROR(ENOTSUP); | |
| 127 | + } | |
| 128 | + | |
| 129 | + return ff_vdpau_common_init(avctx, profile, avctx->level); | |
| 130 | +} | |
| 131 | + | |
| 105 | 132 | AVHWAccel ff_mpeg4_vdpau_hwaccel = { |
| 106 | 133 | .name = "mpeg4_vdpau", |
| 107 | 134 | .type = AVMEDIA_TYPE_VIDEO, |
| @@ -111,5 +138,8 @@ AVHWAccel ff_mpeg4_vdpau_hwaccel = { · 3 unmodified lines | ||
| 111 | 138 | .end_frame = ff_vdpau_mpeg_end_frame, |
| 112 | 139 | .decode_slice = vdpau_mpeg4_decode_slice, |
| 113 | 140 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 141 | + .init = vdpau_mpeg4_init, | |
| 142 | + .uninit = ff_vdpau_common_uninit, | |
| 143 | + .priv_data_size = sizeof(VDPAUContext), | |
| 114 | 144 | }; |
| 115 | 145 | #endif |
| @@ -113,6 +113,27 @@ static int vdpau_vc1_decode_slice(AVCodecContext *avctx, · 112 unmodified lines | ||
| 113 | 113 | return 0; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | +static int vdpau_vc1_init(AVCodecContext *avctx) | |
| 117 | +{ | |
| 118 | + VdpDecoderProfile profile; | |
| 119 | + | |
| 120 | + switch (avctx->profile) { | |
| 121 | + case FF_PROFILE_VC1_SIMPLE: | |
| 122 | + profile = VDP_DECODER_PROFILE_VC1_SIMPLE; | |
| 123 | + break; | |
| 124 | + case FF_PROFILE_VC1_MAIN: | |
| 125 | + profile = VDP_DECODER_PROFILE_VC1_MAIN; | |
| 126 | + break; | |
| 127 | + case FF_PROFILE_VC1_ADVANCED: | |
| 128 | + profile = VDP_DECODER_PROFILE_VC1_ADVANCED; | |
| 129 | + break; | |
| 130 | + default: | |
| 131 | + return AVERROR(ENOTSUP); | |
| 132 | + } | |
| 133 | + | |
| 134 | + return ff_vdpau_common_init(avctx, profile, avctx->level); | |
| 135 | +} | |
| 136 | + | |
| 116 | 137 | #if CONFIG_WMV3_VDPAU_HWACCEL |
| 117 | 138 | AVHWAccel ff_wmv3_vdpau_hwaccel = { |
| 118 | 139 | .name = "wm3_vdpau", |
| @@ -123,6 +144,9 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = { · 4 unmodified lines | ||
| 123 | 144 | .end_frame = ff_vdpau_mpeg_end_frame, |
| 124 | 145 | .decode_slice = vdpau_vc1_decode_slice, |
| 125 | 146 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 147 | + .init = vdpau_vc1_init, | |
| 148 | + .uninit = ff_vdpau_common_uninit, | |
| 149 | + .priv_data_size = sizeof(VDPAUContext), | |
| 126 | 150 | }; |
| 127 | 151 | #endif |
| 128 | 152 | |
| @@ -135,4 +159,7 @@ AVHWAccel ff_vc1_vdpau_hwaccel = { · 6 unmodified lines | ||
| 135 | 159 | .end_frame = ff_vdpau_mpeg_end_frame, |
| 136 | 160 | .decode_slice = vdpau_vc1_decode_slice, |
| 137 | 161 | .frame_priv_data_size = sizeof(struct vdpau_picture_context), |
| 162 | + .init = vdpau_vc1_init, | |
| 163 | + .uninit = ff_vdpau_common_uninit, | |
| 164 | + .priv_data_size = sizeof(VDPAUContext), | |
| 138 | 165 | }; |