OSDN Git Service

Merge branch 'snb-encoder'
[android-x86/hardware-intel-common-vaapi.git] / i965_drv_video.c
index 766d513..aa746f2 100644 (file)
@@ -788,6 +788,8 @@ i965_CreateContext(VADriverContextP ctx,
         return vaStatus;
     }
 
+    render_state->inited = 1;
+
     switch (obj_config->profile) {
     case VAProfileH264Baseline:
     case VAProfileH264Main:
@@ -1652,26 +1654,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) {
@@ -1718,6 +1733,7 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
 
     *out_image = *image;
     obj_surface->flags |= SURFACE_DERIVED;
+    obj_image->derived_surface = surface;
 
     return VA_STATUS_SUCCESS;