Mercurial > mplayer.hg
comparison libmpdemux/demux_ts.c @ 35224:b4d9b416a8f1
Remove some incorrect usages of realloc_struct.
author | reimar |
---|---|
date | Wed, 31 Oct 2012 20:56:41 +0000 |
parents | 053d1129e569 |
children | 3828cde710a2 |
comparison
equal
deleted
inserted
replaced
35223:425467b5be98 | 35224:b4d9b416a8f1 |
---|---|
1752 int skip; | 1752 int skip; |
1753 unsigned char *ptr; | 1753 unsigned char *ptr; |
1754 unsigned char *base; | 1754 unsigned char *base; |
1755 int entries, i; | 1755 int entries, i; |
1756 uint16_t progid; | 1756 uint16_t progid; |
1757 struct pat_progs_t *tmp; | |
1758 ts_section_t *section; | 1757 ts_section_t *section; |
1759 | 1758 |
1760 section = &(priv->pat.section); | 1759 section = &(priv->pat.section); |
1761 skip = collect_section(section, is_start, buff, size); | 1760 skip = collect_section(section, is_start, buff, size); |
1762 if(! skip) | 1761 if(! skip) |
1786 base = &ptr[8 + i*4]; | 1785 base = &ptr[8 + i*4]; |
1787 progid = (base[0] << 8) | base[1]; | 1786 progid = (base[0] << 8) | base[1]; |
1788 | 1787 |
1789 if((idx = prog_idx_in_pat(priv, progid)) == -1) | 1788 if((idx = prog_idx_in_pat(priv, progid)) == -1) |
1790 { | 1789 { |
1791 int sz = sizeof(struct pat_progs_t) * (priv->pat.progs_cnt+1); | 1790 priv->pat.progs = realloc_struct(priv->pat.progs, priv->pat.progs_cnt+1, sizeof(struct pat_progs_t)); |
1792 tmp = realloc_struct(priv->pat.progs, priv->pat.progs_cnt+1, sizeof(struct pat_progs_t)); | 1791 if(!priv->pat.progs) |
1793 if(tmp == NULL) | 1792 { |
1794 { | 1793 int sz = sizeof(struct pat_progs_t) * (priv->pat.progs_cnt+1); |
1794 priv->pat.progs_cnt = 0; | |
1795 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PAT: COULDN'T REALLOC %d bytes, NEXT\n", sz); | 1795 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PAT: COULDN'T REALLOC %d bytes, NEXT\n", sz); |
1796 break; | 1796 break; |
1797 } | 1797 } |
1798 priv->pat.progs = tmp; | |
1799 idx = priv->pat.progs_cnt; | 1798 idx = priv->pat.progs_cnt; |
1800 priv->pat.progs_cnt++; | 1799 priv->pat.progs_cnt++; |
1801 } | 1800 } |
1802 | 1801 |
1803 priv->pat.progs[idx].id = progid; | 1802 priv->pat.progs[idx].id = progid; |
2045 | 2044 |
2046 static uint16_t parse_mp4_es_descriptor(pmt_t *pmt, uint8_t *buf, int len) | 2045 static uint16_t parse_mp4_es_descriptor(pmt_t *pmt, uint8_t *buf, int len) |
2047 { | 2046 { |
2048 int i = 0, j = 0, k, found; | 2047 int i = 0, j = 0, k, found; |
2049 uint8_t flag; | 2048 uint8_t flag; |
2050 mp4_es_descr_t es, *target_es = NULL, *tmp; | 2049 mp4_es_descr_t es, *target_es = NULL; |
2051 | 2050 |
2052 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4ES: len=%d\n", len); | 2051 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4ES: len=%d\n", len); |
2053 memset(&es, 0, sizeof(mp4_es_descr_t)); | 2052 memset(&es, 0, sizeof(mp4_es_descr_t)); |
2054 while(i < len) | 2053 while(i < len) |
2055 { | 2054 { |
2080 } | 2079 } |
2081 } | 2080 } |
2082 | 2081 |
2083 if(! found) | 2082 if(! found) |
2084 { | 2083 { |
2085 tmp = realloc_struct(pmt->mp4es, pmt->mp4es_cnt+1, sizeof(mp4_es_descr_t)); | 2084 pmt->mp4es = realloc_struct(pmt->mp4es, pmt->mp4es_cnt+1, sizeof(mp4_es_descr_t)); |
2086 if(tmp == NULL) | 2085 if(!pmt->mp4es) |
2087 { | 2086 { |
2087 pmt->mp4es_cnt = 0; | |
2088 fprintf(stderr, "CAN'T REALLOC MP4_ES_DESCR\n"); | 2088 fprintf(stderr, "CAN'T REALLOC MP4_ES_DESCR\n"); |
2089 continue; | 2089 continue; |
2090 } | 2090 } |
2091 pmt->mp4es = tmp; | |
2092 target_es = &(pmt->mp4es[pmt->mp4es_cnt]); | 2091 target_es = &(pmt->mp4es[pmt->mp4es_cnt]); |
2093 pmt->mp4es_cnt++; | 2092 pmt->mp4es_cnt++; |
2094 } | 2093 } |
2095 memcpy(target_es, &es, sizeof(mp4_es_descr_t)); | 2094 memcpy(target_es, &es, sizeof(mp4_es_descr_t)); |
2096 mp_msg(MSGT_DEMUX, MSGL_V, "MP4ES_CNT: %d, ID=%d\n", pmt->mp4es_cnt, target_es->id); | 2095 mp_msg(MSGT_DEMUX, MSGL_V, "MP4ES_CNT: %d, ID=%d\n", pmt->mp4es_cnt, target_es->id); |
2421 unsigned char *base, *es_base; | 2420 unsigned char *base, *es_base; |
2422 pmt_t *pmt; | 2421 pmt_t *pmt; |
2423 int32_t idx, es_count, section_bytes; | 2422 int32_t idx, es_count, section_bytes; |
2424 uint8_t m=0; | 2423 uint8_t m=0; |
2425 int skip; | 2424 int skip; |
2426 pmt_t *tmp; | |
2427 struct pmt_es_t *tmp_es; | |
2428 ts_section_t *section; | 2425 ts_section_t *section; |
2429 ES_stream_t *tss; | 2426 ES_stream_t *tss; |
2430 int i; | 2427 int i; |
2431 | 2428 |
2432 idx = progid_idx_in_pmt(priv, progid); | 2429 idx = progid_idx_in_pmt(priv, progid); |
2433 | 2430 |
2434 if(idx == -1) | 2431 if(idx == -1) |
2435 { | 2432 { |
2436 int sz = (priv->pmt_cnt + 1) * sizeof(pmt_t); | 2433 priv->pmt = realloc_struct(priv->pmt, priv->pmt_cnt + 1, sizeof(pmt_t)); |
2437 tmp = realloc_struct(priv->pmt, priv->pmt_cnt + 1, sizeof(pmt_t)); | 2434 if(!priv->pmt) |
2438 if(tmp == NULL) | 2435 { |
2439 { | 2436 int sz = (priv->pmt_cnt + 1) * sizeof(pmt_t); |
2437 priv->pmt_cnt = 0; | |
2440 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT: COULDN'T REALLOC %d bytes, NEXT\n", sz); | 2438 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT: COULDN'T REALLOC %d bytes, NEXT\n", sz); |
2441 return 0; | 2439 return 0; |
2442 } | 2440 } |
2443 priv->pmt = tmp; | |
2444 idx = priv->pmt_cnt; | 2441 idx = priv->pmt_cnt; |
2445 memset(&(priv->pmt[idx]), 0, sizeof(pmt_t)); | 2442 memset(&(priv->pmt[idx]), 0, sizeof(pmt_t)); |
2446 priv->pmt_cnt++; | 2443 priv->pmt_cnt++; |
2447 priv->pmt[idx].progid = progid; | 2444 priv->pmt[idx].progid = progid; |
2448 } | 2445 } |
2492 es_pid = ((es_base[1] & 0x1f) << 8) | es_base[2]; | 2489 es_pid = ((es_base[1] & 0x1f) << 8) | es_base[2]; |
2493 | 2490 |
2494 idx = es_pid_in_pmt(pmt, es_pid); | 2491 idx = es_pid_in_pmt(pmt, es_pid); |
2495 if(idx == -1) | 2492 if(idx == -1) |
2496 { | 2493 { |
2497 int sz = sizeof(struct pmt_es_t) * (pmt->es_cnt + 1); | 2494 pmt->es = realloc_struct(pmt->es, pmt->es_cnt + 1, sizeof(struct pmt_es_t)); |
2498 tmp_es = realloc_struct(pmt->es, pmt->es_cnt + 1, sizeof(struct pmt_es_t)); | 2495 if(!pmt->es) |
2499 if(tmp_es == NULL) | 2496 { |
2500 { | 2497 int sz = sizeof(struct pmt_es_t) * (pmt->es_cnt + 1); |
2498 pmt->es_cnt = 0; | |
2501 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT, COULDN'T ALLOCATE %d bytes for PMT_ES\n", sz); | 2499 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT, COULDN'T ALLOCATE %d bytes for PMT_ES\n", sz); |
2502 continue; | 2500 continue; |
2503 } | 2501 } |
2504 pmt->es = tmp_es; | |
2505 idx = pmt->es_cnt; | 2502 idx = pmt->es_cnt; |
2506 memset(&(pmt->es[idx]), 0, sizeof(struct pmt_es_t)); | 2503 memset(&(pmt->es[idx]), 0, sizeof(struct pmt_es_t)); |
2507 pmt->es_cnt++; | 2504 pmt->es_cnt++; |
2508 } | 2505 } |
2509 | 2506 |