Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: patched-ffmpeg-mt/libavformat/matroskadec.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Matroska file demuxer 2 * Matroska file demuxer
3 * Copyright (c) 2003-2008 The FFmpeg Project 3 * Copyright (c) 2003-2008 The FFmpeg Project
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 char *language; 136 char *language;
137 double time_scale; 137 double time_scale;
138 uint64_t default_duration; 138 uint64_t default_duration;
139 uint64_t flag_default; 139 uint64_t flag_default;
140 MatroskaTrackVideo video; 140 MatroskaTrackVideo video;
141 MatroskaTrackAudio audio; 141 MatroskaTrackAudio audio;
142 EbmlList encodings; 142 EbmlList encodings;
143 143
144 AVStream *stream; 144 AVStream *stream;
145 int64_t end_timecode; 145 int64_t end_timecode;
146 int ms_compat;
146 } MatroskaTrack; 147 } MatroskaTrack;
147 148
148 typedef struct { 149 typedef struct {
149 uint64_t uid; 150 uint64_t uid;
150 char *filename; 151 char *filename;
151 char *mime; 152 char *mime;
152 EbmlBin bin; 153 EbmlBin bin;
153 154
154 AVStream *stream; 155 AVStream *stream;
155 } MatroskaAttachement; 156 } MatroskaAttachement;
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 } 1238 }
1238 } 1239 }
1239 1240
1240 st = track->stream = av_new_stream(s, 0); 1241 st = track->stream = av_new_stream(s, 0);
1241 if (st == NULL) 1242 if (st == NULL)
1242 return AVERROR(ENOMEM); 1243 return AVERROR(ENOMEM);
1243 1244
1244 if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") 1245 if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
1245 && track->codec_priv.size >= 40 1246 && track->codec_priv.size >= 40
1246 && track->codec_priv.data != NULL) { 1247 && track->codec_priv.data != NULL) {
1248 track->ms_compat = 1;
1247 track->video.fourcc = AV_RL32(track->codec_priv.data + 16); 1249 track->video.fourcc = AV_RL32(track->codec_priv.data + 16);
1248 codec_id = ff_codec_get_id(ff_codec_bmp_tags, track->video.fourcc); 1250 codec_id = ff_codec_get_id(ff_codec_bmp_tags, track->video.fourcc);
1249 extradata_offset = 40; 1251 extradata_offset = 40;
1250 } else if (!strcmp(track->codec_id, "A_MS/ACM") 1252 } else if (!strcmp(track->codec_id, "A_MS/ACM")
1251 && track->codec_priv.size >= 14 1253 && track->codec_priv.size >= 14
1252 && track->codec_priv.data != NULL) { 1254 && track->codec_priv.data != NULL) {
1253 init_put_byte(&b, track->codec_priv.data, track->codec_priv.size, 1255 init_put_byte(&b, track->codec_priv.data, track->codec_priv.size,
1254 URL_RDONLY, NULL, NULL, NULL, NULL); 1256 URL_RDONLY, NULL, NULL, NULL, NULL);
1255 ff_get_wav_header(&b, st->codec, track->codec_priv.size); 1257 ff_get_wav_header(&b, st->codec, track->codec_priv.size);
1256 codec_id = st->codec->codec_id; 1258 codec_id = st->codec->codec_id;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 + a * (h*w / a - track->audio.pkt_cnt--), a); 1669 + a * (h*w / a - track->audio.pkt_cnt--), a);
1668 pkt->pos = pos; 1670 pkt->pos = pos;
1669 pkt->stream_index = st->index; 1671 pkt->stream_index = st->index;
1670 dynarray_add(&matroska->packets,&matroska->num_packets,pkt); 1672 dynarray_add(&matroska->packets,&matroska->num_packets,pkt);
1671 } 1673 }
1672 } else { 1674 } else {
1673 MatroskaTrackEncoding *encodings = track->encodings.elem; 1675 MatroskaTrackEncoding *encodings = track->encodings.elem;
1674 int offset = 0, pkt_size = lace_size[n]; 1676 int offset = 0, pkt_size = lace_size[n];
1675 uint8_t *pkt_data = data; 1677 uint8_t *pkt_data = data;
1676 1678
1679 if (lace_size[n] > size) {
1680 av_log(matroska->ctx, AV_LOG_ERROR, "Invalid packet size\n") ;
1681 break;
1682 }
1683
1677 if (encodings && encodings->scope & 1) { 1684 if (encodings && encodings->scope & 1) {
1678 offset = matroska_decode_buffer(&pkt_data,&pkt_size, track); 1685 offset = matroska_decode_buffer(&pkt_data,&pkt_size, track);
1679 if (offset < 0) 1686 if (offset < 0)
1680 continue; 1687 continue;
1681 } 1688 }
1682 1689
1683 pkt = av_mallocz(sizeof(AVPacket)); 1690 pkt = av_mallocz(sizeof(AVPacket));
1684 /* XXX: prevent data copy... */ 1691 /* XXX: prevent data copy... */
1685 if (av_new_packet(pkt, pkt_size+offset) < 0) { 1692 if (av_new_packet(pkt, pkt_size+offset) < 0) {
1686 av_free(pkt); 1693 av_free(pkt);
1687 res = AVERROR(ENOMEM); 1694 res = AVERROR(ENOMEM);
1688 break; 1695 break;
1689 } 1696 }
1690 if (offset) 1697 if (offset)
1691 memcpy (pkt->data, encodings->compression.settings.data, off set); 1698 memcpy (pkt->data, encodings->compression.settings.data, off set);
1692 memcpy (pkt->data+offset, pkt_data, pkt_size); 1699 memcpy (pkt->data+offset, pkt_data, pkt_size);
1693 1700
1694 if (pkt_data != data) 1701 if (pkt_data != data)
1695 av_free(pkt_data); 1702 av_free(pkt_data);
1696 1703
1697 if (n == 0) 1704 if (n == 0)
1698 pkt->flags = is_keyframe; 1705 pkt->flags = is_keyframe;
1699 pkt->stream_index = st->index; 1706 pkt->stream_index = st->index;
1700 1707
1701 pkt->pts = timecode; 1708 if (track->ms_compat)
1709 pkt->dts = timecode;
1710 else
1711 pkt->pts = timecode;
1702 pkt->pos = pos; 1712 pkt->pos = pos;
1703 if (st->codec->codec_id == CODEC_ID_TEXT) 1713 if (st->codec->codec_id == CODEC_ID_TEXT)
1704 pkt->convergence_duration = duration; 1714 pkt->convergence_duration = duration;
1705 else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) 1715 else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE)
1706 pkt->duration = duration; 1716 pkt->duration = duration;
1707 1717
1708 if (st->codec->codec_id == CODEC_ID_SSA) 1718 if (st->codec->codec_id == CODEC_ID_SSA)
1709 matroska_fix_ass_packet(matroska, pkt, duration); 1719 matroska_fix_ass_packet(matroska, pkt, duration);
1710 1720
1711 if (matroska->prev_pkt && 1721 if (matroska->prev_pkt &&
1712 timecode != AV_NOPTS_VALUE && 1722 timecode != AV_NOPTS_VALUE &&
1713 matroska->prev_pkt->pts == timecode && 1723 matroska->prev_pkt->pts == timecode &&
1714 matroska->prev_pkt->stream_index == st->index) 1724 matroska->prev_pkt->stream_index == st->index)
1715 matroska_merge_packets(matroska->prev_pkt, pkt); 1725 matroska_merge_packets(matroska->prev_pkt, pkt);
1716 else { 1726 else {
1717 dynarray_add(&matroska->packets,&matroska->num_packets,pkt); 1727 dynarray_add(&matroska->packets,&matroska->num_packets,pkt);
1718 matroska->prev_pkt = pkt; 1728 matroska->prev_pkt = pkt;
1719 } 1729 }
1720 } 1730 }
1721 1731
1722 if (timecode != AV_NOPTS_VALUE) 1732 if (timecode != AV_NOPTS_VALUE)
1723 timecode = duration ? timecode + duration : AV_NOPTS_VALUE; 1733 timecode = duration ? timecode + duration : AV_NOPTS_VALUE;
1724 data += lace_size[n]; 1734 data += lace_size[n];
1735 size -= lace_size[n];
1725 } 1736 }
1726 } 1737 }
1727 1738
1728 av_free(lace_size); 1739 av_free(lace_size);
1729 return res; 1740 return res;
1730 } 1741 }
1731 1742
1732 static int matroska_parse_cluster(MatroskaDemuxContext *matroska) 1743 static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
1733 { 1744 {
1734 MatroskaCluster cluster = { 0 }; 1745 MatroskaCluster cluster = { 0 };
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 "matroska", 1852 "matroska",
1842 NULL_IF_CONFIG_SMALL("Matroska file format"), 1853 NULL_IF_CONFIG_SMALL("Matroska file format"),
1843 sizeof(MatroskaDemuxContext), 1854 sizeof(MatroskaDemuxContext),
1844 matroska_probe, 1855 matroska_probe,
1845 matroska_read_header, 1856 matroska_read_header,
1846 matroska_read_packet, 1857 matroska_read_packet,
1847 matroska_read_close, 1858 matroska_read_close,
1848 matroska_read_seek, 1859 matroska_read_seek,
1849 .metadata_conv = ff_mkv_metadata_conv, 1860 .metadata_conv = ff_mkv_metadata_conv,
1850 }; 1861 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698