| 1 | *** matroskadec.c.orig 2015-12-07 11:45:53.976807195 +0100
|
|---|
| 2 | --- matroskadec.c 2015-12-07 18:17:53.445838314 +0100
|
|---|
| 3 | ***************
|
|---|
| 4 | *** 312,317 ****
|
|---|
| 5 | --- 312,319 ----
|
|---|
| 6 |
|
|---|
| 7 | /* WebM DASH Manifest live flag/ */
|
|---|
| 8 | int is_live;
|
|---|
| 9 | +
|
|---|
| 10 | + uint8_t *pal;
|
|---|
| 11 | } MatroskaDemuxContext;
|
|---|
| 12 |
|
|---|
| 13 | typedef struct MatroskaBlock {
|
|---|
| 14 | ***************
|
|---|
| 15 | *** 1824,1830 ****
|
|---|
| 16 | codec_id = st->codec->codec_id;
|
|---|
| 17 | extradata_offset = FFMIN(track->codec_priv.size, 18);
|
|---|
| 18 | } else if (!strcmp(track->codec_id, "A_QUICKTIME")
|
|---|
| 19 | ! && (track->codec_priv.size >= 86)
|
|---|
| 20 | && (track->codec_priv.data)) {
|
|---|
| 21 | fourcc = AV_RL32(track->codec_priv.data + 4);
|
|---|
| 22 | codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
|
|---|
| 23 | --- 1826,1832 ----
|
|---|
| 24 | codec_id = st->codec->codec_id;
|
|---|
| 25 | extradata_offset = FFMIN(track->codec_priv.size, 18);
|
|---|
| 26 | } else if (!strcmp(track->codec_id, "A_QUICKTIME")
|
|---|
| 27 | ! && (track->codec_priv.size >= 36)
|
|---|
| 28 | && (track->codec_priv.data)) {
|
|---|
| 29 | fourcc = AV_RL32(track->codec_priv.data + 4);
|
|---|
| 30 | codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
|
|---|
| 31 | ***************
|
|---|
| 32 | *** 1835,1841 ****
|
|---|
| 33 | } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
|
|---|
| 34 | (track->codec_priv.size >= 21) &&
|
|---|
| 35 | (track->codec_priv.data)) {
|
|---|
| 36 | ! fourcc = AV_RL32(track->codec_priv.data + 4);
|
|---|
| 37 | codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
|
|---|
| 38 | if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) {
|
|---|
| 39 | fourcc = AV_RL32(track->codec_priv.data);
|
|---|
| 40 | --- 1837,1848 ----
|
|---|
| 41 | } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
|
|---|
| 42 | (track->codec_priv.size >= 21) &&
|
|---|
| 43 | (track->codec_priv.data)) {
|
|---|
| 44 | ! AVIOContext pb;
|
|---|
| 45 | ! MOVStreamContext *msc;
|
|---|
| 46 | ! void *priv_data;
|
|---|
| 47 | ! int nb_streams;
|
|---|
| 48 | ! MOVContext *mc;
|
|---|
| 49 | ! fourcc = AV_RL32(track->codec_priv.data + 4);
|
|---|
| 50 | codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
|
|---|
| 51 | if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) {
|
|---|
| 52 | fourcc = AV_RL32(track->codec_priv.data);
|
|---|
| 53 | ***************
|
|---|
| 54 | *** 1849,1854 ****
|
|---|
| 55 | --- 1856,1887 ----
|
|---|
| 56 | av_log(matroska->ctx, AV_LOG_ERROR,
|
|---|
| 57 | "mov FourCC not found %s.\n", buf);
|
|---|
| 58 | }
|
|---|
| 59 | + priv_data = st->priv_data;
|
|---|
| 60 | + nb_streams = s->nb_streams;
|
|---|
| 61 | + mc = av_mallocz(sizeof(*mc));
|
|---|
| 62 | + if (! mc)
|
|---|
| 63 | + return AVERROR(ENOMEM);
|
|---|
| 64 | + mc->fc = s;
|
|---|
| 65 | + st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
|
|---|
| 66 | + if (!msc) {
|
|---|
| 67 | + av_free(mc);
|
|---|
| 68 | + st->priv_data = priv_data;
|
|---|
| 69 | + return AVERROR(ENOMEM);
|
|---|
| 70 | + }
|
|---|
| 71 | + ffio_init_context(&pb, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL);
|
|---|
| 72 | + /* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
|
|---|
| 73 | + * so set it temporarily to indicate which stream to update. */
|
|---|
| 74 | + s->nb_streams = st->index + 1;
|
|---|
| 75 | + ff_mov_read_stsd_entries(mc, &pb, 1);
|
|---|
| 76 | + if (msc->has_palette) {
|
|---|
| 77 | + matroska->pal = av_malloc(AVPALETTE_SIZE);
|
|---|
| 78 | + if (matroska->pal)
|
|---|
| 79 | + memcpy(matroska->pal, msc->palette, AVPALETTE_SIZE);
|
|---|
| 80 | + }
|
|---|
| 81 | + av_free(msc);
|
|---|
| 82 | + av_free(mc);
|
|---|
| 83 | + st->priv_data = priv_data;
|
|---|
| 84 | + s->nb_streams = nb_streams;
|
|---|
| 85 | } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
|
|---|
| 86 | switch (track->audio.bitdepth) {
|
|---|
| 87 | case 8:
|
|---|
| 88 | ***************
|
|---|
| 89 | *** 2293,2298 ****
|
|---|
| 90 | --- 2326,2340 ----
|
|---|
| 91 | if (matroska->num_packets > 0) {
|
|---|
| 92 | memcpy(pkt, matroska->packets[0], sizeof(AVPacket));
|
|---|
| 93 | av_freep(&matroska->packets[0]);
|
|---|
| 94 | + if (matroska->pal) {
|
|---|
| 95 | + uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
|
|---|
| 96 | + if (!pal) {
|
|---|
| 97 | + av_log(matroska->ctx, AV_LOG_ERROR, "Cannot append palette to packet\n");
|
|---|
| 98 | + } else {
|
|---|
| 99 | + memcpy(pal, matroska->pal, AVPALETTE_SIZE);
|
|---|
| 100 | + }
|
|---|
| 101 | + av_freep(&matroska->pal);
|
|---|
| 102 | + }
|
|---|
| 103 | if (matroska->num_packets > 1) {
|
|---|
| 104 | void *newpackets;
|
|---|
| 105 | memmove(&matroska->packets[0], &matroska->packets[1],
|
|---|