st/va: move MPEG12 functions into separate file
authorChristian König <christian.koenig@amd.com>
Mon, 23 Nov 2015 13:03:52 +0000 (14:03 +0100)
committerChristian König <christian.koenig@amd.com>
Tue, 24 Nov 2015 14:31:35 +0000 (15:31 +0100)
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Julien Isorce <j.isorce@samsung.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
src/gallium/state_trackers/va/Makefile.sources
src/gallium/state_trackers/va/picture.c
src/gallium/state_trackers/va/picture_mpeg12.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_private.h

index dd0cef5f10431fb4ff2755c7339fe9a4e4d9d3bf..e0ab43fafa8c742d9d872cde64ccf514b63d8016 100644 (file)
@@ -5,6 +5,7 @@ C_SOURCES := \
        display.c \
        image.c \
        picture.c \
+       picture_mpeg12.c \
        postproc.c \
        subpicture.c \
        surface.c \
index 23a1ffae798c675cb92382d4e1c84a67617267fb..67b7acb56669b138a339a2ebd0e654dd77bde017 100644 (file)
@@ -75,9 +75,9 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
    return VA_STATUS_SUCCESS;
 }
 
-static void
-getReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id,
-                  struct pipe_video_buffer **ref_frame)
+void
+vlVaGetReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id,
+                      struct pipe_video_buffer **ref_frame)
 {
    vlVaSurface *surf = handle_table_get(drv->htab, surface_id);
    if (surf)
@@ -89,7 +89,6 @@ getReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id,
 static void
 handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
 {
-   VAPictureParameterBufferMPEG2 *mpeg2;
    VAPictureParameterBufferH264 *h264;
    VAPictureParameterBufferVC1 * vc1;
    VAPictureParameterBufferMPEG4 *mpeg4;
@@ -102,36 +101,7 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *
 
    switch (u_reduce_video_profile(context->decoder->profile)) {
    case PIPE_VIDEO_FORMAT_MPEG12:
-      assert(buf->size >= sizeof(VAPictureParameterBufferMPEG2) && buf->num_elements == 1);
-      mpeg2 = buf->data;
-      /*horizontal_size;*/
-      /*vertical_size;*/
-      getReferenceFrame(drv, mpeg2->forward_reference_picture, &context->desc.mpeg12.ref[0]);
-      getReferenceFrame(drv, mpeg2->backward_reference_picture, &context->desc.mpeg12.ref[1]);
-      context->desc.mpeg12.picture_coding_type = mpeg2->picture_coding_type;
-      context->desc.mpeg12.f_code[0][0] = ((mpeg2->f_code >> 12) & 0xf) - 1;
-      context->desc.mpeg12.f_code[0][1] = ((mpeg2->f_code >> 8) & 0xf) - 1;
-      context->desc.mpeg12.f_code[1][0] = ((mpeg2->f_code >> 4) & 0xf) - 1;
-      context->desc.mpeg12.f_code[1][1] = (mpeg2->f_code & 0xf) - 1;
-      context->desc.mpeg12.intra_dc_precision =
-         mpeg2->picture_coding_extension.bits.intra_dc_precision;
-      context->desc.mpeg12.picture_structure =
-         mpeg2->picture_coding_extension.bits.picture_structure;
-      context->desc.mpeg12.top_field_first =
-         mpeg2->picture_coding_extension.bits.top_field_first;
-      context->desc.mpeg12.frame_pred_frame_dct =
-         mpeg2->picture_coding_extension.bits.frame_pred_frame_dct;
-      context->desc.mpeg12.concealment_motion_vectors =
-         mpeg2->picture_coding_extension.bits.concealment_motion_vectors;
-      context->desc.mpeg12.q_scale_type =
-         mpeg2->picture_coding_extension.bits.q_scale_type;
-      context->desc.mpeg12.intra_vlc_format =
-         mpeg2->picture_coding_extension.bits.intra_vlc_format;
-      context->desc.mpeg12.alternate_scan =
-         mpeg2->picture_coding_extension.bits.alternate_scan;
-      /*repeat_first_field*/
-      /*progressive_frame*/
-      /*is_first_field*/
+      vlVaHandlePictureParameterBufferMPEG12(drv, context, buf);
       break;
 
    case PIPE_VIDEO_FORMAT_MPEG4_AVC:
@@ -199,8 +169,8 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *
    case PIPE_VIDEO_FORMAT_VC1:
       assert(buf->size >= sizeof(VAPictureParameterBufferVC1) && buf->num_elements == 1);
       vc1 = buf->data;
-      getReferenceFrame(drv, vc1->forward_reference_picture, &context->desc.vc1.ref[0]);
-      getReferenceFrame(drv, vc1->backward_reference_picture, &context->desc.vc1.ref[1]);
+      vlVaGetReferenceFrame(drv, vc1->forward_reference_picture, &context->desc.vc1.ref[0]);
+      vlVaGetReferenceFrame(drv, vc1->backward_reference_picture, &context->desc.vc1.ref[1]);
       context->desc.vc1.picture_type = vc1->picture_fields.bits.picture_type;
       context->desc.vc1.frame_coding_mode = vc1->picture_fields.bits.frame_coding_mode;
       context->desc.vc1.postprocflag = vc1->post_processing != 0;
@@ -433,7 +403,7 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *
          if (index == 0x7F)
             continue;
 
-         getReferenceFrame(drv, hevc->ReferenceFrames[i].picture_id, &context->desc.h265.ref[i]);
+         vlVaGetReferenceFrame(drv, hevc->ReferenceFrames[i].picture_id, &context->desc.h265.ref[i]);
 
          if ((hevc->ReferenceFrames[i].flags & VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE) && (iBefore < 8)) {
             context->desc.h265.RefPicSetStCurrBefore[iBefore++] = i;
@@ -458,24 +428,13 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *
 static void
 handleIQMatrixBuffer(vlVaContext *context, vlVaBuffer *buf)
 {
-   VAIQMatrixBufferMPEG2 *mpeg2;
    VAIQMatrixBufferH264 *h264;
    VAIQMatrixBufferMPEG4 *mpeg4;
    VAIQMatrixBufferHEVC *h265;
 
    switch (u_reduce_video_profile(context->decoder->profile)) {
    case PIPE_VIDEO_FORMAT_MPEG12:
-      assert(buf->size >= sizeof(VAIQMatrixBufferMPEG2) && buf->num_elements == 1);
-      mpeg2 = buf->data;
-      if (mpeg2->load_intra_quantiser_matrix)
-         context->desc.mpeg12.intra_matrix = mpeg2->intra_quantiser_matrix;
-      else
-         context->desc.mpeg12.intra_matrix = NULL;
-
-      if (mpeg2->load_non_intra_quantiser_matrix)
-         context->desc.mpeg12.non_intra_matrix = mpeg2->non_intra_quantiser_matrix;
-      else
-         context->desc.mpeg12.non_intra_matrix = NULL;
+      vlVaHandleIQMatrixBufferMPEG12(context, buf);
       break;
 
    case PIPE_VIDEO_FORMAT_MPEG4_AVC:
diff --git a/src/gallium/state_trackers/va/picture_mpeg12.c b/src/gallium/state_trackers/va/picture_mpeg12.c
new file mode 100644 (file)
index 0000000..e587b1e
--- /dev/null
@@ -0,0 +1,80 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "va_private.h"
+
+void vlVaHandlePictureParameterBufferMPEG12(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
+{
+   VAPictureParameterBufferMPEG2 *mpeg2 = buf->data;
+
+   assert(buf->size >= sizeof(VAPictureParameterBufferMPEG2) && buf->num_elements == 1);
+   /*horizontal_size;*/
+   /*vertical_size;*/
+   vlVaGetReferenceFrame(drv, mpeg2->forward_reference_picture, &context->desc.mpeg12.ref[0]);
+   vlVaGetReferenceFrame(drv, mpeg2->backward_reference_picture, &context->desc.mpeg12.ref[1]);
+   context->desc.mpeg12.picture_coding_type = mpeg2->picture_coding_type;
+   context->desc.mpeg12.f_code[0][0] = ((mpeg2->f_code >> 12) & 0xf) - 1;
+   context->desc.mpeg12.f_code[0][1] = ((mpeg2->f_code >> 8) & 0xf) - 1;
+   context->desc.mpeg12.f_code[1][0] = ((mpeg2->f_code >> 4) & 0xf) - 1;
+   context->desc.mpeg12.f_code[1][1] = (mpeg2->f_code & 0xf) - 1;
+   context->desc.mpeg12.intra_dc_precision =
+      mpeg2->picture_coding_extension.bits.intra_dc_precision;
+   context->desc.mpeg12.picture_structure =
+      mpeg2->picture_coding_extension.bits.picture_structure;
+   context->desc.mpeg12.top_field_first =
+      mpeg2->picture_coding_extension.bits.top_field_first;
+   context->desc.mpeg12.frame_pred_frame_dct =
+      mpeg2->picture_coding_extension.bits.frame_pred_frame_dct;
+   context->desc.mpeg12.concealment_motion_vectors =
+      mpeg2->picture_coding_extension.bits.concealment_motion_vectors;
+   context->desc.mpeg12.q_scale_type =
+      mpeg2->picture_coding_extension.bits.q_scale_type;
+   context->desc.mpeg12.intra_vlc_format =
+      mpeg2->picture_coding_extension.bits.intra_vlc_format;
+   context->desc.mpeg12.alternate_scan =
+      mpeg2->picture_coding_extension.bits.alternate_scan;
+   /*repeat_first_field*/
+   /*progressive_frame*/
+   /*is_first_field*/
+}
+
+void vlVaHandleIQMatrixBufferMPEG12(vlVaContext *context, vlVaBuffer *buf)
+{
+   VAIQMatrixBufferMPEG2 *mpeg2 = buf->data;
+
+   assert(buf->size >= sizeof(VAIQMatrixBufferMPEG2) && buf->num_elements == 1);
+   if (mpeg2->load_intra_quantiser_matrix)
+      context->desc.mpeg12.intra_matrix = mpeg2->intra_quantiser_matrix;
+   else
+      context->desc.mpeg12.intra_matrix = NULL;
+
+   if (mpeg2->load_non_intra_quantiser_matrix)
+      context->desc.mpeg12.non_intra_matrix = mpeg2->non_intra_quantiser_matrix;
+   else
+      context->desc.mpeg12.non_intra_matrix = NULL;
+}
+
index aeaf424a2dfff3bdc343c34fb8fa708cf7a6fde4..894860059fb5d1455b5a06b9257ea475c80f9cdb 100644 (file)
@@ -343,5 +343,8 @@ VAStatus vlVaQueryVideoProcPipelineCaps(VADriverContextP ctx, VAContextID contex
 
 // internal functions
 VAStatus vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
+void vlVaGetReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id, struct pipe_video_buffer **ref_frame);
+void vlVaHandlePictureParameterBufferMPEG12(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
+void vlVaHandleIQMatrixBufferMPEG12(vlVaContext *context, vlVaBuffer *buf);
 
 #endif //VA_PRIVATE_H