Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/arib_std_b25.c Sun Oct 21 19:38:02 2012 +0900
- +++ b/arib_std_b25.c Wed Sep 10 06:15:32 2014 +0900
- @@ -25,12 +25,12 @@
- } TS_STREAM_LIST;
- typedef struct {
- -
- +
- uint8_t *pool;
- uint8_t *head;
- uint8_t *tail;
- int32_t max;
- -
- +
- } TS_WORK_BUFFER;
- typedef struct {
- @@ -88,7 +88,7 @@
- int32_t multi2_round;
- int32_t strip;
- int32_t emm_proc_on;
- -
- +
- int32_t unit_size;
- int32_t sbuf_offset;
- @@ -97,7 +97,7 @@
- TS_SECTION_PARSER *cat;
- TS_STREAM_LIST strm_pool;
- -
- +
- int32_t p_count;
- TS_PROGRAM *program;
- @@ -114,7 +114,7 @@
- TS_WORK_BUFFER sbuf;
- TS_WORK_BUFFER dbuf;
- -
- +
- } ARIB_STD_B25_PRIVATE_DATA;
- typedef struct {
- @@ -329,13 +329,13 @@
- ARIB_STD_B25 *create_arib_std_b25()
- {
- int n;
- -
- +
- ARIB_STD_B25 *r;
- ARIB_STD_B25_PRIVATE_DATA *prv;
- n = sizeof(ARIB_STD_B25_PRIVATE_DATA);
- n += sizeof(ARIB_STD_B25);
- -
- +
- prv = (ARIB_STD_B25_PRIVATE_DATA *)calloc(1, n);
- if(prv == NULL){
- return NULL;
- @@ -558,51 +558,55 @@
- r = 0;
- - while( (curr+188) <= tail ){
- -
- + while( (curr+unit) <= tail ){
- +
- if(curr[0] != 0x47){
- p = resync_force(curr, tail, unit);
- if(p == NULL){
- + curr = tail;
- goto LAST;
- }
- curr = p;
- }
- -
- +
- extract_ts_header(&hdr, curr);
- crypt = hdr.transport_scrambling_control;
- pid = hdr.pid;
- if(hdr.transport_error_indicator != 0){
- /* bit error - append output buffer without parsing */
- - if(!append_work_buffer(&(prv->dbuf), curr, 188)){
- + if(!append_work_buffer(&(prv->dbuf), curr, unit)){
- r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- goto NEXT;
- }
- -
- +
- if( (pid == 0x1fff) && (prv->strip) ){
- + /* strip null(padding) stream */
- goto NEXT;
- }
- -
- +
- p = curr+4;
- if(hdr.adaptation_field_control & 0x02){
- p += (p[0]+1);
- - }
- - n = 188 - (p-curr);
- - if( (n < 1) && ((n < 0) || (hdr.adaptation_field_control & 0x01)) ){
- - /* broken packet */
- - curr += 1;
- - continue;
- + n = unit - (p-curr);
- + if( (n < 1) && ((n < 0) || (hdr.adaptation_field_control & 0x01)) ){
- + /* broken packet */
- + curr += 1;
- + continue;
- + }
- + }else{
- + n = unit - 4;
- }
- if( (crypt != 0) &&
- (hdr.adaptation_field_control & 0x01) ){
- -
- +
- if(prv->map[pid].type == PID_MAP_TYPE_OTHER){
- dec = (DECRYPTOR_ELEM *)(prv->map[pid].target);
- }else if( (prv->map[pid].type == 0) &&
- - (prv->decrypt.count == 1) ){
- + (prv->decrypt.count == 1) ){
- dec = prv->decrypt.head;
- }else{
- dec = NULL;
- @@ -612,6 +616,7 @@
- m = dec->m2->decrypt(dec->m2, crypt, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_DECRYPT_FAILURE;
- + curr += unit;
- goto LAST;
- }
- curr[3] &= 0x3f;
- @@ -623,7 +628,7 @@
- prv->map[pid].normal_packet += 1;
- }
- - if(!append_work_buffer(&(prv->dbuf), curr, 188)){
- + if(!append_work_buffer(&(prv->dbuf), curr, unit)){
- r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- @@ -633,16 +638,19 @@
- if( (dec == NULL) || (dec->ecm == NULL) ){
- /* this code will never execute */
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = dec->ecm->put(dec->ecm, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = dec->ecm->get_count(dec->ecm);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -650,6 +658,7 @@
- }
- r = proc_ecm(dec, prv->bcas, prv->multi2_round);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(prv->map[pid].type == PID_MAP_TYPE_PMT){
- @@ -657,16 +666,19 @@
- if( (pgrm == NULL) || (pgrm->pmt == NULL) ){
- /* this code will never execute */
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = pgrm->pmt->put(pgrm->pmt, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = pgrm->pmt->get_count(pgrm->pmt);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -674,6 +686,7 @@
- }
- r = proc_pmt(prv, pgrm);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(prv->map[pid].type == PID_MAP_TYPE_EMM){
- @@ -683,18 +696,20 @@
- if( prv->emm == NULL ){
- prv->emm = create_ts_section_parser();
- if(prv->emm == NULL){
- - r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- + r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- }
- m = prv->emm->put(prv->emm, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = prv->emm->get_count(prv->emm);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -702,6 +717,7 @@
- }
- r = proc_emm(prv);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(pid == 0x0001){
- @@ -715,11 +731,13 @@
- m = prv->cat->put(prv->cat, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = prv->cat->get_count(prv->cat);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -727,6 +745,7 @@
- }
- r = proc_cat(prv);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(pid == 0x0000){
- @@ -740,11 +759,13 @@
- m = prv->pat->put(prv->pat, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = prv->pat->get_count(prv->pat);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -752,21 +773,22 @@
- }
- r = proc_pat(prv);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }
- -
- +
- NEXT:
- curr += unit;
- }
- LAST:
- -
- - m = curr - prv->sbuf.head;
- + m = curr - prv->sbuf.pool;
- n = tail - curr;
- if( (n < 1024) || (m > (prv->sbuf.max/2) ) ){
- p = prv->sbuf.pool;
- - memcpy(p, curr, n);
- + if(n > 0)
- + memcpy(p, curr, n);
- prv->sbuf.head = p;
- prv->sbuf.tail = p+n;
- }else{
- @@ -779,7 +801,7 @@
- static int put_arib_std_b25(void *std_b25, ARIB_STD_B25_BUFFER *buf)
- {
- int32_t n;
- -
- +
- ARIB_STD_B25_PRIVATE_DATA *prv;
- prv = private_data(std_b25);
- @@ -875,7 +897,7 @@
- static int get_program_count_arib_std_b25(void *std_b25)
- {
- ARIB_STD_B25_PRIVATE_DATA *prv;
- -
- +
- prv = private_data(std_b25);
- if(prv == NULL){
- return ARIB_STD_B25_ERROR_INVALID_PARAM;
- @@ -889,12 +911,12 @@
- ARIB_STD_B25_PRIVATE_DATA *prv;
- TS_PROGRAM *pgrm;
- -
- +
- TS_STREAM_ELEM *strm;
- DECRYPTOR_ELEM *dec;
- int32_t pid;
- -
- +
- prv = private_data(std_b25);
- if( (prv == NULL) || (info == NULL) || (idx < 0) || (idx >= prv->p_count) ){
- return ARIB_STD_B25_ERROR_INVALID_PARAM;
- @@ -905,7 +927,7 @@
- memset(info, 0, sizeof(ARIB_STD_B25_PROGRAM_INFO));
- info->program_number = pgrm->program_number;
- -
- +
- pid = pgrm->pmt_pid;
- info->total_packet_count += prv->map[pid].normal_packet;
- info->total_packet_count += prv->map[pid].undecrypted;
- @@ -953,13 +975,13 @@
- return NULL;
- }
- - return r;
- + return r;
- }
- static void teardown(ARIB_STD_B25_PRIVATE_DATA *prv)
- {
- int i;
- -
- +
- prv->unit_size = 0;
- prv->sbuf_offset = 0;
- @@ -1011,7 +1033,7 @@
- head = prv->sbuf.head;
- tail = prv->sbuf.tail;
- -
- +
- buf = head;
- memset(count, 0, sizeof(count));
- @@ -1058,7 +1080,7 @@
- {
- int r;
- int n,size;
- -
- +
- int32_t unit;
- uint8_t *p;
- @@ -1073,32 +1095,36 @@
- tail = prv->sbuf.tail;
- while( (curr+unit) < tail ){
- +
- if( (curr[0] != 0x47) || (curr[unit] != 0x47) ){
- p = resync(curr, tail, unit);
- if(p == NULL){
- + curr = tail;
- goto LAST;
- }
- curr = p;
- }
- +
- extract_ts_header(&hdr, curr);
- +
- if(hdr.pid == 0x0000){
- -
- p = curr+4;
- if(hdr.adaptation_field_control & 0x02){
- p += (p[0]+1);
- + size = unit - (p-curr);
- + if(size < 1){
- + goto NEXT;
- + }
- + }else{
- + size = unit - 4;
- }
- - size = 188 - (p-curr);
- - if(size < 1){
- - goto NEXT;
- - }
- -
- if(prv->pat == NULL){
- prv->pat = create_ts_section_parser();
- if(prv->pat == NULL){
- return ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- }
- }
- -
- +
- n = prv->pat->put(prv->pat, &hdr, p, size);
- if(n < 0){
- r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- @@ -1136,13 +1162,13 @@
- int i,n;
- int len;
- int count;
- -
- +
- int32_t program_number;
- int32_t pid;
- uint8_t *head;
- uint8_t *tail;
- -
- +
- TS_PROGRAM *work;
- TS_SECTION sect;
- @@ -1168,7 +1194,7 @@
- r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- -
- +
- if(prv->program != NULL){
- for(i=0;i<prv->p_count;i++){
- release_program(prv, prv->program+i);
- @@ -1203,7 +1229,7 @@
- prv->program = work;
- prv->p_count = i;
- -
- +
- prv->map[0x0000].ref = 1;
- prv->map[0x0000].type = PID_MAP_TYPE_PAT;
- prv->map[0x0000].target = NULL;
- @@ -1251,7 +1277,7 @@
- {
- int r;
- int n,size;
- -
- +
- int32_t unit;
- uint8_t *p;
- @@ -1267,17 +1293,57 @@
- tail = prv->sbuf.tail;
- while( (curr+unit) < tail ){
- -
- +
- if( (curr[0] != 0x47) || (curr[unit] != 0x47) ){
- p = resync(curr, tail, unit);
- if(p == NULL){
- + curr = tail;
- goto LAST;
- }
- curr = p;
- }
- -
- +
- extract_ts_header(&hdr, curr);
- -
- +
- + if(hdr.pid == 0x0000){
- + p = curr+4;
- + if(hdr.adaptation_field_control & 0x02){
- + p += (p[0]+1);
- + size = unit - (p-curr);
- + if(size < 1){
- + goto NEXT;
- + }
- + }else{
- + size = unit - 4;
- + }
- + if(prv->pat == NULL){
- + prv->pat = create_ts_section_parser();
- + if(prv->pat == NULL){
- + r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- + goto LAST;
- + }
- + }
- + n = prv->pat->put(prv->pat, &hdr, p, size);
- + if(n < 0){
- + r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- + goto LAST;
- + }
- + n = prv->pat->get_count(prv->pat);
- + if(n < 0){
- + r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- + goto LAST;
- + }
- + if(n == 0){
- + goto NEXT;
- + }
- + r = proc_pat(prv);
- + prv->sbuf.head = curr;
- + curr += unit;
- + goto LAST;
- + }
- +
- if(prv->map[hdr.pid].type != PID_MAP_TYPE_PMT){
- goto NEXT;
- }
- @@ -1285,25 +1351,27 @@
- if(pgrm == NULL){
- goto NEXT;
- }
- -
- +
- if(pgrm->phase == 0){
- -
- +
- p = curr + 4;
- if(hdr.adaptation_field_control & 0x02){
- p += (p[0]+1);
- + size = unit - (p-curr);
- + if(size < 1){
- + goto NEXT;
- + }
- + }else{
- + size = unit - 4;
- }
- - size = 188 - (p-curr);
- - if(size < 1){
- - goto NEXT;
- - }
- -
- +
- if(pgrm->pmt == NULL){
- /* this code will never execute */
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- curr += unit;
- goto LAST;
- }
- -
- +
- n = pgrm->pmt->put(pgrm->pmt, &hdr, p, size);
- if(n < 0){
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- @@ -1338,7 +1406,7 @@
- curr += unit;
- goto LAST;
- }
- -
- +
- NEXT:
- curr += unit;
- }
- @@ -1364,10 +1432,10 @@
- int32_t type;
- TS_SECTION sect;
- -
- +
- DECRYPTOR_ELEM *dec[2];
- DECRYPTOR_ELEM *dw;
- -
- +
- TS_STREAM_ELEM *strm;
- r = 0;
- @@ -1383,7 +1451,7 @@
- r = ARIB_STD_B25_WARN_TS_SECTION_ID_MISSMATCH;
- goto LAST;
- }
- -
- +
- head = sect.data;
- tail = sect.tail-4;
- @@ -1412,7 +1480,6 @@
- }
- head += length;
- -
- /* unref old stream entries */
- while( (strm = get_stream_list_head(&(pgrm->old_strm))) != NULL ){
- unref_stream(prv, strm->pid);
- @@ -1440,7 +1507,7 @@
- head += 5;
- ecm_pid = find_ca_descriptor_pid(head, head+length, prv->ca_system_id);
- head += length;
- -
- +
- if( (ecm_pid != 0) && (ecm_pid != 0x1fff) ){
- dec[1] = set_decryptor(prv, ecm_pid);
- if(dec[1] == NULL){
- @@ -1466,16 +1533,16 @@
- strm->pid = pid;
- strm->type = type;
- }
- -
- +
- prv->map[pid].type = PID_MAP_TYPE_OTHER;
- prv->map[pid].ref += 1;
- dw = select_active_decryptor(dec[0], dec[1], ecm_pid);
- bind_stream_decryptor(prv, pid, dw);
- -
- +
- put_stream_list_tail(&(pgrm->streams), strm);
- }
- -
- +
- LAST:
- if( dec[0] != NULL ){
- dec[0]->ref -= 1;
- @@ -1494,12 +1561,12 @@
- return r;
- }
- -
- +
- static int32_t find_ca_descriptor_pid(uint8_t *head, uint8_t *tail, int32_t ca_system_id)
- {
- uint32_t ca_pid;
- uint32_t ca_sys_id;
- -
- +
- uint32_t tag;
- uint32_t len;
- @@ -1602,11 +1669,52 @@
- if( (curr[0] != 0x47) || (curr[unit] != 0x47) ){
- p = resync(curr, tail, unit);
- if(p == NULL){
- + curr = tail;
- goto LAST;
- }
- curr = p;
- }
- extract_ts_header(&hdr, curr);
- +
- + if(hdr.pid == 0x0000){
- + p = curr+4;
- + if(hdr.adaptation_field_control & 0x02){
- + p += (p[0]+1);
- + size = unit - (p-curr);
- + if(size < 1){
- + goto NEXT;
- + }
- + }else{
- + size = unit - 4;
- + }
- + if(prv->pat == NULL){
- + prv->pat = create_ts_section_parser();
- + if(prv->pat == NULL){
- + r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- + goto LAST;
- + }
- + }
- + n = prv->pat->put(prv->pat, &hdr, p, size);
- + if(n < 0){
- + r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- + goto LAST;
- + }
- + n = prv->pat->get_count(prv->pat);
- + if(n < 0){
- + r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- + goto LAST;
- + }
- + if(n == 0){
- + goto NEXT;
- + }
- + r = proc_pat(prv);
- + prv->sbuf.head = curr;
- + curr += unit;
- + goto LAST;
- + }
- +
- if(prv->map[hdr.pid].type != PID_MAP_TYPE_ECM){
- goto NEXT;
- }
- @@ -1616,23 +1724,25 @@
- }
- if(dec->phase == 0){
- -
- +
- p = curr + 4;
- if(hdr.adaptation_field_control & 0x02){
- p += (p[0]+1);
- + size = unit - (p-curr);
- + if(size < 1){
- + goto NEXT;
- + }
- + }else{
- + size = unit - 4;
- }
- - size = 188 - (p-curr);
- - if(size < 1){
- - goto NEXT;
- - }
- -
- +
- if(dec->ecm == NULL){
- /* this code will never execute */
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- curr += unit;
- goto LAST;
- }
- -
- +
- n = dec->ecm->put(dec->ecm, &hdr, p, size);
- if(n < 0){
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- @@ -1658,7 +1768,7 @@
- /* broken or unexpected section data */
- goto NEXT;
- }
- -
- +
- dec->phase = 1;
- if(check_ecm_complete(prv)){
- curr += unit;
- @@ -1670,7 +1780,7 @@
- curr += unit;
- goto LAST;
- }
- -
- +
- NEXT:
- curr += unit;
- }
- @@ -1687,7 +1797,7 @@
- int length;
- uint8_t *p;
- -
- +
- B_CAS_INIT_STATUS is;
- B_CAS_ECM_RESULT res;
- @@ -1710,7 +1820,7 @@
- r = ARIB_STD_B25_WARN_TS_SECTION_ID_MISSMATCH;
- goto LAST;
- }
- -
- +
- if(dec->locked){
- /* previous ECM has returned unpurchased
- skip this pid for B-CAS card load reduction */
- @@ -1730,7 +1840,7 @@
- r = ARIB_STD_B25_ERROR_ECM_PROC_FAILURE;
- goto LAST;
- }
- -
- +
- if( (res.return_code != 0x0800) &&
- (res.return_code != 0x0400) &&
- (res.return_code != 0x0200) ){
- @@ -1777,7 +1887,7 @@
- fprintf(stdout, "\n");
- fflush(stdout);
- }
- -
- +
- LAST:
- if(sect.raw != NULL){
- n = dec->ecm->ret(dec->ecm, §);
- @@ -1785,7 +1895,7 @@
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- }
- }
- -
- +
- return r;
- }
- @@ -1793,10 +1903,10 @@
- {
- int32_t pts_dts_flag;
- int64_t pts,dts;
- -
- - src += 4; // TS ヘッダ部
- - src += 4; // start_code_prefix + stream_id 部
- - src += 2; // packet_length 部
- +
- + src += 4; // TS header
- + src += 4; // start_code_prefix + stream_id
- + src += 2; // packet_length
- pts_dts_flag = (src[1] >> 6) & 3;
- @@ -1820,7 +1930,7 @@
- }
- if(pts_dts_flag == 2){
- - fprintf(stdout, " key=%d, pts=%"PRId64"\n", crypt, pts/90);
- + fprintf(stdout, " key=%d, pts=%d\n", crypt, (int32_t)(pts/90));
- fflush(stdout);
- }
- }
- @@ -1855,28 +1965,29 @@
- r = 0;
- while( (curr+unit) < tail ){
- -
- +
- if( (curr[0] != 0x47) || (curr[unit] != 0x47) ){
- p = resync(curr, tail, unit);
- if(p == NULL){
- + curr = tail;
- goto LAST;
- }
- curr = p;
- }
- -
- +
- extract_ts_header(&hdr, curr);
- crypt = hdr.transport_scrambling_control;
- pid = hdr.pid;
- if(hdr.transport_error_indicator != 0){
- /* bit error - append output buffer without parsing */
- - if(!append_work_buffer(&(prv->dbuf), curr, 188)){
- + if(!append_work_buffer(&(prv->dbuf), curr, unit)){
- r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- goto NEXT;
- }
- -
- +
- if( (pid == 0x1fff) && (prv->strip) ){
- /* strip null(padding) stream */
- goto NEXT;
- @@ -1885,17 +1996,19 @@
- p = curr+4;
- if(hdr.adaptation_field_control & 0x02){
- p += (p[0]+1);
- - }
- - n = 188 - (p-curr);
- - if( (n < 1) && ((n < 0) || (hdr.adaptation_field_control & 0x01)) ){
- - /* broken packet */
- - curr += 1;
- - continue;
- + n = unit - (p-curr);
- + if( (n < 1) && ((n < 0) || (hdr.adaptation_field_control & 0x01)) ){
- + /* broken packet */
- + curr += 1;
- + continue;
- + }
- + }else{
- + n = unit - 4;
- }
- if( (crypt != 0) &&
- (hdr.adaptation_field_control & 0x01) ){
- -
- +
- if(prv->map[pid].type == PID_MAP_TYPE_OTHER){
- dec = (DECRYPTOR_ELEM *)(prv->map[pid].target);
- }else if( (prv->map[pid].type == 0) &&
- @@ -1909,6 +2022,7 @@
- m = dec->m2->decrypt(dec->m2, crypt, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_DECRYPT_FAILURE;
- + curr += unit;
- goto LAST;
- }
- curr[3] &= 0x3f;
- @@ -1924,7 +2038,7 @@
- dump_pts(curr, crypt);
- }
- #endif
- - if(!append_work_buffer(&(prv->dbuf), curr, 188)){
- + if(!append_work_buffer(&(prv->dbuf), curr, unit)){
- r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- @@ -1934,16 +2048,19 @@
- if( (dec == NULL) || (dec->ecm == NULL) ){
- /* this code will never execute */
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = dec->ecm->put(dec->ecm, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = dec->ecm->get_count(dec->ecm);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -1951,6 +2068,7 @@
- }
- r = proc_ecm(dec, prv->bcas, prv->multi2_round);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(prv->map[pid].type == PID_MAP_TYPE_PMT){
- @@ -1958,16 +2076,19 @@
- if( (pgrm == NULL) || (pgrm->pmt == NULL) ){
- /* this code will never execute */
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = pgrm->pmt->put(pgrm->pmt, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = pgrm->pmt->get_count(pgrm->pmt);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -1975,6 +2096,7 @@
- }
- r = proc_pmt(prv, pgrm);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(prv->map[pid].type == PID_MAP_TYPE_EMM){
- @@ -1984,18 +2106,20 @@
- if( prv->emm == NULL ){
- prv->emm = create_ts_section_parser();
- if(prv->emm == NULL){
- - r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- + r = ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY;
- goto LAST;
- }
- }
- m = prv->emm->put(prv->emm, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = prv->emm->get_count(prv->emm);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -2003,6 +2127,7 @@
- }
- r = proc_emm(prv);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(pid == 0x0001){
- @@ -2016,11 +2141,13 @@
- m = prv->cat->put(prv->cat, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = prv->cat->get_count(prv->cat);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- @@ -2028,6 +2155,7 @@
- }
- r = proc_cat(prv);
- if(r < 0){
- + curr += unit;
- goto LAST;
- }
- }else if(pid == 0x0000){
- @@ -2041,26 +2169,29 @@
- m = prv->pat->put(prv->pat, &hdr, p, n);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- m = prv->pat->get_count(prv->pat);
- if(m < 0){
- r = ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE;
- + curr += unit;
- goto LAST;
- }
- if(m == 0){
- goto NEXT;
- }
- r = proc_pat(prv);
- + curr += unit;
- goto LAST;
- }
- -
- +
- NEXT:
- curr += unit;
- }
- LAST:
- - m = curr - prv->sbuf.head;
- + m = curr - prv->sbuf.pool;
- n = tail - curr;
- if( (n < 1024) || (m > (prv->sbuf.max/2) ) ){
- p = prv->sbuf.pool;
- @@ -2112,7 +2243,7 @@
- prv->map[emm_pid].type = PID_MAP_TYPE_EMM;
- prv->map[emm_pid].target = NULL;
- }
- -
- +
- prv->map[0x0001].ref = 1;
- prv->map[0x0001].type = PID_MAP_TYPE_CAT;
- prv->map[0x0001].target = NULL;
- @@ -2154,7 +2285,7 @@
- n = prv->emm->get(prv->emm, §);
- if(n < 0){
- - r = ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE;
- + r = ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE;
- goto LAST;
- }
- @@ -2170,14 +2301,14 @@
- tail = sect.tail - 4;
- while( (head+13) <= tail ){
- -
- +
- extract_emm_fixed_part(&emm_hdr, head);
- len = emm_hdr.associated_information_length+7;
- if( (head+len) > tail ){
- /* broken EMM element */
- goto NEXT;
- }
- -
- +
- for(j=0;j<prv->casid.count;j++){
- if(prv->casid.data[j] == emm_hdr.card_id){
- n = prv->bcas->proc_emm(prv->bcas, head, len);
- @@ -2220,7 +2351,7 @@
- TS_STREAM_ELEM *strm;
- pid = pgrm->pmt_pid;
- -
- +
- if(pgrm->pmt != NULL){
- pgrm->pmt->release(pgrm->pmt);
- pgrm->pmt = NULL;
- @@ -2376,7 +2507,7 @@
- /* already binded - do nothing */
- return;
- }
- -
- +
- if(old != NULL){
- old->ref -= 1;
- if(old->ref == 0){
- @@ -2493,7 +2624,7 @@
- {
- int m,n;
- uint8_t *p;
- -
- +
- if(buf->max >= size){
- return 1;
- }
- @@ -2503,7 +2634,7 @@
- }else{
- n = buf->max * 2;
- }
- -
- +
- while(n < size){
- n += n;
- }
- @@ -2591,7 +2722,7 @@
- for(i=0;i<6;i++){
- dst->card_id = (dst->card_id << 8) | src[i];
- }
- -
- +
- dst->associated_information_length = src[ 6];
- dst->protocol_number = src[ 7];
- dst->broadcaster_group_id = src[ 8];
- @@ -2629,7 +2760,7 @@
- unsigned char *buf;
- buf = head;
- - while( buf <= (tail-188) ){
- + while( buf <= (tail-unit_size) ){
- if(buf[0] == 0x47){
- n = (tail - buf) / unit_size;
- if(n == 0){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement