media_module: mh264/h265/avs2 [1/2]

PD#SWPL-6607

Problem:
	Not support QOS information for mh264.h265,avs2

Solution:
	Support QOS information picking for mh264,h265,avs2
	Support QOS information access interface by ioctl

Verify:
	Verified franklin

Change-Id: I4e6f85392007bc78a274726aba510c39088018e3
Signed-off-by: Rong Zhang <rong.zhang@amlogic.com>
This commit is contained in:
Rong Zhang
2019-04-01 21:11:08 +08:00
committed by Tao Zeng
parent cca7d53392
commit 97e1613e7c
5 changed files with 102 additions and 17 deletions

View File

@@ -55,6 +55,7 @@ struct pts_rec_s {
struct list_head list;
u32 offset;
u32 val;
u32 size;
u64 pts_uS64;
} /*pts_rec_t */;
@@ -640,7 +641,7 @@ int get_last_checkout_pts(u8 type)
}
EXPORT_SYMBOL(get_last_checkout_pts);
int pts_lookup(u8 type, u32 *val, u32 pts_margin)
int pts_lookup(u8 type, u32 *val, u32 *frame_size, u32 pts_margin)
{
u32 page, offset;
@@ -648,18 +649,20 @@ int pts_lookup(u8 type, u32 *val, u32 pts_margin)
if (type == PTS_TYPE_VIDEO) {
offset = page * pts_table[PTS_TYPE_VIDEO].buf_size + offset;
pts_lookup_offset(PTS_TYPE_VIDEO, offset, val, pts_margin);
pts_lookup_offset(
PTS_TYPE_VIDEO, offset, val, frame_size, pts_margin);
return 0;
} else if (type == PTS_TYPE_AUDIO) {
offset = page * pts_table[PTS_TYPE_AUDIO].buf_size + offset;
pts_lookup_offset(PTS_TYPE_AUDIO, offset, val, pts_margin);
pts_lookup_offset(
PTS_TYPE_AUDIO, offset, val, frame_size, pts_margin);
return 0;
} else
return -EINVAL;
}
EXPORT_SYMBOL(pts_lookup);
static int pts_lookup_offset_inline_locked(u8 type, u32 offset, u32 *val,
u32 pts_margin, u64 *uS64)
u32 *frame_size, u32 pts_margin, u64 *uS64)
{
struct pts_table_s *pTable;
int lookup_threshold;
@@ -777,6 +780,9 @@ static int pts_lookup_offset_inline_locked(u8 type, u32 offset, u32 *val,
} else
p2 = p;
if (type == PTS_TYPE_VIDEO)
*frame_size = p->size;
if ((p2) &&
(OFFSET_DIFF(offset, p2->offset) < lookup_threshold)) {
if (p2->val == 0) /* FFT: set valid vpts */
@@ -788,8 +794,9 @@ static int pts_lookup_offset_inline_locked(u8 type, u32 offset, u32 *val,
("vpts look up offset<0x%x> -->",
offset);
pr_info
("<0x%x:0x%x>, look_cnt = %d\n",
p2->offset, p2->val, look_cnt);
("<0x%x:0x%x>, fsize %x, look_cnt = %d\n",
p2->offset, p2->val,
p2->size, look_cnt);
}
if (tsync_get_debug_apts()
@@ -805,6 +812,7 @@ static int pts_lookup_offset_inline_locked(u8 type, u32 offset, u32 *val,
}
*val = p2->val;
*uS64 = p2->pts_uS64;
*frame_size = p2->size;
#ifdef CALC_CACHED_TIME
pTable->last_checkout_pts = p2->val;
@@ -1130,14 +1138,15 @@ static int pts_pick_by_offset_inline_locked(u8 type, u32 offset, u32 *val,
static int pts_lookup_offset_inline(u8 type, u32 offset, u32 *val,
u32 pts_margin, u64 *uS64)
u32 *frame_size, u32 pts_margin, u64 *uS64)
{
unsigned long flags;
int res;
spin_lock_irqsave(&lock, flags);
res = pts_lookup_offset_inline_locked(
type, offset, val, pts_margin, uS64);
type, offset, val,
frame_size, pts_margin, uS64);
#if 0
if (timestamp_firstvpts_get() == 0 && res == 0 && (*val) != 0
@@ -1175,18 +1184,21 @@ static int pts_pick_by_offset_inline(u8 type, u32 offset, u32 *val,
}
int pts_lookup_offset(u8 type, u32 offset, u32 *val, u32 pts_margin)
int pts_lookup_offset(u8 type, u32 offset, u32 *val,
u32 *frame_size, u32 pts_margin)
{
u64 pts_us;
return pts_lookup_offset_inline(type, offset, val, pts_margin, &pts_us);
return pts_lookup_offset_inline(type, offset, val,
frame_size, pts_margin, &pts_us);
}
EXPORT_SYMBOL(pts_lookup_offset);
int pts_lookup_offset_us64(u8 type, u32 offset, u32 *val, u32 pts_margin,
u64 *uS64)
int pts_lookup_offset_us64(u8 type, u32 offset, u32 *val,
u32 *frame_size, u32 pts_margin, u64 *uS64)
{
return pts_lookup_offset_inline(type, offset, val, pts_margin, uS64);
return pts_lookup_offset_inline(type, offset, val,
frame_size, pts_margin, uS64);
}
EXPORT_SYMBOL(pts_lookup_offset_us64);

View File

@@ -2003,8 +2003,10 @@ static ssize_t show_startsync_mode(struct class *class,
static ssize_t show_apts_lookup(struct class *class,
struct class_attribute *attrr, char *buf)
{
u32 frame_size;
unsigned int pts = 0xffffffff;
pts_lookup_offset(PTS_TYPE_AUDIO, apts_lookup_offset, &pts, 300);
pts_lookup_offset(PTS_TYPE_AUDIO, apts_lookup_offset,
&pts, &frame_size, 300);
return sprintf(buf, "0x%x\n", pts);
}

View File

@@ -43,12 +43,13 @@ extern int get_last_checkin_pts(u8 type);
extern int get_last_checkout_pts(u8 type);
extern int pts_lookup(u8 type, u32 *val, u32 pts_margin);
extern int pts_lookup(u8 type, u32 *val, u32 *frame_size, u32 pts_margin);
extern int pts_lookup_offset(u8 type, u32 offset, u32 *val, u32 pts_margin);
extern int pts_lookup_offset(u8 type, u32 offset, u32 *val,
u32 *frame_size, u32 pts_margin);
extern int pts_lookup_offset_us64(u8 type, u32 offset, u32 *val,
u32 pts_margin, u64 *uS64);
u32 *frame_size, u32 pts_margin, u64 *uS64);
extern int pts_pickout_offset_us64(u8 type, u32 offset,
u32 *val, u32 pts_margin,

View File

@@ -357,6 +357,14 @@
#define HEVC_IQIT_STAT_GEN0 0x3708
#define HEVC_QP_WRITE 0x3709
#define HEVC_IQIT_STAT_GEN1 0x370a
#define HEVC_IQIT_BITDEPTH 0x370b
#define HEVC_IQIT_STAT_GEN2 0x370c
#define HEVC_IQIT_AVS2_WQP_0123 0x370d
#define HEVC_IQIT_AVS2_WQP_45 0x370e
#define HEVC_IQIT_AVS2_QP_DELTA 0x370f
#define HEVC_PIC_QUALITY_CTRL 0x3710
#define HEVC_PIC_QUALITY_DATA 0x3711
/**/
/*add from M8M2*/

View File

@@ -221,6 +221,9 @@
#define AMSTREAM_IOC_SET_EX _IOW((_A_M), 0xc4, struct am_ioctl_parm_ex)
#define AMSTREAM_IOC_GET_PTR _IOWR((_A_M), 0xc5, struct am_ioctl_parm_ptr)
#define AMSTREAM_IOC_SET_PTR _IOW((_A_M), 0xc6, struct am_ioctl_parm_ptr)
#define AMSTREAM_IOC_GET_AVINFO _IOR((_A_M), 0xc7, struct av_param_info_t)
#define AMSTREAM_IOC_GET_QOSINFO _IOR((_A_M), 0xc8, struct av_param_qosinfo_t)
#define TRICKMODE_NONE 0x00
#define TRICKMODE_I 0x01
@@ -682,6 +685,65 @@ struct am_ioctl_parm_ptr {
u32 len; /*char reserved[4]; */
};
struct vframe_qos_s {
int num;
int type;
int size;
int pts;
int max_qp;
int avg_qp;
int min_qp;
int max_skip;
int avg_skip;
int min_skip;
int max_mv;
int min_mv;
int avg_mv;
int decode_buffer;
} /*vframe_qos */;
enum FRAME_FORMAT {
FRAME_FORMAT_UNKNOWN,
FRAME_FORMAT_PROGRESS,
FRAME_FORMAT_INTERLACE,
};
#define QOS_FRAME_NUM 60
struct av_info_t {
/*auido info*/
int sample_rate;
int channels;
int aformat_type;
unsigned int apts;
unsigned int apts_err;
/*video info*/
unsigned int width;
unsigned int height;
unsigned int dec_error_count;
unsigned int first_pic_coming;
unsigned int fps;
unsigned int current_fps;
unsigned int vpts;
unsigned int vpts_err;
unsigned int ts_error;
unsigned int first_vpts;
int vformat_type;
enum FRAME_FORMAT frame_format;
unsigned int toggle_frame_count;/*toggle frame count*/
unsigned int dec_err_frame_count;/*vdec error frame count*/
unsigned int dec_frame_count;/*vdec frame count*/
unsigned int dec_drop_frame_count;/*drop frame num*/
int tsync_mode;
};
struct av_param_info_t {
struct av_info_t av_info;
};
struct av_param_qosinfo_t {
struct vframe_qos_s vframe_qos[QOS_FRAME_NUM];
};
#define SUPPORT_VDEC_NUM (20)
int vcodec_profile_register(const struct codec_profile_t *vdec_profile);
ssize_t vcodec_profile_read(char *buf);