st/va: detect MJPEG format from bitstream
authorLeo Liu <leo.liu@amd.com>
Tue, 15 Aug 2017 18:08:02 +0000 (14:08 -0400)
committerLeo Liu <leo.liu@amd.com>
Mon, 21 Aug 2017 14:09:09 +0000 (10:09 -0400)
To find if the format is supported YUYV by sampling factor which
is embedded from bitstream. So we could use this info for buffer
reallocation on the correct format.

Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/state_trackers/va/picture.c
src/gallium/state_trackers/va/picture_mjpeg.c
src/gallium/state_trackers/va/va_private.h

index 732079139eafe29bad898d4cb289d3574f2348cb..1e1212dd7a91d650ae909104bea544804ea999e2 100644 (file)
@@ -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) {
 
index 326c890c8809c5a4fcc8b78e60f7a4340e937cc1..396b743442555355a7a2b1e663db82ed82248c4a 100644 (file)
@@ -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;
index a437a5b90f1ae58125673a9a312ed88d6f54963e..9c09318127715741cd7840788b86a1a062d96229 100644 (file)
@@ -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;