Ticket #5071: patchmkvmov.diff
| File patchmkvmov.diff, 3.2 KB (added by , 11 years ago) |
|---|
-
libavformat/matroskadec.c
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 749e9a97..34c4829 100644
a b typedef struct MatroskaDemuxContext { 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 { … … static int matroska_parse_tracks(AVFormatContext *s) 1835 1837 } else if (!strcmp(track->codec_id, "V_QUICKTIME") && 1836 1838 (track->codec_priv.size >= 21) && 1837 1839 (track->codec_priv.data)) { 1840 /* 1838 1841 fourcc = AV_RL32(track->codec_priv.data + 4); 1839 1842 codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc); 1840 1843 if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) { … … static int matroska_parse_tracks(AVFormatContext *s) 1849 1852 av_log(matroska->ctx, AV_LOG_ERROR, 1850 1853 "mov FourCC not found %s.\n", buf); 1851 1854 } 1855 */ 1856 AVIOContext pb; 1857 MOVStreamContext *msc; 1858 void *priv_data = st->priv_data; 1859 int nb_streams = s->nb_streams; 1860 MOVContext *mc = av_mallocz(sizeof(*mc)); 1861 if (!mc) 1862 return AVERROR(ENOMEM); 1863 mc->fc = s; 1864 st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext)); 1865 if (!msc) { 1866 av_free(mc); 1867 st->priv_data = priv_data; 1868 return AVERROR(ENOMEM); 1869 } 1870 ffio_init_context(&pb, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL); 1871 /* ff_mov_read_stsd_entries updates stream s->nb_streams-1, 1872 * so set it temporarily to indicate which stream to update. */ 1873 s->nb_streams = st->index + 1; 1874 ff_mov_read_stsd_entries(mc, &pb, 1); 1875 1876 if (msc->has_palette) { 1877 matroska->pal = av_malloc(AVPALETTE_SIZE); 1878 if (matroska->pal) 1879 memcpy(matroska->pal, msc->palette, AVPALETTE_SIZE); 1880 } 1881 1882 av_free(msc); 1883 av_free(mc); 1884 st->priv_data = priv_data; 1885 s->nb_streams = nb_streams; 1886 codec_id = st->codec->codec_id; 1887 fourcc = st->codec->codec_tag; 1852 1888 } else if (codec_id == AV_CODEC_ID_PCM_S16BE) { 1853 1889 switch (track->audio.bitdepth) { 1854 1890 case 8: … … static int matroska_deliver_packet(MatroskaDemuxContext *matroska, 2293 2329 if (matroska->num_packets > 0) { 2294 2330 memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); 2295 2331 av_freep(&matroska->packets[0]); 2332 if (matroska->pal) { 2333 uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); 2334 if (!pal) { 2335 av_log(matroska->ctx, AV_LOG_ERROR, "Cannot append palette to packet\n"); 2336 } else { 2337 memcpy(pal, matroska->pal, AVPALETTE_SIZE); 2338 } 2339 av_freep(&matroska->pal); 2340 } 2296 2341 if (matroska->num_packets > 1) { 2297 2342 void *newpackets; 2298 2343 memmove(&matroska->packets[0], &matroska->packets[1],
