mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-27 21:40:34 +00:00
lavc: put remaining bits of vdpau-in-decoder under FF_API_CAP_VDPAU.
This commit is contained in:
parent
7a629186ba
commit
030b5a4f77
@ -777,7 +777,9 @@ void ff_er_frame_start(ERContext *s)
|
||||
static int er_supported(ERContext *s)
|
||||
{
|
||||
if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice ||
|
||||
#if FF_API_CAP_VDPAU
|
||||
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU ||
|
||||
#endif
|
||||
!s->cur_pic.f ||
|
||||
s->cur_pic.field_picture
|
||||
)
|
||||
|
@ -603,10 +603,12 @@ retry:
|
||||
if (!s->divx_packed && !avctx->hwaccel)
|
||||
ff_thread_finish_setup(avctx);
|
||||
|
||||
#if FF_API_CAP_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);
|
||||
goto frame_end;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (avctx->hwaccel) {
|
||||
ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer,
|
||||
|
@ -1561,9 +1561,11 @@ again:
|
||||
if (h->avctx->hwaccel &&
|
||||
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
|
||||
goto end;
|
||||
#if FF_API_CAP_VDPAU
|
||||
if (CONFIG_H264_VDPAU_DECODER &&
|
||||
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
ff_vdpau_h264_picture_start(h);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (sl->redundant_pic_count == 0) {
|
||||
@ -1573,6 +1575,7 @@ again:
|
||||
consumed);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
#if FF_API_CAP_VDPAU
|
||||
} else if (CONFIG_H264_VDPAU_DECODER &&
|
||||
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) {
|
||||
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
|
||||
@ -1581,6 +1584,7 @@ again:
|
||||
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
|
||||
&buf[buf_index - consumed],
|
||||
consumed);
|
||||
#endif
|
||||
} else
|
||||
context_count++;
|
||||
}
|
||||
|
@ -157,9 +157,11 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
|
||||
int err = 0;
|
||||
h->mb_y = 0;
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
if (CONFIG_H264_VDPAU_DECODER &&
|
||||
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
ff_vdpau_h264_set_reference_frames(h);
|
||||
#endif
|
||||
|
||||
if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
|
||||
if (!h->droppable) {
|
||||
@ -178,9 +180,11 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
|
||||
"hardware accelerator failed to decode picture\n");
|
||||
}
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
if (CONFIG_H264_VDPAU_DECODER &&
|
||||
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
ff_vdpau_h264_picture_complete(h);
|
||||
#endif
|
||||
|
||||
#if CONFIG_ERROR_RESILIENCE
|
||||
av_assert0(sl == h->slice_ctx);
|
||||
|
@ -612,8 +612,11 @@ static int h264_frame_start(H264Context *h)
|
||||
|
||||
if ((ret = alloc_picture(h, pic)) < 0)
|
||||
return ret;
|
||||
if(!h->frame_recovered && !h->avctx->hwaccel &&
|
||||
!(h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU))
|
||||
if(!h->frame_recovered && !h->avctx->hwaccel
|
||||
#if FF_API_CAP_VDPAU
|
||||
&& !(h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
#endif
|
||||
)
|
||||
avpriv_color_frame(pic->f, c);
|
||||
|
||||
h->cur_pic_ptr = pic;
|
||||
@ -1048,6 +1051,7 @@ static int h264_slice_header_init(H264Context *h)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
if (h->avctx->codec &&
|
||||
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU &&
|
||||
(h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
|
||||
@ -1056,6 +1060,7 @@ static int h264_slice_header_init(H264Context *h)
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
@ -2533,8 +2538,11 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
|
||||
|
||||
h->slice_ctx[0].next_slice_idx = INT_MAX;
|
||||
|
||||
if (h->avctx->hwaccel ||
|
||||
h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
if (h->avctx->hwaccel
|
||||
#if FF_API_CAP_VDPAU
|
||||
|| h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU
|
||||
#endif
|
||||
)
|
||||
return 0;
|
||||
if (context_count == 1) {
|
||||
int ret;
|
||||
|
@ -1186,8 +1186,10 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
|
||||
#if CONFIG_MPEG1_XVMC_HWACCEL
|
||||
AV_PIX_FMT_XVMC,
|
||||
#endif
|
||||
#if CONFIG_MPEG1_VDPAU_HWACCEL
|
||||
#if CONFIG_MPEG1_VDPAU_DECODER
|
||||
AV_PIX_FMT_VDPAU_MPEG1,
|
||||
#endif
|
||||
#if CONFIG_MPEG1_VDPAU_HWACCEL
|
||||
AV_PIX_FMT_VDPAU,
|
||||
#endif
|
||||
AV_PIX_FMT_YUV420P,
|
||||
@ -1198,8 +1200,10 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
|
||||
#if CONFIG_MPEG2_XVMC_HWACCEL
|
||||
AV_PIX_FMT_XVMC,
|
||||
#endif
|
||||
#if CONFIG_MPEG2_VDPAU_HWACCEL
|
||||
#if CONFIG_MPEG_VDPAU_DECODER
|
||||
AV_PIX_FMT_VDPAU_MPEG2,
|
||||
#endif
|
||||
#if CONFIG_MPEG2_VDPAU_HWACCEL
|
||||
AV_PIX_FMT_VDPAU,
|
||||
#endif
|
||||
#if CONFIG_MPEG2_DXVA2_HWACCEL
|
||||
@ -1228,9 +1232,11 @@ static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = {
|
||||
AV_PIX_FMT_NONE
|
||||
};
|
||||
|
||||
#if FF_API_VDPAU
|
||||
static inline int uses_vdpau(AVCodecContext *avctx) {
|
||||
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)
|
||||
{
|
||||
@ -1256,7 +1262,11 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
|
||||
static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
|
||||
{
|
||||
// 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)
|
||||
avctx->idct_algo = FF_IDCT_SIMPLE;
|
||||
|
||||
@ -2460,9 +2470,11 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
|
||||
s2->er.error_count += s2->thread_context[i]->er.error_count;
|
||||
}
|
||||
|
||||
#if FF_API_VDPAU
|
||||
if ((CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER)
|
||||
&& uses_vdpau(avctx))
|
||||
ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
|
||||
#endif
|
||||
|
||||
ret = slice_end(avctx, picture);
|
||||
if (ret < 0)
|
||||
@ -2711,10 +2723,12 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
#if FF_API_VDPAU
|
||||
if (uses_vdpau(avctx)) {
|
||||
s->slice_count++;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (HAVE_THREADS &&
|
||||
(avctx->active_thread_type & FF_THREAD_SLICE) &&
|
||||
|
@ -58,7 +58,11 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
|
||||
{
|
||||
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;
|
||||
|
||||
if (linesize < 24) {
|
||||
|
@ -1307,7 +1307,11 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
||||
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++)
|
||||
memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i,
|
||||
0x80, avctx->width);
|
||||
@ -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) */
|
||||
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;
|
||||
|
||||
|
||||
|
@ -1243,8 +1243,10 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
|
||||
|
||||
if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
|
||||
break;
|
||||
#if FF_API_CAP_VDPAU
|
||||
if (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
break;
|
||||
#endif
|
||||
|
||||
if (!setup_hwaccel(avctx, ret, desc->name))
|
||||
break;
|
||||
|
@ -647,12 +647,14 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
if (s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) {
|
||||
if (v->profile < PROFILE_ADVANCED)
|
||||
avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
|
||||
else
|
||||
avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
|
||||
}
|
||||
#endif
|
||||
|
||||
//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) {
|
||||
@ -672,15 +674,21 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (size <= 0) continue;
|
||||
switch (AV_RB32(start)) {
|
||||
case VC1_CODE_FRAME:
|
||||
if (avctx->hwaccel ||
|
||||
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
if (avctx->hwaccel
|
||||
#if FF_API_CAP_VDPAU
|
||||
|| s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU
|
||||
#endif
|
||||
)
|
||||
buf_start = start;
|
||||
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
|
||||
break;
|
||||
case VC1_CODE_FIELD: {
|
||||
int buf_size3;
|
||||
if (avctx->hwaccel ||
|
||||
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
if (avctx->hwaccel
|
||||
#if FF_API_CAP_VDPAU
|
||||
|| s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU
|
||||
#endif
|
||||
)
|
||||
buf_start_second_field = start;
|
||||
tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
|
||||
if (!tmp) {
|
||||
@ -742,8 +750,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto err;
|
||||
} else { // found field marker, unescape second field
|
||||
if (avctx->hwaccel ||
|
||||
s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)
|
||||
if (avctx->hwaccel
|
||||
#if FF_API_CAP_VDPAU
|
||||
|| s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU
|
||||
#endif
|
||||
)
|
||||
buf_start_second_field = divider;
|
||||
tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
|
||||
if (!tmp) {
|
||||
@ -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_avg = s->qdsp.avg_qpel_pixels_tab;
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
if ((CONFIG_VC1_VDPAU_DECODER)
|
||||
&&s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) {
|
||||
if (v->field_mode && buf_start_second_field) {
|
||||
@ -898,7 +910,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
} else {
|
||||
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) {
|
||||
// decode first field
|
||||
s->picture_structure = PICT_BOTTOM_FIELD - v->tff;
|
||||
|
Loading…
Reference in New Issue
Block a user