[Mesa-dev] [PATCH 18/20] st/va: detect mjpeg format from bitstream

Leo Liu leo.liu at amd.com
Tue Aug 15 20:08:36 UTC 2017


To find if the format is supported yuyv by sampling factor which
is embedded from bitstream. So we could use this info for buffer
relocation on the correct format.

Signed-off-by: Leo Liu <leo.liu at amd.com>
---
 src/gallium/state_trackers/va/picture.c       | 1 +
 src/gallium/state_trackers/va/picture_mjpeg.c | 5 +++++
 src/gallium/state_trackers/va/va_private.h    | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index 3af387ea5b..a13c1ecbb2 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -65,6 +65,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
    context->target_id = render_target;
    surf->ctx = context_id;
    context->target = surf->buffer;
+   context->mjpeg.sampling_factor = 0;
 
    if (!context->decoder) {
 
diff --git a/src/gallium/state_trackers/va/picture_mjpeg.c b/src/gallium/state_trackers/va/picture_mjpeg.c
index 326c890c88..396b743442 100644
--- a/src/gallium/state_trackers/va/picture_mjpeg.c
+++ b/src/gallium/state_trackers/va/picture_mjpeg.c
@@ -30,6 +30,7 @@
 void vlVaHandlePictureParameterBufferMJPEG(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
 {
    VAPictureParameterBufferJPEGBaseline *mjpeg = buf->data;
+   unsigned sf;
    int i;
 
    assert(buf->size >= sizeof(VAPictureParameterBufferJPEGBaseline) && buf->num_elements == 1);
@@ -46,6 +47,10 @@ void vlVaHandlePictureParameterBufferMJPEG(vlVaDriver *drv, vlVaContext *context
          mjpeg->components[i].v_sampling_factor;
       context->desc.mjpeg.picture_parameter.components[i].quantiser_table_selector =
          mjpeg->components[i].quantiser_table_selector;
+
+      sf = mjpeg->components[i].h_sampling_factor << 4 | mjpeg->components[i].v_sampling_factor;
+      context->mjpeg.sampling_factor <<= 8;
+      context->mjpeg.sampling_factor |= sf;
    }
 
    context->desc.mjpeg.picture_parameter.num_components = mjpeg->num_components;
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
index a437a5b90f..9c09318127 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -277,6 +277,10 @@ typedef struct {
       uint8_t start_code[32];
    } mpeg4;
 
+   struct {
+      unsigned sampling_factor;
+   } mjpeg;
+
    struct vl_deint_filter *deint;
    vlVaBuffer *coded_buf;
    int target_id;
-- 
2.11.0



More information about the mesa-dev mailing list