History

vdpau: force reinitialization when output resolution changes

This is necessary to recreate the decoder with the correct parameters, as not all codecs invoke get_format() in this case.

Rémi Denis-Courmont committed 12 years ago

Commit 502cde41 parent 89ac99b2 files · +32 −0Browse files

Unified · Split

2 files
  1. libavcodec/vdpau.c +29 −0
  2. libavcodec/vdpau_internal.h +3 −0
libavcodec/vdpau.c+29−0
@@ -76,6 +76,9 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, · 75 unmodified lines
7676 uint32_t width = (avctx->coded_width + 1) & ~1;
7777 uint32_t height = (avctx->coded_height + 3) & ~3;
7878
79+ vdctx->width = UINT32_MAX;
80+ vdctx->height = UINT32_MAX;
81+
7982 if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
8083 vdctx->decoder = hwctx->context.decoder;
8184 vdctx->render = hwctx->context.render;
@@ -102,6 +105,11 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, · 20 unmodified lines
102105
103106 status = create(vdctx->device, profile, width, height, avctx->refs,
104107 &vdctx->decoder);
108+ if (status == VDP_STATUS_OK) {
109+ vdctx->width = avctx->coded_width;
110+ vdctx->height = avctx->coded_height;
111+ }
112+
105113 return vdpau_error(status);
106114 }
107115
@@ -114,6 +122,8 @@ int ff_vdpau_common_uninit(AVCodecContext *avctx) · 6 unmodified lines
114122
115123 if (vdctx->device == VDP_INVALID_HANDLE)
116124 return 0; /* Decoder created and destroyed by user */
125+ if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
126+ return 0;
117127
118128 status = vdctx->get_proc_address(vdctx->device,
119129 VDP_FUNC_ID_DECODER_DESTROY, &func);
@@ -126,6 +136,20 @@ int ff_vdpau_common_uninit(AVCodecContext *avctx) · 6 unmodified lines
126136 return vdpau_error(status);
127137 }
128138
139+static int ff_vdpau_common_reinit(AVCodecContext *avctx)
140+{
141+ VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
142+
143+ if (vdctx->device == VDP_INVALID_HANDLE)
144+ return 0; /* Decoder created by user */
145+ if (avctx->coded_width == vdctx->width &&
146+ avctx->coded_height == vdctx->height)
147+ return 0;
148+
149+ avctx->hwaccel->uninit(avctx);
150+ return avctx->hwaccel->init(avctx);
151+}
152+
129153 int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
130154 av_unused const uint8_t *buffer,
131155 av_unused uint32_t size)
@@ -142,6 +166,11 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 10 unmodified lines
142166 VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
143167 VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
144168 VdpStatus status;
169+ int val;
170+
171+ val = ff_vdpau_common_reinit(avctx);
172+ if (val < 0)
173+ return val;
145174
146175 status = vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info,
147176 pic_ctx->bitstream_buffers_used,
libavcodec/vdpau_internal.h+3−0
@@ -74,6 +74,9 @@ typedef struct VDPAUContext { · 73 unmodified lines
7474 * VDPAU decoder render callback
7575 */
7676 VdpDecoderRender *render;
77+
78+ uint32_t width;
79+ uint32_t height;
7780 } VDPAUContext;
7881
7982 struct vdpau_picture_context {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t