Revision 979c0910 libavformat/matroskadec.c

View differences:

libavformat/matroskadec.c
95 95
typedef struct MatroskaSubtitleTrack {
96 96
    MatroskaTrack track;
97 97

  
98
    int ass;
98 99
    //..
99 100
} MatroskaSubtitleTrack;
100 101

  
......
2145 2146
                }
2146 2147
            }
2147 2148

  
2149
            else if (codec_id == CODEC_ID_TEXT) {
2150
                MatroskaSubtitleTrack *subtrack=(MatroskaSubtitleTrack *)track;
2151
                if (!strcmp(track->codec_id, "S_TEXT/ASS") ||
2152
                    !strcmp(track->codec_id, "S_TEXT/SSA"))
2153
                    subtrack->ass = 1;
2154
            }
2155

  
2148 2156
            if (codec_id == CODEC_ID_NONE) {
2149 2157
                av_log(matroska->ctx, AV_LOG_INFO,
2150 2158
                       "Unknown/unsupported CodecID %s.\n",
......
2430 2438
                        matroska_queue_packet(matroska, pkt);
2431 2439
                    }
2432 2440
                } else {
2441
                    int offset = 0;
2442

  
2443
                    if (st->codec->codec_id == CODEC_ID_TEXT
2444
                        && ((MatroskaSubtitleTrack *)(matroska->tracks[track]))->ass) {
2445
                        int i;
2446
                        for (i=0; i<8 && data[slice_offset+offset]; offset++)
2447
                            if (data[slice_offset+offset] == ',')
2448
                                i++;
2449
                    }
2450

  
2433 2451
                    pkt = av_mallocz(sizeof(AVPacket));
2434 2452
                    /* XXX: prevent data copy... */
2435
                    if (av_new_packet(pkt, slice_size) < 0) {
2453
                    if (av_new_packet(pkt, slice_size-offset) < 0) {
2436 2454
                        res = AVERROR_NOMEM;
2437 2455
                        n = laces-1;
2438 2456
                        break;
2439 2457
                    }
2440
                    memcpy (pkt->data, data+slice_offset, slice_size);
2458
                    memcpy (pkt->data, data+slice_offset+offset, slice_size-offset);
2441 2459

  
2442 2460
                    if (n == 0)
2443 2461
                        pkt->flags = is_keyframe;

Also available in: Unified diff