+/**
+ * It updates a picture data/pitches.
+ */
+int CommonUpdatePicture(picture_t *picture, picture_t **fallback,
+ uint8_t *data, unsigned pitch)
+{
+ if (fallback) {
+ if (*fallback == NULL) {
+ *fallback = picture_NewFromFormat(&picture->format);
+ if (*fallback == NULL)
+ return VLC_EGENERIC;
+ }
+ for (int n = 0; n < picture->i_planes; n++) {
+ const plane_t *src = &(*fallback)->p[n];
+ plane_t *dst = &picture->p[n];
+ dst->p_pixels = src->p_pixels;
+ dst->i_pitch = src->i_pitch;
+ dst->i_lines = src->i_lines;
+ }
+ return VLC_SUCCESS;
+ }
+ /* fill in buffer info in first plane */
+ picture->p->p_pixels = data;
+ picture->p->i_pitch = pitch;
+ picture->p->i_lines = picture->format.i_height;
+
+ /* Fill chroma planes for planar YUV */
+ if (picture->format.i_chroma == VLC_CODEC_I420 ||
+ picture->format.i_chroma == VLC_CODEC_J420 ||
+ picture->format.i_chroma == VLC_CODEC_YV12) {
+
+ for (int n = 1; n < picture->i_planes; n++) {
+ const plane_t *o = &picture->p[n-1];
+ plane_t *p = &picture->p[n];
+
+ p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
+ p->i_pitch = pitch / 2;
+ p->i_lines = picture->format.i_height / 2;
+ }
+ /* The dx/d3d buffer is always allocated as YV12 */
+ if (vlc_fourcc_AreUVPlanesSwapped(picture->format.i_chroma, VLC_CODEC_YV12)) {
+ uint8_t *p_tmp = picture->p[1].p_pixels;
+ picture->p[1].p_pixels = picture->p[2].p_pixels;
+ picture->p[2].p_pixels = p_tmp;
+ }
+ }
+ return VLC_SUCCESS;
+}
+
+void AlignRect(RECT *r, int align_boundary, int align_size)
+{
+ if (align_boundary)
+ r->left = (r->left + align_boundary/2) & ~align_boundary;
+ if (align_size)
+ r->right = ((r->right - r->left + align_size/2) & ~align_size) + r->left;
+}
+
+/* */
+static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
+{
+#ifndef UNDER_CE
+ vout_display_sys_t *sys = vd->sys;
+
+ /* Windows 7 taskbar thumbnail code */
+ OSVERSIONINFO winVer;
+ winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if (!GetVersionEx(&winVer) || winVer.dwMajorVersion <= 5)
+ return;
+
+ CoInitialize(0);
+
+ LPTASKBARLIST3 taskbl;
+ if (S_OK == CoCreateInstance(&clsid_ITaskbarList,
+ NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskbarList3,
+ &taskbl)) {
+ taskbl->vt->HrInit(taskbl);
+
+ HWND hroot = GetAncestor(sys->hwnd,GA_ROOT);
+ RECT relative;
+ if (show) {
+ RECT video, parent;
+ GetWindowRect(sys->hvideownd, &video);
+ GetWindowRect(hroot, &parent);
+ relative.left = video.left - parent.left - 8;
+ relative.top = video.top - parent.top - 10;
+
+ relative.right = video.right - video.left + relative.left;
+ relative.bottom = video.bottom - video.top + relative.top - 25;
+ }
+ if (S_OK != taskbl->vt->SetThumbnailClip(taskbl, hroot,
+ show ? &relative : NULL))
+ msg_Err(vd, "SetThumbNailClip failed");
+
+ taskbl->vt->Release(taskbl);
+ }
+ CoUninitialize();
+#endif
+}
+