Lines Matching refs:frame
103 struct sna_video_frame *frame)
106 if (video->buf && __kgem_bo_size(video->buf) < frame->size)
110 if (frame->width != video->width ||
111 frame->height != video->height ||
112 frame->id != video->format)
119 frame->width, frame->height, 32,
122 video->buf = kgem_create_linear(&video->sna->kgem, frame->size,
127 video->width = frame->width;
128 video->height = frame->height;
129 video->format = frame->id;
146 struct sna_video_frame *frame,
187 crtc_region, frame->width, frame->height);
191 frame->src.x1 = x1 >> 16;
192 frame->src.y1 = y1 >> 16;
193 frame->src.x2 = (x2 + 0xffff) >> 16;
194 frame->src.y2 = (y2 + 0xffff) >> 16;
196 frame->image.x1 = frame->src.x1 & ~1;
197 frame->image.x2 = ALIGN(frame->src.x2, 2);
198 if (is_planar_fourcc(frame->id)) {
199 frame->image.y1 = frame->src.y1 & ~1;
200 frame->image.y2 = ALIGN(frame->src.y2, 2);
202 frame->image.y1 = frame->src.y1;
203 frame->image.y2 = frame->src.y2;
212 struct sna_video_frame *frame)
218 frame->bo = NULL;
219 frame->id = id;
220 frame->width = width;
221 frame->height = height;
222 frame->rotation = 0;
227 struct sna_video_frame *frame,
230 unsigned width = frame->width;
231 unsigned height = frame->height;
235 frame->rotation = rotation;
240 if (frame->id == FOURCC_XVMC && video->sna->kgem.gen < 040 && align < 1024)
247 if (is_nv12_fourcc(frame->id)) {
251 frame->pitch[0] = ALIGN(height, align);
252 frame->pitch[1] = ALIGN(height, align);
253 frame->size = width * frame->pitch[1] +
254 width / 2 * frame->pitch[0];
256 frame->pitch[0] = ALIGN(width, align);
257 frame->pitch[1] = ALIGN(width, align);
258 frame->size = height * frame->pitch[1] +
259 height / 2 * frame->pitch[0];
263 frame->UBufOffset = (int)frame->pitch[1] * width;
264 frame->VBufOffset = frame->UBufOffset;
266 frame->UBufOffset = (int)frame->pitch[1] * height;
267 frame->VBufOffset = frame->UBufOffset;
269 } else if (is_planar_fourcc(frame->id)) {
273 frame->pitch[0] = ALIGN((height / 2), align);
274 frame->pitch[1] = ALIGN(height, align);
275 frame->size = width;
277 frame->pitch[0] = ALIGN((width / 2), align);
278 frame->pitch[1] = ALIGN(width, align);
279 frame->size = height;
281 frame->size *= frame->pitch[0] + frame->pitch[1];
284 frame->UBufOffset = (int)frame->pitch[1] * width;
285 frame->VBufOffset =
286 frame->UBufOffset + (int)frame->pitch[0] * width / 2;
288 frame->UBufOffset = (int)frame->pitch[1] * height;
289 frame->VBufOffset =
290 frame->UBufOffset + (int)frame->pitch[0] * height / 2;
293 switch (frame->id) {
297 frame->pitch[0] = ALIGN((height << 2), align);
298 frame->size = (int)frame->pitch[0] * width;
300 frame->pitch[0] = ALIGN((width << 2), align);
301 frame->size = (int)frame->pitch[0] * height;
303 frame->UBufOffset = frame->VBufOffset = 0;
307 frame->pitch[0] = ALIGN((height << 1), align);
308 frame->size = (int)frame->pitch[0] * width;
310 frame->pitch[0] = ALIGN((width << 1), align);
311 frame->size = (int)frame->pitch[0] * height;
313 frame->UBufOffset = frame->VBufOffset = 0;
318 frame->pitch[0] = ALIGN((height << 1), align);
319 frame->size = (int)frame->pitch[0] * width;
321 frame->pitch[0] = ALIGN((width << 1), align);
322 frame->size = (int)frame->pitch[0] * height;
326 frame->pitch[1] = 0;
327 frame->UBufOffset = 0;
328 frame->VBufOffset = 0;
331 assert(frame->size);
334 static void plane_dims(const struct sna_video_frame *frame, int sub,
337 *x = frame->image.x1;
338 *y = frame->image.y1;
339 *w = frame->image.x2 - frame->image.x1;
340 *h = frame->image.y2 - frame->image.y1;
350 const struct sna_video_frame *frame)
352 int dstPitch = frame->pitch[0] >> 1, srcPitch;
357 plane_dims(frame, 1, &x, &y, &w, &h);
359 srcPitch = ALIGN((frame->width >> 1), 2);
365 switch (frame->rotation) {
408 const struct sna_video_frame *frame, int sub)
410 int dstPitch = frame->pitch[!sub], srcPitch;
415 plane_dims(frame, sub, &x, &y, &w, &h);
418 srcPitch = ALIGN((frame->width >> 1), 4);
420 srcPitch = ALIGN(frame->width, 4);
426 switch (frame->rotation) {
469 const struct sna_video_frame *frame,
472 sna_memcpy_plane(video, dst, src, frame, 0);
473 src += frame->height * ALIGN(frame->width, 4);
474 dst += frame->UBufOffset;
475 sna_memcpy_cbcr_plane(video, (void*)dst, (void*)src, frame);
480 const struct sna_video_frame *frame,
485 sna_memcpy_plane(video, dst, src, frame, 0);
486 src += frame->height * ALIGN(frame->width, 4);
488 if (frame->id == FOURCC_I420)
489 d = dst + frame->UBufOffset;
491 d = dst + frame->VBufOffset;
492 sna_memcpy_plane(video, d, src, frame, 1);
493 src += (frame->height >> 1) * ALIGN(frame->width >> 1, 4);
495 if (frame->id == FOURCC_I420)
496 d = dst + frame->VBufOffset;
498 d = dst + frame->UBufOffset;
499 sna_memcpy_plane(video, d, src, frame, 1);
504 const struct sna_video_frame *frame,
508 int pitch = frame->width << 1;
516 w = frame->width;
517 h = frame->height;
519 x = frame->image.x1;
520 y = frame->image.y1;
521 w = frame->image.x2 - frame->image.x1;
522 h = frame->image.y2 - frame->image.y1;
527 switch (frame->rotation) {
533 dst += frame->pitch[0];
542 dst[(i + 0) + ((w - j - 1) * frame->pitch[0])] = *s;
552 dst[((i * 2) + 1) + ((w - j - 1) * frame->pitch[0])] = src[(j * 2) + 1 + (i * pitch)];
553 dst[((i * 2) + 1) + ((w - j - 2) * frame->pitch[0])] = src[(j * 2) + 1 + ((i + 1) * pitch)];
554 /* Copy V */ dst[((i * 2) + 3) + ((w - j - 1) * frame->pitch[0])] = src[(j * 2) + 3 + (i * pitch)];
555 dst[((i * 2) + 3) + ((w - j - 2) * frame->pitch[0])] = src[(j * 2) + 3 + ((i + 1) * pitch)];
564 dst[(w - j - 4) + ((h - i - 1) * frame->pitch[0])] = *s++;
565 dst[(w - j - 3) + ((h - i - 1) * frame->pitch[0])] = *s++;
566 dst[(w - j - 2) + ((h - i - 1) * frame->pitch[0])] = *s++;
567 dst[(w - j - 1) + ((h - i - 1) * frame->pitch[0])] = *s++;
578 dst[(h - i - 2) + (j * frame->pitch[0])] = *s;
588 dst[(((h - i) * 2) - 3) + (j * frame->pitch[0])] = src[(j * 2) + 1 + (i * pitch)];
589 dst[(((h - i) * 2) - 3) + ((j + 1) * frame->pitch[0])] = src[(j * 2) + 1 + ((i + 1) * pitch)];
591 dst[(((h - i) * 2) - 1) + (j * frame->pitch[0])] = src[(j * 2) + 3 + (i * pitch)];
592 dst[(((h - i) * 2) - 1) + ((j + 1) * frame->pitch[0])] = src[(j * 2) + 3 + ((i + 1) * pitch)];
601 const struct sna_video_frame *frame,
605 int pitch = frame->width << 2;
615 w = frame->width;
616 h = frame->height;
618 x = frame->image.x1;
619 y = frame->image.y1;
620 w = frame->image.x2 - frame->image.x1;
621 h = frame->image.y2 - frame->image.y1;
627 switch (frame->rotation) {
667 struct sna_video_frame *frame,
673 __FUNCTION__, frame->bo ? frame->bo->handle : 0,
674 frame->width, frame->height, frame->size, frame->pitch[0], frame->pitch[1],
675 frame->rotation, video->textured));
678 frame->image.x1, frame->image.y1, frame->image.x2, frame->image.y2,
679 frame->src.x1, frame->src.y1, frame->src.x2, frame->src.y2));
680 assert(frame->width && frame->height);
681 assert(frame->rotation);
682 assert(frame->size);
685 if (frame->rotation == RR_Rotate_0 && !video->tiled && !is_ayuv_fourcc(frame->id)) {
687 __FUNCTION__, is_planar_fourcc(frame->id)));
688 if (is_nv12_fourcc(frame->id)) {
689 int w = frame->image.x2 - frame->image.x1;
690 int h = frame->image.y2 - frame->image.y1;
691 if (ALIGN(h, 2) == frame->height &&
692 ALIGN(w, 4) == frame->pitch[0] &&
693 ALIGN(w, 4) == frame->pitch[1]) {
694 if (frame->bo) {
695 if (!kgem_bo_write(&video->sna->kgem, frame->bo,
696 buf, frame->size))
699 frame->bo = kgem_create_buffer(&video->sna->kgem, frame->size,
702 if (frame->bo == NULL)
705 memcpy(dst, buf, frame->size);
709 } else if (is_planar_fourcc(frame->id)) {
710 int w = frame->image.x2 - frame->image.x1;
711 int h = frame->image.y2 - frame->image.y1;
712 if (ALIGN(h, 2) == frame->height &&
713 ALIGN(w >> 1, 4) == frame->pitch[0] &&
714 ALIGN(w, 4) == frame->pitch[1]) {
715 if (frame->bo) {
716 if (!kgem_bo_write(&video->sna->kgem, frame->bo,
717 buf, frame->size))
720 frame->bo = kgem_create_buffer(&video->sna->kgem, frame->size,
723 if (frame->bo == NULL)
726 memcpy(dst, buf, frame->size);
728 if (frame->id != FOURCC_I420) {
730 tmp = frame->VBufOffset;
731 frame->VBufOffset = frame->UBufOffset;
732 frame->UBufOffset = tmp;
742 w = frame->width;
743 h = frame->height;
745 x = frame->image.x1;
746 y = frame->image.y1;
747 w = frame->image.x2 - frame->image.x1;
748 h = frame->image.y2 - frame->image.y1;
751 if (w*2 == frame->pitch[0]) {
752 buf += (2U*y * frame->width) + (x << 1);
753 if (frame->bo) {
754 if (!kgem_bo_write(&video->sna->kgem, frame->bo,
755 buf, 2U*h*frame->width))
758 frame->bo = kgem_create_buffer(&video->sna->kgem, frame->size,
761 if (frame->bo == NULL)
764 memcpy(dst, buf, 2U*h*frame->width);
774 if (frame->bo) {
775 dst = kgem_bo_map__gtt(&video->sna->kgem, frame->bo);
779 frame->bo = kgem_create_buffer(&video->sna->kgem, frame->size,
782 if (frame->bo == NULL)
786 if (is_nv12_fourcc(frame->id))
787 sna_copy_nv12_data(video, frame, buf, dst);
788 else if (is_planar_fourcc(frame->id))
789 sna_copy_planar_data(video, frame, buf, dst);
790 else if (is_ayuv_fourcc(frame->id))
791 sna_copy_ayuv_data(video, frame, buf, dst);
793 sna_copy_packed_data(video, frame, buf, dst);