| OLD | NEW |
| (Empty) | |
| 1 diff -rpu -N orig/libavformat/matroskadec.c ffmpeg-mt/libavformat/matroskadec.c |
| 2 --- orig/libavformat/matroskadec.c 2010-06-24 19:20:06.232967800 -0700 |
| 3 +++ ffmpeg-mt/libavformat/matroskadec.c 2010-06-24 19:20:07.855388600 -0700 |
| 4 @@ -34,13 +34,17 @@ |
| 5 /* For ff_codec_get_id(). */ |
| 6 #include "riff.h" |
| 7 #include "isom.h" |
| 8 +#if CONFIG_SIPR_DECODER |
| 9 #include "rm.h" |
| 10 +#endif |
| 11 #include "matroska.h" |
| 12 #include "libavcodec/mpeg4audio.h" |
| 13 #include "libavutil/intfloat_readwrite.h" |
| 14 #include "libavutil/intreadwrite.h" |
| 15 #include "libavutil/avstring.h" |
| 16 +#if HAVE_LZO1X_999_COMPRESS |
| 17 #include "libavutil/lzo.h" |
| 18 +#endif |
| 19 #if CONFIG_ZLIB |
| 20 #include <zlib.h> |
| 21 #endif |
| 22 @@ -619,12 +623,14 @@ static int ebml_read_float(ByteIOContext |
| 23 static int ebml_read_ascii(ByteIOContext *pb, int size, char **str) |
| 24 { |
| 25 av_free(*str); |
| 26 + *str = NULL; |
| 27 /* EBML strings are usually not 0-terminated, so we allocate one |
| 28 * byte more, read the string and NULL-terminate it ourselves. */ |
| 29 - if (!(*str = av_malloc(size + 1))) |
| 30 + if (size < 0 || !(*str = av_malloc(size + 1))) |
| 31 return AVERROR(ENOMEM); |
| 32 if (get_buffer(pb, (uint8_t *) *str, size) != size) { |
| 33 av_freep(str); |
| 34 + *str = NULL; |
| 35 return AVERROR(EIO); |
| 36 } |
| 37 (*str)[size] = '\0'; |
| 38 @@ -646,6 +652,7 @@ static int ebml_read_binary(ByteIOContex |
| 39 bin->pos = url_ftell(pb); |
| 40 if (get_buffer(pb, bin->data, length) != length) { |
| 41 av_freep(&bin->data); |
| 42 + bin->data = NULL; |
| 43 return AVERROR(EIO); |
| 44 } |
| 45 |
| 46 @@ -866,6 +873,8 @@ static int matroska_probe(AVProbeData *p |
| 47 * Not fully fool-proof, but good enough. */ |
| 48 for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) { |
| 49 int probelen = strlen(matroska_doctypes[i]); |
| 50 + if (total < sizeof(probelen)) |
| 51 + return 0; |
| 52 for (n = 4+size; n <= 4+size+total-probelen; n++) |
| 53 if (!memcmp(p->buf+n, matroska_doctypes[i], probelen)) |
| 54 return AVPROBE_SCORE_MAX; |
| 55 @@ -903,6 +912,7 @@ static int matroska_decode_buffer(uint8_ |
| 56 switch (encodings[0].compression.algo) { |
| 57 case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP: |
| 58 return encodings[0].compression.settings.size; |
| 59 +#if HAVE_LZO1X_999_COMPRESS |
| 60 case MATROSKA_TRACK_ENCODING_COMP_LZO: |
| 61 do { |
| 62 olen = pkt_size *= 3; |
| 63 @@ -913,6 +923,7 @@ static int matroska_decode_buffer(uint8_ |
| 64 goto failed; |
| 65 pkt_size -= olen; |
| 66 break; |
| 67 +#endif |
| 68 #if CONFIG_ZLIB |
| 69 case MATROSKA_TRACK_ENCODING_COMP_ZLIB: { |
| 70 z_stream zstream = {0}; |
| 71 @@ -1173,6 +1184,7 @@ static int matroska_read_header(AVFormat |
| 72 ebml_free(ebml_syntax, &ebml); |
| 73 return AVERROR_PATCHWELCOME; |
| 74 } |
| 75 + av_metadata_set2(&s->metadata, "doctype", ebml.doctype, 0); |
| 76 for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) |
| 77 if (!strcmp(ebml.doctype, matroska_doctypes[i])) |
| 78 break; |
| 79 @@ -1232,14 +1244,17 @@ static int matroska_read_header(AVFormat |
| 80 "Multiple combined encodings no supported"); |
| 81 } else if (encodings_list->nb_elem == 1) { |
| 82 if (encodings[0].type || |
| 83 - (encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_
HEADERSTRIP && |
| 84 + (encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_
HEADERSTRIP |
| 85 #if CONFIG_ZLIB |
| 86 - encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_
ZLIB && |
| 87 + && encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_CO
MP_ZLIB |
| 88 #endif |
| 89 #if CONFIG_BZLIB |
| 90 - encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_
BZLIB && |
| 91 + && encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_CO
MP_BZLIB |
| 92 #endif |
| 93 - encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_
LZO)) { |
| 94 +#if HAVE_LZO1X_999_COMPRESS |
| 95 + && encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_CO
MP_LZO |
| 96 +#endif |
| 97 + )) { |
| 98 encodings[0].scope = 0; |
| 99 av_log(matroska->ctx, AV_LOG_ERROR, |
| 100 "Unsupported encoding type"); |
| 101 @@ -1364,11 +1379,13 @@ static int matroska_read_header(AVFormat |
| 102 st->codec->block_align = track->audio.coded_framesize; |
| 103 track->codec_priv.size = 0; |
| 104 } else { |
| 105 +#if CONFIG_SIPR_DECODER |
| 106 if (codec_id == CODEC_ID_SIPR && flavor < 4) { |
| 107 const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 }; |
| 108 track->audio.sub_packet_size = ff_sipr_subpk_size[flavor]; |
| 109 st->codec->bit_rate = sipr_bit_rate[flavor]; |
| 110 } |
| 111 +#endif |
| 112 st->codec->block_align = track->audio.sub_packet_size; |
| 113 extradata_offset = 78; |
| 114 } |
| 115 @@ -1429,6 +1446,8 @@ static int matroska_read_header(AVFormat |
| 116 } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { |
| 117 st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
| 118 st->codec->sample_rate = track->audio.out_samplerate; |
| 119 + if (st->codec->sample_rate <= 0) |
| 120 + st->codec->sample_rate = 1; |
| 121 st->codec->channels = track->audio.channels; |
| 122 if (st->codec->codec_id != CODEC_ID_AAC) |
| 123 st->need_parsing = AVSTREAM_PARSE_HEADERS; |
| 124 @@ -1708,8 +1727,10 @@ static int matroska_parse_block(Matroska |
| 125 memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y
>>1)), data+x*sps, sps); |
| 126 |
| 127 if (++track->audio.sub_packet_cnt >= h) { |
| 128 +#if CONFIG_SIPR_DECODER |
| 129 if (st->codec->codec_id == CODEC_ID_SIPR) |
| 130 ff_rm_reorder_sipr_data(track->audio.buf, h, w); |
| 131 +#endif |
| 132 track->audio.sub_packet_cnt = 0; |
| 133 track->audio.pkt_cnt = h*w / a; |
| 134 } |
| OLD | NEW |