Commit 030b5a4f authored by Ronald S. Bultje's avatar Ronald S. Bultje

lavc: put remaining bits of vdpau-in-decoder under FF_API_CAP_VDPAU.

parent 7a629186
...@@ -777,7 +777,9 @@ void ff_er_frame_start(ERContext *s) ...@@ -777,7 +777,9 @@ void ff_er_frame_start(ERContext *s)
static int er_supported(ERContext *s) static int er_supported(ERContext *s)
{ {
if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice || if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice ||
#if FF_API_CAP_VDPAU
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU || s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU ||
#endif
!s->cur_pic.f || !s->cur_pic.f ||
s->cur_pic.field_picture s->cur_pic.field_picture
) )
......
...@@ -603,10 +603,12 @@ retry: ...@@ -603,10 +603,12 @@ retry:
if (!s->divx_packed && !avctx->hwaccel) if (!s->divx_packed && !avctx->hwaccel)
ff_thread_finish_setup(avctx); ff_thread_finish_setup(avctx);
#if FF_API_CAP_VDPAU
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)) { if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(avctx->priv_data, s->gb.buffer, s->gb.buffer_end - s->gb.buffer); ff_vdpau_mpeg4_decode_picture(avctx->priv_data, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end; goto frame_end;
} }
#endif
if (avctx->hwaccel) { if (avctx->hwaccel) {
ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer,
......
...@@ -1561,9 +1561,11 @@ again: ...@@ -1561,9 +1561,11 @@ again:
if (h->avctx->hwaccel && if (h->avctx->hwaccel &&
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0) (ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
goto end; goto end;
#if FF_API_CAP_VDPAU
if (CONFIG_H264_VDPAU_DECODER && if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_start(h); ff_vdpau_h264_picture_start(h);
#endif
} }
if (sl->redundant_pic_count == 0) { if (sl->redundant_pic_count == 0) {
...@@ -1573,6 +1575,7 @@ again: ...@@ -1573,6 +1575,7 @@ again:
consumed); consumed);
if (ret < 0) if (ret < 0)
goto end; goto end;
#if FF_API_CAP_VDPAU
} else if (CONFIG_H264_VDPAU_DECODER && } else if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) { h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) {
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0], ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
...@@ -1581,6 +1584,7 @@ again: ...@@ -1581,6 +1584,7 @@ again:
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0], ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
&buf[buf_index - consumed], &buf[buf_index - consumed],
consumed); consumed);
#endif
} else } else
context_count++; context_count++;
} }
......
...@@ -157,9 +157,11 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) ...@@ -157,9 +157,11 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
int err = 0; int err = 0;
h->mb_y = 0; h->mb_y = 0;
#if FF_API_CAP_VDPAU
if (CONFIG_H264_VDPAU_DECODER && if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_set_reference_frames(h); ff_vdpau_h264_set_reference_frames(h);
#endif
if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) { if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
if (!h->droppable) { if (!h->droppable) {
...@@ -178,9 +180,11 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) ...@@ -178,9 +180,11 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
"hardware accelerator failed to decode picture\n"); "hardware accelerator failed to decode picture\n");
} }
#if FF_API_CAP_VDPAU
if (CONFIG_H264_VDPAU_DECODER && if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_complete(h); ff_vdpau_h264_picture_complete(h);
#endif
#if CONFIG_ERROR_RESILIENCE #if CONFIG_ERROR_RESILIENCE
av_assert0(sl == h->slice_ctx); av_assert0(sl == h->slice_ctx);
......
...@@ -612,8 +612,11 @@ static int h264_frame_start(H264Context *h) ...@@ -612,8 +612,11 @@ static int h264_frame_start(H264Context *h)
if ((ret = alloc_picture(h, pic)) < 0) if ((ret = alloc_picture(h, pic)) < 0)
return ret; return ret;
if(!h->frame_recovered && !h->avctx->hwaccel && if(!h->frame_recovered && !h->avctx->hwaccel
!(h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)) #if FF_API_CAP_VDPAU
&& !(h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
#endif
)
avpriv_color_frame(pic->f, c); avpriv_color_frame(pic->f, c);
h->cur_pic_ptr = pic; h->cur_pic_ptr = pic;
...@@ -1048,6 +1051,7 @@ static int h264_slice_header_init(H264Context *h) ...@@ -1048,6 +1051,7 @@ static int h264_slice_header_init(H264Context *h)
goto fail; goto fail;
} }
#if FF_API_CAP_VDPAU
if (h->avctx->codec && if (h->avctx->codec &&
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU && h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU &&
(h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) { (h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
...@@ -1056,6 +1060,7 @@ static int h264_slice_header_init(H264Context *h) ...@@ -1056,6 +1060,7 @@ static int h264_slice_header_init(H264Context *h)
ret = AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto fail; goto fail;
} }
#endif
if (h->sps.bit_depth_luma < 8 || h->sps.bit_depth_luma > 14 || if (h->sps.bit_depth_luma < 8 || h->sps.bit_depth_luma > 14 ||
h->sps.bit_depth_luma == 11 || h->sps.bit_depth_luma == 13 h->sps.bit_depth_luma == 11 || h->sps.bit_depth_luma == 13
...@@ -2533,8 +2538,11 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count) ...@@ -2533,8 +2538,11 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
h->slice_ctx[0].next_slice_idx = INT_MAX; h->slice_ctx[0].next_slice_idx = INT_MAX;
if (h->avctx->hwaccel || if (h->avctx->hwaccel
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) #if FF_API_CAP_VDPAU
|| h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU
#endif
)
return 0; return 0;
if (context_count == 1) { if (context_count == 1) {
int ret; int ret;
......
...@@ -1186,8 +1186,10 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { ...@@ -1186,8 +1186,10 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
#if CONFIG_MPEG1_XVMC_HWACCEL #if CONFIG_MPEG1_XVMC_HWACCEL
AV_PIX_FMT_XVMC, AV_PIX_FMT_XVMC,
#endif #endif
#if CONFIG_MPEG1_VDPAU_HWACCEL #if CONFIG_MPEG1_VDPAU_DECODER
AV_PIX_FMT_VDPAU_MPEG1, AV_PIX_FMT_VDPAU_MPEG1,
#endif
#if CONFIG_MPEG1_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU, AV_PIX_FMT_VDPAU,
#endif #endif
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P,
...@@ -1198,8 +1200,10 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { ...@@ -1198,8 +1200,10 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
#if CONFIG_MPEG2_XVMC_HWACCEL #if CONFIG_MPEG2_XVMC_HWACCEL
AV_PIX_FMT_XVMC, AV_PIX_FMT_XVMC,
#endif #endif
#if CONFIG_MPEG2_VDPAU_HWACCEL #if CONFIG_MPEG_VDPAU_DECODER
AV_PIX_FMT_VDPAU_MPEG2, AV_PIX_FMT_VDPAU_MPEG2,
#endif
#if CONFIG_MPEG2_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU, AV_PIX_FMT_VDPAU,
#endif #endif
#if CONFIG_MPEG2_DXVA2_HWACCEL #if CONFIG_MPEG2_DXVA2_HWACCEL
...@@ -1228,9 +1232,11 @@ static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = { ...@@ -1228,9 +1232,11 @@ static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = {
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
#if FF_API_VDPAU
static inline int uses_vdpau(AVCodecContext *avctx) { static inline int uses_vdpau(AVCodecContext *avctx) {
return avctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG1 || avctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG2; return avctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG1 || avctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG2;
} }
#endif
static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
{ {
...@@ -1256,7 +1262,11 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) ...@@ -1256,7 +1262,11 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
{ {
// until then pix_fmt may be changed right after codec init // until then pix_fmt may be changed right after codec init
if (avctx->hwaccel || uses_vdpau(avctx)) if (avctx->hwaccel
#if FF_API_VDPAU
|| uses_vdpau(avctx)
#endif
)
if (avctx->idct_algo == FF_IDCT_AUTO) if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_SIMPLE; avctx->idct_algo = FF_IDCT_SIMPLE;
...@@ -2460,9 +2470,11 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, ...@@ -2460,9 +2470,11 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
s2->er.error_count += s2->thread_context[i]->er.error_count; s2->er.error_count += s2->thread_context[i]->er.error_count;
} }
#if FF_API_VDPAU
if ((CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER) if ((CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER)
&& uses_vdpau(avctx)) && uses_vdpau(avctx))
ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
#endif
ret = slice_end(avctx, picture); ret = slice_end(avctx, picture);
if (ret < 0) if (ret < 0)
...@@ -2711,10 +2723,12 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, ...@@ -2711,10 +2723,12 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
#if FF_API_VDPAU
if (uses_vdpau(avctx)) { if (uses_vdpau(avctx)) {
s->slice_count++; s->slice_count++;
break; break;
} }
#endif
if (HAVE_THREADS && if (HAVE_THREADS &&
(avctx->active_thread_type & FF_THREAD_SLICE) && (avctx->active_thread_type & FF_THREAD_SLICE) &&
......
...@@ -58,7 +58,11 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, ...@@ -58,7 +58,11 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
{ {
int alloc_size = FFALIGN(FFABS(linesize) + 64, 32); int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
if (avctx->hwaccel || avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) if (avctx->hwaccel
#if FF_API_CAP_VDPAU
|| avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU
#endif
)
return 0; return 0;
if (linesize < 24) { if (linesize < 24) {
......
...@@ -1307,7 +1307,11 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1307,7 +1307,11 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
return -1; return -1;
} }
if (!avctx->hwaccel && !(avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)) { if (!avctx->hwaccel
#if FF_API_CAP_VDPAU
&& !(avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
#endif
) {
for(i=0; i<avctx->height; i++) for(i=0; i<avctx->height; i++)
memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i, memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i,
0x80, avctx->width); 0x80, avctx->width);
...@@ -1652,7 +1656,10 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ ...@@ -1652,7 +1656,10 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_
/* TODO: export all the following to make them accessible for users (and filters) */ /* TODO: export all the following to make them accessible for users (and filters) */
if (avctx->hwaccel || !mbtype_table if (avctx->hwaccel || !mbtype_table
|| (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)) #if FF_API_CAP_VDPAU
|| (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
#endif
)
return; return;
......
...@@ -1243,8 +1243,10 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) ...@@ -1243,8 +1243,10 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
break; break;
#if FF_API_CAP_VDPAU
if (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) if (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
break; break;
#endif
if (!setup_hwaccel(avctx, ret, desc->name)) if (!setup_hwaccel(avctx, ret, desc->name))
break; break;
......
...@@ -647,12 +647,14 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -647,12 +647,14 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
return buf_size; return buf_size;
} }
#if FF_API_CAP_VDPAU
if (s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) { if (s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) {
if (v->profile < PROFILE_ADVANCED) if (v->profile < PROFILE_ADVANCED)
avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3; avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
else else
avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1; avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
} }
#endif
//for advanced profile we may need to parse and unescape data //for advanced profile we may need to parse and unescape data
if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
...@@ -672,15 +674,21 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -672,15 +674,21 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (size <= 0) continue; if (size <= 0) continue;
switch (AV_RB32(start)) { switch (AV_RB32(start)) {
case VC1_CODE_FRAME: case VC1_CODE_FRAME:
if (avctx->hwaccel || if (avctx->hwaccel
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) #if FF_API_CAP_VDPAU
|| s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU
#endif
)
buf_start = start; buf_start = start;
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
break; break;
case VC1_CODE_FIELD: { case VC1_CODE_FIELD: {
int buf_size3; int buf_size3;
if (avctx->hwaccel || if (avctx->hwaccel
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) #if FF_API_CAP_VDPAU
|| s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU
#endif
)
buf_start_second_field = start; buf_start_second_field = start;
tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1)); tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
if (!tmp) { if (!tmp) {
...@@ -742,8 +750,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -742,8 +750,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
ret = AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto err; goto err;
} else { // found field marker, unescape second field } else { // found field marker, unescape second field
if (avctx->hwaccel || if (avctx->hwaccel
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) #if FF_API_CAP_VDPAU
|| s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU
#endif
)
buf_start_second_field = divider; buf_start_second_field = divider;
tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1)); tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
if (!tmp) { if (!tmp) {
...@@ -890,6 +901,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -890,6 +901,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
s->me.qpel_put = s->qdsp.put_qpel_pixels_tab; s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab; s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
#if FF_API_CAP_VDPAU
if ((CONFIG_VC1_VDPAU_DECODER) if ((CONFIG_VC1_VDPAU_DECODER)
&&s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) { &&s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) {
if (v->field_mode && buf_start_second_field) { if (v->field_mode && buf_start_second_field) {
...@@ -898,7 +910,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -898,7 +910,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
} else { } else {
ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start); ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
} }
} else if (avctx->hwaccel) { } else
#endif
if (avctx->hwaccel) {
if (v->field_mode && buf_start_second_field) { if (v->field_mode && buf_start_second_field) {
// decode first field // decode first field
s->picture_structure = PICT_BOTTOM_FIELD - v->tff; s->picture_structure = PICT_BOTTOM_FIELD - v->tff;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment