History

Merge commit '502cde409ca5ee97ef70c2cdede88b9101746ff6'

* commit '502cde409ca5ee97ef70c2cdede88b9101746ff6': vdpau: force reinitialization when output resolution changes Conflicts: libavcodec/vdpau.c

Michael Niedermayer committed 12 years ago

Commit 067d11b2 parents ec6a855 502cde42 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
@@ -83,6 +83,9 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, · 82 unmodified lines
8383 uint32_t width = (avctx->coded_width + 1) & ~1;
8484 uint32_t height = (avctx->coded_height + 3) & ~3;
8585
86+ vdctx->width = UINT32_MAX;
87+ vdctx->height = UINT32_MAX;
88+
8689 if (!hwctx) {
8790 vdctx->device = VDP_INVALID_HANDLE;
8891 av_log(avctx, AV_LOG_WARNING, "hwaccel_context has not been setup by the user application, cannot initialize\n");
@@ -115,6 +118,11 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, · 26 unmodified lines
115118
116119 status = create(vdctx->device, profile, width, height, avctx->refs,
117120 &vdctx->decoder);
121+ if (status == VDP_STATUS_OK) {
122+ vdctx->width = avctx->coded_width;
123+ vdctx->height = avctx->coded_height;
124+ }
125+
118126 return vdpau_error(status);
119127 }
120128
@@ -127,6 +135,8 @@ int ff_vdpau_common_uninit(AVCodecContext *avctx) · 6 unmodified lines
127135
128136 if (vdctx->device == VDP_INVALID_HANDLE)
129137 return 0; /* Decoder created and destroyed by user */
138+ if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
139+ return 0;
130140
131141 status = vdctx->get_proc_address(vdctx->device,
132142 VDP_FUNC_ID_DECODER_DESTROY, &func);
@@ -139,6 +149,20 @@ int ff_vdpau_common_uninit(AVCodecContext *avctx) · 6 unmodified lines
139149 return vdpau_error(status);
140150 }
141151
152+static int ff_vdpau_common_reinit(AVCodecContext *avctx)
153+{
154+ VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
155+
156+ if (vdctx->device == VDP_INVALID_HANDLE)
157+ return 0; /* Decoder created by user */
158+ if (avctx->coded_width == vdctx->width &&
159+ avctx->coded_height == vdctx->height)
160+ return 0;
161+
162+ avctx->hwaccel->uninit(avctx);
163+ return avctx->hwaccel->init(avctx);
164+}
165+
142166 int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
143167 av_unused const uint8_t *buffer,
144168 av_unused uint32_t size)
@@ -156,6 +180,11 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 11 unmodified lines
156180 AVVDPAUContext *hwctx = avctx->hwaccel_context;
157181 VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
158182 VdpStatus status;
183+ int val;
184+
185+ val = ff_vdpau_common_reinit(avctx);
186+ if (val < 0)
187+ return val;
159188
160189 #if FF_API_BUFS_VDPAU
161190 FF_DISABLE_DEPRECATION_WARNINGS
libavcodec/vdpau_internal.h+3−0
@@ -81,6 +81,9 @@ typedef struct VDPAUContext { · 80 unmodified lines
8181 * VDPAU decoder render callback
8282 */
8383 VdpDecoderRender *render;
84+
85+ uint32_t width;
86+ uint32_t height;
8487 } VDPAUContext;
8588
8689 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