[PORT FROM R3] Fix MPEG4 multiple frame issue.

BZ: 43475

Streams may contain vol header, so the first item is not the vop,then
the framesize won't be set. Use the last picdata offset and size to
calculate the next frame offset.

Orignal Change-Id: If06e4bfbfc66dbd57839d8a10c60f11013626fc5

Change-Id: I94060ff7c5dfc780a913fd5cd25d4a6457a8eac6
Signed-off-by: fxiao4X <fengx.xiao@intel.com>
Reviewed-on: http://android.intel.com:8080/59193
Reviewed-by: buildbot <buildbot@intel.com>
Reviewed-by: Zhang, Xiaolin <xiaolin.zhang@intel.com>
Tested-by: Zhang, Xiaolin <xiaolin.zhang@intel.com>
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_loader.h b/mix_vbp/viddec_fw/fw/parser/vbp_loader.h
index 7037fd0..38e2a05 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_loader.h
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_loader.h
@@ -113,7 +113,6 @@
     uint32 number_pictures;
 
     vbp_picture_data_mp42 *picture_data;
-    uint32 frameSize; // fist frame size in buffer. Use for multiple frame in a buffer
 
 } vbp_data_mp42;
 
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c b/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c
index ccc0ab5..249a9f8 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c
@@ -632,13 +632,6 @@
 
 void vbp_on_vop_mp42(vbp_context *pcontext, int list_index)
 {
-    if(list_index == 0) {
-        // for the fist list item
-        viddec_pm_cxt_t *parent = pcontext->parser_cxt;
-        vbp_data_mp42 *query_data = (vbp_data_mp42 *) pcontext->query_data;
-        query_data->frameSize = parent->list.total_bytes; //record the first item frame size
-    }
-
     vbp_fill_codec_data(pcontext);
     vbp_fill_picture_param(pcontext, 1);
     vbp_fill_iq_matrix_buffer(pcontext);
diff --git a/videodecoder/VideoDecoderMPEG4.cpp b/videodecoder/VideoDecoderMPEG4.cpp
index 2ddc5ff..5499fbb 100644
--- a/videodecoder/VideoDecoderMPEG4.cpp
+++ b/videodecoder/VideoDecoderMPEG4.cpp
@@ -338,8 +338,17 @@
                     mExpectingNVOP = false;
                 }
                 if (useGraphicBuffer) {
-                    mPackedFrame.offSet = data->frameSize;
-                    VTRACE("Report OMX to handle for Multiple frame offset=%d time=%lld",data->frameSize,mPackedFrame.timestamp);
+                    int32_t count = i - 1;
+                    if (count < 0) {
+                        WTRACE("Shuld not be here!");
+                        return DECODE_SUCCESS;
+                    }
+                    vbp_picture_data_mp42 *lastpic = data->picture_data;
+                    for(int k = 0; k < count; k++ ) {
+                        lastpic = lastpic->next_picture_data;
+                    }
+                    mPackedFrame.offSet = lastpic->slice_data.slice_offset + lastpic->slice_data.slice_size;
+                    VTRACE("Report OMX to handle for Multiple frame offset=%d time=%lld",mPackedFrame.offSet,mPackedFrame.timestamp);
                     return DECODE_MULTIPLE_FRAME;
                 }
             }