demux: improve section not completed process [1/1]

PD#SWPL-120523

Problem:
section handle slowly

Solution:
don't use cache, rewind read rp

Verify:
verified at sdmc project

Change-Id: I18b49bc7fd8d9be2b1193f616256b4075081dd58
Signed-off-by: chuangcheng peng <chuangcheng.peng@amlogic.com>
This commit is contained in:
chuangcheng peng
2023-04-20 16:36:14 +08:00
committed by gerrit autosubmit
parent 2ed9860c27
commit 25f511eea8
3 changed files with 49 additions and 79 deletions
+17
View File
@@ -1176,6 +1176,23 @@ int SC2_bufferid_read(struct chan_id *pchan, char **pread, unsigned int len,
return 0;
}
/**
* SC2_bufferid_move_read_rp
* \param pchan:struct chan_id handle
* \param len:length
* \param flag: 0:rewind; 1:forward
* \retval 0:success.
* \retval -1:fail.
*/
int SC2_bufferid_move_read_rp(struct chan_id *pchan, unsigned int len, int flag)
{
if (flag == 0)
pchan->r_offset = (pchan->r_offset + pchan->mem_size - len) % pchan->mem_size;
else
pchan->r_offset = (pchan->r_offset + len) % pchan->mem_size;
return 0;
}
static int check_data_pack_align(char *mem, int len, struct aml_dmx *pdmx)
{
int left = len;
+9
View File
@@ -155,6 +155,15 @@ unsigned int SC2_bufferid_get_wp_offset(struct chan_id *pchan);
unsigned int SC2_bufferid_get_data_len(struct chan_id *pchan);
int SC2_bufferid_read_header_again(struct chan_id *pchan, char **pread);
int SC2_bufferid_read_newest_pts(struct chan_id *pchan, char **pread);
/**
* SC2_bufferid_move_read_rp
* \param pchan:struct chan_id handle
* \param len:length
* \param flag: 0:rewind; 1:forward
* \retval 0:success.
* \retval -1:fail.
*/
int SC2_bufferid_move_read_rp(struct chan_id *pchan, unsigned int len, int flag);
int SC2_add_dump_cb(struct list_head *node, dmx_dump_cb cb);
int _alloc_buff(unsigned int len, int sec_level,
+23 -79
View File
@@ -119,9 +119,6 @@ struct out_elem {
struct chan_id *pchan1;
struct pid_entry *pcrpid_list;
char *cache;
u16 cache_len;
u16 remain_len;
struct cb_entry *cb_sec_list;
struct cb_entry *cb_ts_list;
u16 flush_time_ms;
@@ -474,72 +471,35 @@ static int section_process(struct out_elem *pout)
int ret = 0;
int len = 0, w_size;
char *pread;
int remain_len = 0;
if (pout->pchan->sec_level)
start_aucpu_non_es(pout);
if (pout->remain_len == 0) {
len = MAX_READ_BUF_LEN;
if (pout->pchan->sec_level)
ret = aucpu_bufferid_read(pout, &pread, len, 0);
else
ret = SC2_bufferid_read(pout->pchan, &pread, len, 0);
if (ret != 0) {
if (pout->cb_sec_list) {
w_size = out_sec_cb_list(pout, pread, ret);
ATRACE_COUNTER(pout->name, w_size);
pr_sec_dbg("%s send:%d, w:%d\n", __func__,
ret, w_size);
pout->remain_len = ret - w_size;
if (dump_other_cb)
dump_other_cb(pout->sid, pout->es_pes->pid,
DMX_DUMP_SECTION_TYPE, pread, w_size,
&dump_other_head);
if (pout->remain_len) {
if (pout->remain_len >=
READ_CACHE_SIZE) {
dprint("len:%d lost data\n",
pout->remain_len);
pout->remain_len = 0;
} else {
memcpy(pout->cache,
pread + w_size,
pout->remain_len);
}
}
len = MAX_READ_BUF_LEN;
if (pout->pchan->sec_level)
ret = aucpu_bufferid_read(pout, &pread, len, 0);
else
ret = SC2_bufferid_read(pout->pchan, &pread, len, 0);
if (ret != 0) {
if (pout->cb_sec_list) {
w_size = out_sec_cb_list(pout, pread, ret);
ATRACE_COUNTER(pout->name, w_size);
pr_sec_dbg("%s send:%d, w:%d wwwwww\n", __func__,
ret, w_size);
remain_len = ret - w_size;
if (remain_len) {
if (pout->pchan->sec_level)
pout->aucpu_read_offset =
(pout->aucpu_read_offset +
pout->aucpu_mem_size - remain_len)
% pout->aucpu_mem_size;
else
SC2_bufferid_move_read_rp(pout->pchan, remain_len, 0);
}
if (pout->cb_ts_list)
out_ts_cb_list(pout, pread, ret, 0, 0);
}
} else {
len = READ_CACHE_SIZE - pout->remain_len;
if (pout->pchan->sec_level)
ret = aucpu_bufferid_read(pout, &pread, len, 0);
else
ret = SC2_bufferid_read(pout->pchan, &pread, len, 0);
if (ret != 0) {
memcpy(pout->cache + pout->remain_len, pread, ret);
pout->remain_len += ret;
if (ret == len) {
ret = pout->remain_len;
w_size =
out_sec_cb_list(pout, pout->cache, ret);
ATRACE_COUNTER(pout->name, w_size);
pr_sec_dbg("%s send:%d, w:%d\n", __func__, ret,
w_size);
if (dump_other_cb)
dump_other_cb(pout->sid, pout->es_pes->pid,
DMX_DUMP_SECTION_TYPE, pout->cache,
w_size, &dump_other_head);
pout->remain_len = ret - w_size;
if (pout->remain_len)
memmove(pout->cache,
pout->cache + w_size,
pout->remain_len);
}
if (pout->cb_ts_list)
out_ts_cb_list(pout, pread, ret, 0, 0);
}
if (pout->cb_ts_list)
out_ts_cb_list(pout, pread, ret, 0, 0);
}
return 0;
}
@@ -2329,9 +2289,6 @@ struct out_elem *ts_output_open(int sid, u8 dmx_id, u8 format,
return NULL;
}
pout->enable = 0;
pout->remain_len = 0;
pout->cache_len = 0;
pout->cache = NULL;
pout->aucpu_handle = -1;
pout->aucpu_start = 0;
pout->aucpu_pts_handle = -1;
@@ -2353,21 +2310,12 @@ struct out_elem *ts_output_open(int sid, u8 dmx_id, u8 format,
pout->aucpu_pts_handle = -1;
pout->aucpu_pts_start = 0;
pout->enable = 0;
pout->remain_len = 0;
pout->cache_len = READ_CACHE_SIZE;
pout->cache = kmalloc(pout->cache_len, GFP_KERNEL);
if (!pout->cache) {
SC2_bufferid_dealloc(pout->pchan);
dprint("%s sid:%d kmalloc cache fail\n", __func__, sid);
return NULL;
}
}
ts_out_tmp = kmalloc(sizeof(*ts_out_tmp), GFP_KERNEL);
if (!ts_out_tmp) {
dprint("ts out list fail\n");
SC2_bufferid_dealloc(pout->pchan);
kfree(pout->cache);
return NULL;
}
@@ -2377,7 +2325,6 @@ struct out_elem *ts_output_open(int sid, u8 dmx_id, u8 format,
if (!ts_out_tmp->es_params) {
dprint("ts out es_params fail\n");
SC2_bufferid_dealloc(pout->pchan);
kfree(pout->cache);
kfree(ts_out_tmp);
return NULL;
}
@@ -2428,7 +2375,6 @@ int ts_output_close(struct out_elem *pout)
mutex_destroy(&pout->pts_mutex);
} else {
remove_ts_out_list(pout, &ts_out_task_tmp);
kfree(pout->cache);
}
if (pout->aucpu_handle >= 0) {
@@ -3101,8 +3047,6 @@ int ts_output_remove_cb(struct out_elem *pout, ts_output_cb cb, void *udata,
pre_cb = tmp_cb;
tmp_cb = tmp_cb->next;
}
if (!pout->cb_sec_list)
pout->remain_len = 0;
} else {
if (pout->type == VIDEO_TYPE || pout->type == AUDIO_TYPE)
mutex_lock(&es_output_mutex);