i965_drv_video: fix the format of a derived image for MPEG2 on ILK 44/744/1
authorXiang, Haihao <haihao.xiang@intel.com>
Mon, 11 Apr 2011 02:13:17 +0000 (10:13 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 11 Apr 2011 02:13:17 +0000 (10:13 +0800)
The native format used for MPEG2 decoding on ILK is I420

i965_drv_video/i965_drv_video.c
i965_drv_video/i965_render.c
i965_drv_video/i965_render.h

index b325ce6..e1bceba 100644 (file)
@@ -775,6 +775,8 @@ i965_CreateContext(VADriverContextP ctx,
         return vaStatus;
     }
 
+    render_state->inited = 1;
+
     switch (obj_config->profile) {
     case VAProfileH264Baseline:
     case VAProfileH264Main:
@@ -1572,26 +1574,39 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
     image->height = obj_surface->orig_height;
     image->data_size = data_size;
 
-    if (render_state->interleaved_uv) {
-        image->format.fourcc = VA_FOURCC('N','V','1','2');
-        image->format.byte_order = VA_LSB_FIRST;
-        image->format.bits_per_pixel = 12;
-        image->num_planes = 2;
-        image->pitches[0] = w_pitch;
-        image->offsets[0] = 0;
-        image->pitches[1] = w_pitch;
-        image->offsets[1] = w_pitch * h_pitch;
+    if (!render_state->inited) {
+            image->format.fourcc = VA_FOURCC('Y','V','1','2');
+            image->format.byte_order = VA_LSB_FIRST;
+            image->format.bits_per_pixel = 12;
+            image->num_planes = 3;
+            image->pitches[0] = w_pitch;
+            image->offsets[0] = 0;
+            image->pitches[1] = w_pitch / 2;
+            image->offsets[1] = w_pitch * h_pitch;
+            image->pitches[2] = w_pitch / 2;
+            image->offsets[2] = w_pitch * h_pitch + (w_pitch / 2) * (h_pitch / 2);
     } else {
-        image->format.fourcc = VA_FOURCC('Y','V','1','2');
-        image->format.byte_order = VA_LSB_FIRST;
-        image->format.bits_per_pixel = 12;
-        image->num_planes = 3;
-        image->pitches[0] = w_pitch;
-        image->offsets[0] = 0;
-        image->pitches[1] = w_pitch / 2;
-        image->offsets[1] = w_pitch * h_pitch;
-        image->pitches[2] = w_pitch / 2;
-        image->offsets[2] = w_pitch * h_pitch + (w_pitch / 2) * (h_pitch / 2);
+        if (render_state->interleaved_uv) {
+            image->format.fourcc = VA_FOURCC('N','V','1','2');
+            image->format.byte_order = VA_LSB_FIRST;
+            image->format.bits_per_pixel = 12;
+            image->num_planes = 2;
+            image->pitches[0] = w_pitch;
+            image->offsets[0] = 0;
+            image->pitches[1] = w_pitch;
+            image->offsets[1] = w_pitch * h_pitch;
+        } else {
+            image->format.fourcc = VA_FOURCC('I','4','2','0');
+            image->format.byte_order = VA_LSB_FIRST;
+            image->format.bits_per_pixel = 12;
+            image->num_planes = 3;
+            image->pitches[0] = w_pitch;
+            image->offsets[0] = 0;
+            image->pitches[1] = w_pitch / 2;
+            image->offsets[1] = w_pitch * h_pitch;
+            image->pitches[2] = w_pitch / 2;
+            image->offsets[2] = w_pitch * h_pitch + (w_pitch / 2) * (h_pitch / 2);
+        }
     }
 
     if (obj_surface->bo == NULL) {
index 3092195..efed4c3 100644 (file)
@@ -681,20 +681,25 @@ i965_render_src_surfaces_state(VADriverContextP ctx,
     i965_render_src_surface_state(ctx, 1, region, 0, rw, rh, w, I965_SURFACEFORMAT_R8_UNORM);     /* Y */
     i965_render_src_surface_state(ctx, 2, region, 0, rw, rh, w, I965_SURFACEFORMAT_R8_UNORM);
 
-    if (render_state->interleaved_uv) {
-        i965_render_src_surface_state(ctx, 3, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8G8_UNORM); /* UV */
-        i965_render_src_surface_state(ctx, 4, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8G8_UNORM);
-    } else {
-        int u3 = 3, u4 = 4, v5 = 5, v6 = 6;
+    if (!render_state->inited) {
+        int u3 = 5, u4 = 6, v5 = 3, v6 = 4;
 
-        if (obj_surface->flags & SURFACE_DERIVED) {
-            u3 = 5, u4 = 6, v5 = 3, v6 = 4;
-        }
-        
         i965_render_src_surface_state(ctx, u3, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM); /* U */
         i965_render_src_surface_state(ctx, u4, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
         i965_render_src_surface_state(ctx, v5, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);     /* V */
         i965_render_src_surface_state(ctx, v6, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
+    } else {
+        if (render_state->interleaved_uv) {
+            i965_render_src_surface_state(ctx, 3, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8G8_UNORM); /* UV */
+            i965_render_src_surface_state(ctx, 4, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8G8_UNORM);
+        } else {
+            int u3 = 3, u4 = 4, v5 = 5, v6 = 6;
+
+            i965_render_src_surface_state(ctx, u3, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM); /* U */
+            i965_render_src_surface_state(ctx, u4, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
+            i965_render_src_surface_state(ctx, v5, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);     /* V */
+            i965_render_src_surface_state(ctx, v6, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
+        }
     }
 }
 
index 8ff4fe2..dc7bcc2 100644 (file)
@@ -66,7 +66,8 @@ struct i965_render_state
         int upload;
     } curbe;
 
-    int interleaved_uv;
+    unsigned short interleaved_uv;
+    unsigned short inited;
     struct intel_region *draw_region;
 
     int pp_flag; /* 0: disable, 1: enable */