Ticket #5071: matroskadec.c.latest.diff
| File matroskadec.c.latest.diff, 4.9 KB (added by , 11 years ago) |
|---|
-
matroskadec.c
old new 310 310 /* File has SSA subtitles which prevent incremental cluster parsing. */ 311 311 int contains_ssa; 312 312 313 313 /* WebM DASH Manifest live flag/ */ 314 314 int is_live; 315 316 uint8_t *pal; 315 317 } MatroskaDemuxContext; 316 318 317 319 typedef struct MatroskaBlock { 318 320 uint64_t duration; 319 321 int64_t reference; … … 1853 1855 if (ret < 0) 1854 1856 return ret; 1855 1857 codec_id = st->codec->codec_id; 1856 1858 extradata_offset = FFMIN(track->codec_priv.size, 18); 1857 1859 } else if (!strcmp(track->codec_id, "A_QUICKTIME") 1858 && (track->codec_priv.size >= 86)1860 && (track->codec_priv.size >= 36) 1859 1861 && (track->codec_priv.data)) { 1860 1862 fourcc = AV_RL32(track->codec_priv.data + 4); 1861 1863 codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc); 1862 1864 if (ff_codec_get_id(ff_codec_movaudio_tags, AV_RL32(track->codec_priv.data))) { 1863 1865 fourcc = AV_RL32(track->codec_priv.data); 1864 1866 codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc); 1865 1867 } 1866 1868 } else if (!strcmp(track->codec_id, "V_QUICKTIME") && 1867 1869 (track->codec_priv.size >= 21) && 1868 1870 (track->codec_priv.data)) { 1869 fourcc = AV_RL32(track->codec_priv.data + 4); 1871 AVIOContext pb; 1872 MOVContext *mc; 1873 MOVStreamContext *msc; 1874 void *priv_data; 1875 int nb_streams; 1876 fourcc = AV_RL32(track->codec_priv.data + 4); 1870 1877 codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc); 1871 1878 if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) { 1872 1879 fourcc = AV_RL32(track->codec_priv.data); 1873 1880 codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc); 1874 1881 } … … 1878 1885 char buf[32]; 1879 1886 av_get_codec_tag_string(buf, sizeof(buf), fourcc); 1880 1887 av_log(matroska->ctx, AV_LOG_ERROR, 1881 1888 "mov FourCC not found %s.\n", buf); 1882 1889 } 1890 priv_data = st->priv_data; 1891 nb_streams = s->nb_streams; 1892 mc = av_mallocz(sizeof(*mc)); 1893 if (! mc) 1894 return AVERROR(ENOMEM); 1895 mc->fc = s; 1896 st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext)); 1897 if (!msc) { 1898 av_free(mc); 1899 st->priv_data = priv_data; 1900 return AVERROR(ENOMEM); 1901 } 1902 ffio_init_context(&pb, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL); 1903 /* ff_mov_read_stsd_entries updates stream s->nb_streams-1, 1904 * so set it temporarily to indicate which stream to update. */ 1905 s->nb_streams = st->index + 1; 1906 ff_mov_read_stsd_entries(mc, &pb, 1); 1907 if (msc->has_palette) { 1908 if (! (matroska->pal = av_malloc(AVPALETTE_SIZE))) { 1909 av_free(msc); 1910 av_free(mc); 1911 st->priv_data = priv_data; 1912 return AVERROR(ENOMEM); 1913 } 1914 memcpy(matroska->pal, msc->palette, AVPALETTE_SIZE); 1915 if (! (extradata = av_malloc(AVPALETTE_SIZE))) { 1916 av_free(msc); 1917 av_free(mc); 1918 st->priv_data = priv_data; 1919 return AVERROR(ENOMEM); 1920 } 1921 memcpy(extradata, msc->palette, AVPALETTE_SIZE); 1922 extradata_size = AVPALETTE_SIZE; 1923 } 1924 av_free(msc); 1925 av_free(mc); 1926 st->priv_data = priv_data; 1927 s->nb_streams = nb_streams; 1883 1928 } else if (codec_id == AV_CODEC_ID_PCM_S16BE) { 1884 1929 switch (track->audio.bitdepth) { 1885 1930 case 8: 1886 1931 codec_id = AV_CODEC_ID_PCM_U8; 1887 1932 break; … … 2322 2367 AVPacket *pkt) 2323 2368 { 2324 2369 if (matroska->num_packets > 0) { 2325 2370 memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); 2326 2371 av_freep(&matroska->packets[0]); 2372 if (matroska->pal) { 2373 uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); 2374 if (!pal) { 2375 av_log(matroska->ctx, AV_LOG_ERROR, "Cannot append palette to packet\n"); 2376 } else { 2377 memcpy(pal, matroska->pal, AVPALETTE_SIZE); 2378 } 2379 av_freep(&matroska->pal); 2380 } 2327 2381 if (matroska->num_packets > 1) { 2328 2382 void *newpackets; 2329 2383 memmove(&matroska->packets[0], &matroska->packets[1], 2330 2384 (matroska->num_packets - 1) * sizeof(AVPacket *)); 2331 2385 newpackets = av_realloc(matroska->packets,
