media_module: can't get the correct width and height information [1/1]
authorPeng Yixin <yixin.peng@amlogic.com>
Mon, 11 Jan 2021 02:12:56 +0000 (10:12 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Mon, 18 Jan 2021 11:57:15 +0000 (03:57 -0800)
PD#SWPL-40808

Problem:
When the width and height of the file exceed
the decoding limit, the user layer cannot
read the width and height information correctly.

Solution:
Transmit the width and height information from
the header to solve this issue.

Verify:
AM311

Signed-off-by: Peng Yixin <yixin.peng@amlogic.com>
Change-Id: I036eaa410eeff7391cd571a4e08ee201884e4e83

drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/h265/vh265.c
drivers/frame_provider/decoder/vp9/vvp9.c

index 53894057a263c4651ec920275e729439fbbfce7d..b019a3830d853cf02b0e473eb672ad2a68eafdb6 100644 (file)
@@ -931,6 +931,8 @@ struct vdec_h264_hw_s {
        u32 start_bit_cnt;
        u32 right_frame_count;
        u32 wrong_frame_count;
+       u32 error_frame_width;
+       u32 error_frame_height;
 };
 
 static u32 again_threshold;
@@ -5041,8 +5043,12 @@ static int vh264_set_params(struct vdec_h264_hw_s *hw,
                        seq_info2,
                        mb_width,
                        mb_height);
+                       hw->error_frame_width = mb_width << 4;
+                       hw->error_frame_height = mb_height << 4;
                return -1;
        }
+       hw->error_frame_width = 0;
+       hw->error_frame_height = 0;
 
        if (seq_info2 != 0 &&
                hw->seq_info2 != (seq_info2 & (~0x80000000)) &&
@@ -7443,6 +7449,11 @@ static int dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
 
        vstatus->frame_width = hw->frame_width;
        vstatus->frame_height = hw->frame_height;
+       if (hw->error_frame_width &&
+               hw->error_frame_height) {
+               vstatus->frame_width = hw->error_frame_width;
+               vstatus->frame_height = hw->error_frame_height;
+       }
        if (hw->frame_dur != 0) {
                vstatus->frame_dur = hw->frame_dur;
                vstatus->frame_rate = ((96000 * 10 / hw->frame_dur) % 10) < 5 ?
@@ -8740,8 +8751,12 @@ static int vmh264_get_ps_info(struct vdec_h264_hw_s *hw,
                        param1,
                        mb_width,
                        mb_height);
+               hw->error_frame_width = mb_width << 4;
+               hw->error_frame_height = mb_height << 4;
                return -1;
        }
+       hw->error_frame_width = 0;
+       hw->error_frame_height = 0;
 
        reorder_pic_num =
                get_max_dec_frame_buf_size(level_idc,
index 2c6a35e86f7f40eec7bfd90e84df91ae1bb8649b..857a8c1dfdd7a917b52fe31d3f3d0c4d62a4e9dc 100644 (file)
@@ -11808,10 +11808,10 @@ int vh265_dec_status(struct vdec_info *vstatus)
        if (!hevc)
                return -1;
 
-       vstatus->frame_width = hevc->frame_width;
+       vstatus->frame_width = hevc->pic_w;
        /* for hevc interlace for disp height x2 */
        vstatus->frame_height =
-               (hevc->frame_height << hevc->interlace_flag);
+               (hevc->pic_h << hevc->interlace_flag);
        if (hevc->frame_dur != 0)
                vstatus->frame_rate = ((96000 * 10 / hevc->frame_dur) % 10) < 5 ?
                                96000 / hevc->frame_dur : (96000 / hevc->frame_dur +1);
index d9a64c2d837c257aab0d49d91f6577a176d591f4..5d59c42f62e31356554a7ca5ed3517a01fdf9913 100644 (file)
@@ -1226,6 +1226,8 @@ struct VP9Decoder_s {
        u64 frame_mode_pts64_save[FRAME_BUFFERS];
        int run_ready_min_buf_num;
        int one_package_frame_cnt;
+       u32 error_frame_width;
+       u32 error_frame_height;
 };
 
 static int vp9_print(struct VP9Decoder_s *pbi,
@@ -1322,9 +1324,13 @@ static int setup_frame_size(
        width = params->p.width;
        height = params->p.height;
        if (is_oversize(width, height)) {
+               pbi->error_frame_width = width;
+               pbi->error_frame_height = height;
                vp9_print(pbi, 0, "%s, Error: Invalid frame size\n", __func__);
                return -1;
        }
+       pbi->error_frame_width = 0;
+       pbi->error_frame_height = 0;
 
        /*vp9_read_frame_size(rb, &width, &height);*/
        if (print_header_info)
@@ -1449,9 +1455,13 @@ static int setup_frame_size_with_refs(
        }
 
        if (is_oversize(width, height)) {
+               pbi->error_frame_width = width;
+               pbi->error_frame_height = height;
                vp9_print(pbi, 0, "%s, Error: Invalid frame size\n", __func__);
                return -1;
        }
+       pbi->error_frame_width = 0;
+       pbi->error_frame_height = 0;
 
        params->p.width = width;
        params->p.height = height;
@@ -9084,6 +9094,12 @@ int vvp9_dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
 
        vstatus->frame_width = frame_width;
        vstatus->frame_height = frame_height;
+       if (vp9->error_frame_width &&
+               vp9->error_frame_height) {
+               vstatus->frame_width = vp9->error_frame_width;
+               vstatus->frame_height = vp9->error_frame_height;
+       }
+
        if (vp9->frame_dur != 0)
                vstatus->frame_rate = ((96000 * 10 / vp9->frame_dur) % 10) < 5 ?
                                96000 / vp9->frame_dur : (96000 / vp9->frame_dur +1);