Mercurial > libavcodec.hg
comparison vc1.c @ 9224:aed92dbae82e libavcodec
Add support for HW accelerated VC-1 decoding through the new
AVHWAccel infrastructure.
author | gb |
---|---|
date | Sat, 21 Mar 2009 23:44:21 +0000 |
parents | 91f9fe7bedd9 |
children | 5c14ea3f8950 |
comparison
equal
deleted
inserted
replaced
9223:53f2c0f6e71d | 9224:aed92dbae82e |
---|---|
4008 MpegEncContext *s = &v->s; | 4008 MpegEncContext *s = &v->s; |
4009 GetBitContext gb; | 4009 GetBitContext gb; |
4010 | 4010 |
4011 if (!avctx->extradata_size || !avctx->extradata) return -1; | 4011 if (!avctx->extradata_size || !avctx->extradata) return -1; |
4012 if (!(avctx->flags & CODEC_FLAG_GRAY)) | 4012 if (!(avctx->flags & CODEC_FLAG_GRAY)) |
4013 avctx->pix_fmt = PIX_FMT_YUV420P; | 4013 avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); |
4014 else | 4014 else |
4015 avctx->pix_fmt = PIX_FMT_GRAY8; | 4015 avctx->pix_fmt = PIX_FMT_GRAY8; |
4016 avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); | |
4016 v->s.avctx = avctx; | 4017 v->s.avctx = avctx; |
4017 avctx->flags |= CODEC_FLAG_EMU_EDGE; | 4018 avctx->flags |= CODEC_FLAG_EMU_EDGE; |
4018 v->s.flags |= CODEC_FLAG_EMU_EDGE; | 4019 v->s.flags |= CODEC_FLAG_EMU_EDGE; |
4019 | 4020 |
4020 if(avctx->idct_algo==FF_IDCT_AUTO){ | 4021 if(avctx->idct_algo==FF_IDCT_AUTO){ |
4185 next = find_next_marker(start + 4, end); | 4186 next = find_next_marker(start + 4, end); |
4186 size = next - start - 4; | 4187 size = next - start - 4; |
4187 if(size <= 0) continue; | 4188 if(size <= 0) continue; |
4188 switch(AV_RB32(start)){ | 4189 switch(AV_RB32(start)){ |
4189 case VC1_CODE_FRAME: | 4190 case VC1_CODE_FRAME: |
4190 if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) | 4191 if (avctx->hwaccel || |
4192 s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) | |
4191 buf_start = start; | 4193 buf_start = start; |
4192 buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); | 4194 buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); |
4193 break; | 4195 break; |
4194 case VC1_CODE_ENTRYPOINT: /* it should be before frame data */ | 4196 case VC1_CODE_ENTRYPOINT: /* it should be before frame data */ |
4195 buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); | 4197 buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); |
4278 s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; | 4280 s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; |
4279 | 4281 |
4280 if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER) | 4282 if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER) |
4281 &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) | 4283 &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) |
4282 ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start); | 4284 ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start); |
4283 else { | 4285 else if (avctx->hwaccel) { |
4286 if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0) | |
4287 return -1; | |
4288 if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0) | |
4289 return -1; | |
4290 if (avctx->hwaccel->end_frame(avctx) < 0) | |
4291 return -1; | |
4292 } else { | |
4284 ff_er_frame_start(s); | 4293 ff_er_frame_start(s); |
4285 | 4294 |
4286 v->bits = buf_size * 8; | 4295 v->bits = buf_size * 8; |
4287 vc1_decode_blocks(v); | 4296 vc1_decode_blocks(v); |
4288 //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), buf_size*8); | 4297 //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), buf_size*8); |
4346 vc1_decode_end, | 4355 vc1_decode_end, |
4347 vc1_decode_frame, | 4356 vc1_decode_frame, |
4348 CODEC_CAP_DELAY, | 4357 CODEC_CAP_DELAY, |
4349 NULL, | 4358 NULL, |
4350 .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), | 4359 .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), |
4351 .pix_fmts = ff_pixfmt_list_420 | 4360 .pix_fmts = ff_hwaccel_pixfmt_list_420 |
4352 }; | 4361 }; |
4353 | 4362 |
4354 AVCodec wmv3_decoder = { | 4363 AVCodec wmv3_decoder = { |
4355 "wmv3", | 4364 "wmv3", |
4356 CODEC_TYPE_VIDEO, | 4365 CODEC_TYPE_VIDEO, |
4361 vc1_decode_end, | 4370 vc1_decode_end, |
4362 vc1_decode_frame, | 4371 vc1_decode_frame, |
4363 CODEC_CAP_DELAY, | 4372 CODEC_CAP_DELAY, |
4364 NULL, | 4373 NULL, |
4365 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), | 4374 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), |
4366 .pix_fmts = ff_pixfmt_list_420 | 4375 .pix_fmts = ff_hwaccel_pixfmt_list_420 |
4367 }; | 4376 }; |
4368 | 4377 |
4369 #if CONFIG_WMV3_VDPAU_DECODER | 4378 #if CONFIG_WMV3_VDPAU_DECODER |
4370 AVCodec wmv3_vdpau_decoder = { | 4379 AVCodec wmv3_vdpau_decoder = { |
4371 "wmv3_vdpau", | 4380 "wmv3_vdpau", |