From 64c2076bfcc61def58788968595b091d54e21f59 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 13 May 2010 16:26:55 +0000 Subject: [PATCH 001/301] update version string in changelog Originally committed as revision 23114 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 2 +- libavformat/mov.c | 31 ----- libavformat/movenc.c | 293 +++++++++++++++++-------------------------- 3 files changed, 115 insertions(+), 211 deletions(-) diff --git a/Changelog b/Changelog index c454c1596d..218f6cf690 100644 --- a/Changelog +++ b/Changelog @@ -2,7 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. -version : +version 0.6: - PB-frame decoding for H.263 - deprecated vhook subsystem removed diff --git a/libavformat/mov.c b/libavformat/mov.c index e37bcf5f57..2a60c92b34 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -219,36 +219,6 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_chpl(MOVContext *c, ByteIOContext *pb, MOVAtom atom) -{ - int64_t start; - int i, nb_chapters, str_len; - char str[256+1]; - - if ((atom.size -= 5) < 0) - return 0; - - get_be32(pb); // version + flags - get_be32(pb); // ??? - nb_chapters = get_byte(pb); - - for (i = 0; i < nb_chapters; i++) { - if (atom.size < 9) - return 0; - - start = get_be64(pb); - str_len = get_byte(pb); - - if ((atom.size -= 9+str_len) < 0) - return 0; - - get_buffer(pb, str, str_len); - str[str_len] = 0; - ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); - } - return 0; -} - static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { int64_t total_size = 0; @@ -2196,7 +2166,6 @@ static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom) static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('a','v','s','s'), mov_read_extradata }, -{ MKTAG('c','h','p','l'), mov_read_chpl }, { MKTAG('c','o','6','4'), mov_read_stco }, { MKTAG('c','t','t','s'), mov_read_ctts }, /* composition time to sample */ { MKTAG('d','i','n','f'), mov_read_default }, diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 9f10aed193..4efed1be56 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -77,15 +77,12 @@ typedef struct MOVIndex { MOVIentry *cluster; int audio_vbr; int height; ///< active picture (w/o VBI) height for D-10/IMX - uint32_t tref_tag; - int tref_id; ///< trackID of the referenced track } MOVTrack; typedef struct MOVMuxContext { int mode; int64_t time; int nb_streams; - int chapter_track; ///< qt chapter track number int64_t mdat_pos; uint64_t mdat_size; MOVTrack *tracks; @@ -1186,8 +1183,8 @@ static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) put_be32(pb, 0x40000000); /* reserved */ /* Track width and height, for visual only */ - if(st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO || - track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) { + if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO || + track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio); if(!sample_aspect_ratio || track->height != track->enc->height) sample_aspect_ratio = 1; @@ -1220,16 +1217,6 @@ static int mov_write_edts_tag(ByteIOContext *pb, MOVTrack *track) return 0x24; } -static int mov_write_tref_tag(ByteIOContext *pb, MOVTrack *track) -{ - put_be32(pb, 20); // size - put_tag(pb, "tref"); - put_be32(pb, 12); // size (subatom) - put_le32(pb, track->tref_tag); - put_be32(pb, track->tref_id); - return 20; -} - // goes at the end of each track! ... Critical for PSP playback ("Incompatible data" without it) static int mov_write_uuid_tag_psp(ByteIOContext *pb, MOVTrack *mov) { @@ -1257,8 +1244,6 @@ static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) mov_write_tkhd_tag(pb, track, st); if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS) mov_write_edts_tag(pb, track); // PSP Movies require edts box - if (track->tref_tag) - mov_write_tref_tag(pb, track); mov_write_mdia_tag(pb, track); if (track->mode == MODE_PSP) mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box @@ -1671,17 +1656,11 @@ static int mov_write_moov_tag(ByteIOContext *pb, MOVMuxContext *mov, mov->tracks[i].trackID = i+1; } - if (mov->chapter_track) - for (i=0; inb_streams; i++) { - mov->tracks[i].tref_tag = MKTAG('c','h','a','p'); - mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].trackID; - } - mov_write_mvhd_tag(pb, mov); //mov_write_iods_tag(pb, mov); for (i=0; inb_streams; i++) { if(mov->tracks[i].entry > 0) { - mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); + mov_write_trak_tag(pb, &(mov->tracks[i]), s->streams[i]); } } @@ -1822,6 +1801,117 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) put_be32(pb, 0x010001); /* ? */ } +static int mov_write_header(AVFormatContext *s) +{ + ByteIOContext *pb = s->pb; + MOVMuxContext *mov = s->priv_data; + int i; + + if (url_is_streamed(s->pb)) { + av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); + return -1; + } + + /* Default mode == MP4 */ + mov->mode = MODE_MP4; + + if (s->oformat != NULL) { + if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; + else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; + else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; + else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; + else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; + + mov_write_ftyp_tag(pb,s); + if (mov->mode == MODE_PSP) { + if (s->nb_streams != 2) { + av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); + return -1; + } + mov_write_uuidprof_tag(pb,s); + } + } + + mov->tracks = av_mallocz(s->nb_streams*sizeof(*mov->tracks)); + if (!mov->tracks) + return AVERROR(ENOMEM); + + for(i=0; inb_streams; i++){ + AVStream *st= s->streams[i]; + MOVTrack *track= &mov->tracks[i]; + AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0); + + track->enc = st->codec; + track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); + if (track->language < 0) + track->language = 0; + track->mode = mov->mode; + track->tag = mov_find_codec_tag(s, track); + if (!track->tag) { + av_log(s, AV_LOG_ERROR, "track %d: could not find tag, " + "codec not currently supported in container\n", i); + goto error; + } + if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ + if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || + track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || + track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { + if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { + av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); + goto error; + } + track->height = track->tag>>24 == 'n' ? 486 : 576; + } + track->timescale = st->codec->time_base.den; + if (track->mode == MODE_MOV && track->timescale > 100000) + av_log(s, AV_LOG_WARNING, + "WARNING codec timebase is very high. If duration is too long,\n" + "file may not be playable by quicktime. Specify a shorter timebase\n" + "or choose different container.\n"); + }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){ + track->timescale = st->codec->sample_rate; + if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { + av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i); + goto error; + }else if(st->codec->frame_size > 1){ /* assume compressed audio */ + track->audio_vbr = 1; + }else{ + st->codec->frame_size = 1; + track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; + } + if (track->mode != MODE_MOV) { + if (track->timescale > UINT16_MAX) { + av_log(s, AV_LOG_ERROR, "track %d: output format does not support " + "sample rate %dhz\n", i, track->timescale); + goto error; + } + if (track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) { + av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", + i, track->enc->sample_rate); + goto error; + } + } + }else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){ + track->timescale = st->codec->time_base.den; + } + if (!track->height) + track->height = st->codec->height; + + av_set_pts_info(st, 64, 1, track->timescale); + } + + mov_write_mdat_tag(pb, mov); + mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based + mov->nb_streams = s->nb_streams; + + put_flush_packet(pb); + + return 0; + error: + av_freep(&mov->tracks); + return -1; +} + static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags) { uint32_t c = -1; @@ -1939,158 +2029,6 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } -// QuickTime chapters involve an additional text track with the chapter names -// as samples, and a tref pointing from the other tracks to the chapter one. -static void mov_create_chapter_track(AVFormatContext *s, int tracknum) -{ - MOVMuxContext *mov = s->priv_data; - MOVTrack *track = &mov->tracks[tracknum]; - AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY }; - int i, len; - - track->mode = mov->mode; - track->tag = MKTAG('t','e','x','t'); - track->timescale = MOV_TIMESCALE; - track->enc = avcodec_alloc_context(); - track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE; - - for (i = 0; i < s->nb_chapters; i++) { - AVChapter *c = s->chapters[i]; - AVMetadataTag *t; - - int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE}); - pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE}); - pkt.duration = end - pkt.dts; - - if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) { - len = strlen(t->value); - pkt.size = len+2; - pkt.data = av_malloc(pkt.size); - AV_WB16(pkt.data, len); - memcpy(pkt.data+2, t->value, len); - mov_write_packet(s, &pkt); - av_freep(&pkt.data); - } - } -} - -static int mov_write_header(AVFormatContext *s) -{ - ByteIOContext *pb = s->pb; - MOVMuxContext *mov = s->priv_data; - int i; - - if (url_is_streamed(s->pb)) { - av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); - return -1; - } - - /* Default mode == MP4 */ - mov->mode = MODE_MP4; - - if (s->oformat != NULL) { - if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; - else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; - else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; - else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; - else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; - - mov_write_ftyp_tag(pb,s); - if (mov->mode == MODE_PSP) { - if (s->nb_streams != 2) { - av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); - return -1; - } - mov_write_uuidprof_tag(pb,s); - } - } - - mov->nb_streams = s->nb_streams; - if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters) - mov->chapter_track = mov->nb_streams++; - - mov->tracks = av_mallocz(mov->nb_streams*sizeof(*mov->tracks)); - if (!mov->tracks) - return AVERROR(ENOMEM); - - for(i=0; inb_streams; i++){ - AVStream *st= s->streams[i]; - MOVTrack *track= &mov->tracks[i]; - AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0); - - track->enc = st->codec; - track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); - if (track->language < 0) - track->language = 0; - track->mode = mov->mode; - track->tag = mov_find_codec_tag(s, track); - if (!track->tag) { - av_log(s, AV_LOG_ERROR, "track %d: could not find tag, " - "codec not currently supported in container\n", i); - goto error; - } - if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ - if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || - track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || - track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { - if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { - av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); - goto error; - } - track->height = track->tag>>24 == 'n' ? 486 : 576; - } - track->timescale = st->codec->time_base.den; - if (track->mode == MODE_MOV && track->timescale > 100000) - av_log(s, AV_LOG_WARNING, - "WARNING codec timebase is very high. If duration is too long,\n" - "file may not be playable by quicktime. Specify a shorter timebase\n" - "or choose different container.\n"); - }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){ - track->timescale = st->codec->sample_rate; - if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { - av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i); - goto error; - }else if(st->codec->frame_size > 1){ /* assume compressed audio */ - track->audio_vbr = 1; - }else{ - st->codec->frame_size = 1; - track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; - } - if (track->mode != MODE_MOV) { - if (track->timescale > UINT16_MAX) { - av_log(s, AV_LOG_ERROR, "track %d: output format does not support " - "sample rate %dhz\n", i, track->timescale); - goto error; - } - if (track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) { - av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", - i, track->enc->sample_rate); - goto error; - } - } - }else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){ - track->timescale = st->codec->time_base.den; - } - if (!track->height) - track->height = st->codec->height; - - av_set_pts_info(st, 64, 1, track->timescale); - } - - mov_write_mdat_tag(pb, mov); - mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based - - if (mov->chapter_track) - mov_create_chapter_track(s, mov->chapter_track); - - put_flush_packet(pb); - - return 0; - error: - av_freep(&mov->tracks); - return -1; -} - static int mov_write_trailer(AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; @@ -2115,9 +2053,6 @@ static int mov_write_trailer(AVFormatContext *s) mov_write_moov_tag(pb, mov, s); - if (mov->chapter_track) - av_freep(&mov->tracks[mov->chapter_track].enc); - for (i=0; inb_streams; i++) { av_freep(&mov->tracks[i].cluster); From eb9df4ac33f323890770d9da882dba751b205b49 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 13 May 2010 16:37:21 +0000 Subject: [PATCH 002/301] first draft of the release notes Originally committed as revision 23117 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 RELEASE diff --git a/RELEASE b/RELEASE new file mode 100644 index 0000000000..5c74afb216 --- /dev/null +++ b/RELEASE @@ -0,0 +1,84 @@ +Release Notes +============= + +* 0.6 "Works with HTML5" May, 2010 + +General notes +------------- + +See the Changelog file for a list of significant changes. + +Please note that our policy on bug reports has not changed. We still only accept +bug reports against HEAD of the FFmpeg trunk repository. If you are experiencing +any issues with any formally released version of FFmpeg, please try a current +version of the development code to check if the issue still exists. If it does, +make your report against the development code following the usual bug reporting +guidelines. + + +API and other notable Changes +----------------------------- + +Please see the file doc/APIchanges for programmer centric information + +Notably changes: +- deprecated vhook subsystem removed +- deprecated old scaler removed +- nonfree libamr support for AMR-NB/WB decoding/encoding removed +- RTMP support in libavformat +- -formats option split into -formats, -codecs, -bsfs, and -protocols +- ffprobe tool +- RTMP/RTMPT/RTMPS/RTMPE/RTMPTE protocol support via librtmp + + +Added Codecs: +------------- + +- VQF demuxer +- PCX encoder +- CorePNG decoding support +- 8088flex TMV demuxer and decoder +- enable symbol versioning by default for linkers that support it +- V210 decoder and encoder +- QCP demuxer +- SoX native format muxer and demuxer +- AMR-NB decoding/encoding, AMR-WB decoding via OpenCORE libraries +- DPX image decoder +- Electronic Arts Madcow decoder +- DivX (XSUB) subtitle encoder +- experimental AAC encoder +- Wave64 demuxer +- IEC-61937 compatible Muxer +- TwinVQ decoder +- Bluray (PGS) subtitle decoder +- LPCM support in MPEG-TS (HDMV RID as found on Blu-ray disks) +- WMA Pro decoder +- Core Audio Format demuxer +- Atrac1 decoder +- MD STUDIO audio demuxer +- RF64 support in WAV demuxer +- MPEG-4 Audio Lossless Coding (ALS) decoder +- IV8 demuxer +- CDG demuxer and decoder +- R210 decoder +- Auravision Aura 1 and 2 decoders +- Deluxe Paint Animation playback system +- SIPR decoder +- Adobe Filmstrip muxer and demuxer +- RTP depacketization of H.263 +- Bink demuxer and audio/video decoders +- IFF PBM/ILBM bitmap decoder +- Indeo 5 decoder +- WMA Voice decoder +- AMR-NB decoder +- RTSP muxer +- HE-AAC v1 decoder +- Kega Game Video (KGV1) decoder +- Psygnosis YOP demuxer and video decoder + + +Notable license related changes +------------------------------- + +- remaining GPL parts in AC-3 decoder converted to LGPL +- libswscale can now be compiled in LGPL mode From 26899578f1e000be990b0424fba6813402b7dc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 13 May 2010 19:42:32 +0000 Subject: [PATCH 003/301] Mention that both packetizers and depacketizers of H.263 and AMR were added Originally committed as revision 23130 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index 5c74afb216..54f074f23c 100644 --- a/RELEASE +++ b/RELEASE @@ -65,7 +65,7 @@ Added Codecs: - Deluxe Paint Animation playback system - SIPR decoder - Adobe Filmstrip muxer and demuxer -- RTP depacketization of H.263 +- RTP packetization and depacketization of H.263 and AMR - Bink demuxer and audio/video decoders - IFF PBM/ILBM bitmap decoder - Indeo 5 decoder From a03dcb9682142756894f0a97cf7a0dc7bae0f5ae Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 07:58:17 +0000 Subject: [PATCH 004/301] mov: Read nero chapters backport r23020 by conrad Originally committed as revision 23171 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/mov.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2a60c92b34..e37bcf5f57 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -219,6 +219,36 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_chpl(MOVContext *c, ByteIOContext *pb, MOVAtom atom) +{ + int64_t start; + int i, nb_chapters, str_len; + char str[256+1]; + + if ((atom.size -= 5) < 0) + return 0; + + get_be32(pb); // version + flags + get_be32(pb); // ??? + nb_chapters = get_byte(pb); + + for (i = 0; i < nb_chapters; i++) { + if (atom.size < 9) + return 0; + + start = get_be64(pb); + str_len = get_byte(pb); + + if ((atom.size -= 9+str_len) < 0) + return 0; + + get_buffer(pb, str, str_len); + str[str_len] = 0; + ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); + } + return 0; +} + static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { int64_t total_size = 0; @@ -2166,6 +2196,7 @@ static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom) static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('a','v','s','s'), mov_read_extradata }, +{ MKTAG('c','h','p','l'), mov_read_chpl }, { MKTAG('c','o','6','4'), mov_read_stco }, { MKTAG('c','t','t','s'), mov_read_ctts }, /* composition time to sample */ { MKTAG('d','i','n','f'), mov_read_default }, From 9d08b20fea72a8ecae5534073a7d2ebec27cbafb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:02:05 +0000 Subject: [PATCH 005/301] movenc: Swap positions of mov_write_header and mov_write_packet backport r23021 by conrad Originally committed as revision 23172 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/movenc.c | 222 +++++++++++++++++++++---------------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 4efed1be56..1c32b6fd19 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1801,117 +1801,6 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) put_be32(pb, 0x010001); /* ? */ } -static int mov_write_header(AVFormatContext *s) -{ - ByteIOContext *pb = s->pb; - MOVMuxContext *mov = s->priv_data; - int i; - - if (url_is_streamed(s->pb)) { - av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); - return -1; - } - - /* Default mode == MP4 */ - mov->mode = MODE_MP4; - - if (s->oformat != NULL) { - if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; - else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; - else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; - else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; - else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; - - mov_write_ftyp_tag(pb,s); - if (mov->mode == MODE_PSP) { - if (s->nb_streams != 2) { - av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); - return -1; - } - mov_write_uuidprof_tag(pb,s); - } - } - - mov->tracks = av_mallocz(s->nb_streams*sizeof(*mov->tracks)); - if (!mov->tracks) - return AVERROR(ENOMEM); - - for(i=0; inb_streams; i++){ - AVStream *st= s->streams[i]; - MOVTrack *track= &mov->tracks[i]; - AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0); - - track->enc = st->codec; - track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); - if (track->language < 0) - track->language = 0; - track->mode = mov->mode; - track->tag = mov_find_codec_tag(s, track); - if (!track->tag) { - av_log(s, AV_LOG_ERROR, "track %d: could not find tag, " - "codec not currently supported in container\n", i); - goto error; - } - if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ - if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || - track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || - track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { - if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { - av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); - goto error; - } - track->height = track->tag>>24 == 'n' ? 486 : 576; - } - track->timescale = st->codec->time_base.den; - if (track->mode == MODE_MOV && track->timescale > 100000) - av_log(s, AV_LOG_WARNING, - "WARNING codec timebase is very high. If duration is too long,\n" - "file may not be playable by quicktime. Specify a shorter timebase\n" - "or choose different container.\n"); - }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){ - track->timescale = st->codec->sample_rate; - if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { - av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i); - goto error; - }else if(st->codec->frame_size > 1){ /* assume compressed audio */ - track->audio_vbr = 1; - }else{ - st->codec->frame_size = 1; - track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; - } - if (track->mode != MODE_MOV) { - if (track->timescale > UINT16_MAX) { - av_log(s, AV_LOG_ERROR, "track %d: output format does not support " - "sample rate %dhz\n", i, track->timescale); - goto error; - } - if (track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) { - av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", - i, track->enc->sample_rate); - goto error; - } - } - }else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){ - track->timescale = st->codec->time_base.den; - } - if (!track->height) - track->height = st->codec->height; - - av_set_pts_info(st, 64, 1, track->timescale); - } - - mov_write_mdat_tag(pb, mov); - mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based - mov->nb_streams = s->nb_streams; - - put_flush_packet(pb); - - return 0; - error: - av_freep(&mov->tracks); - return -1; -} - static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags) { uint32_t c = -1; @@ -2029,6 +1918,117 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } +static int mov_write_header(AVFormatContext *s) +{ + ByteIOContext *pb = s->pb; + MOVMuxContext *mov = s->priv_data; + int i; + + if (url_is_streamed(s->pb)) { + av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); + return -1; + } + + /* Default mode == MP4 */ + mov->mode = MODE_MP4; + + if (s->oformat != NULL) { + if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; + else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; + else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; + else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; + else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; + + mov_write_ftyp_tag(pb,s); + if (mov->mode == MODE_PSP) { + if (s->nb_streams != 2) { + av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); + return -1; + } + mov_write_uuidprof_tag(pb,s); + } + } + + mov->tracks = av_mallocz(s->nb_streams*sizeof(*mov->tracks)); + if (!mov->tracks) + return AVERROR(ENOMEM); + + for(i=0; inb_streams; i++){ + AVStream *st= s->streams[i]; + MOVTrack *track= &mov->tracks[i]; + AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0); + + track->enc = st->codec; + track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); + if (track->language < 0) + track->language = 0; + track->mode = mov->mode; + track->tag = mov_find_codec_tag(s, track); + if (!track->tag) { + av_log(s, AV_LOG_ERROR, "track %d: could not find tag, " + "codec not currently supported in container\n", i); + goto error; + } + if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ + if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || + track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || + track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { + if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { + av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); + goto error; + } + track->height = track->tag>>24 == 'n' ? 486 : 576; + } + track->timescale = st->codec->time_base.den; + if (track->mode == MODE_MOV && track->timescale > 100000) + av_log(s, AV_LOG_WARNING, + "WARNING codec timebase is very high. If duration is too long,\n" + "file may not be playable by quicktime. Specify a shorter timebase\n" + "or choose different container.\n"); + }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){ + track->timescale = st->codec->sample_rate; + if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { + av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i); + goto error; + }else if(st->codec->frame_size > 1){ /* assume compressed audio */ + track->audio_vbr = 1; + }else{ + st->codec->frame_size = 1; + track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; + } + if (track->mode != MODE_MOV) { + if (track->timescale > UINT16_MAX) { + av_log(s, AV_LOG_ERROR, "track %d: output format does not support " + "sample rate %dhz\n", i, track->timescale); + goto error; + } + if (track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) { + av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", + i, track->enc->sample_rate); + goto error; + } + } + }else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){ + track->timescale = st->codec->time_base.den; + } + if (!track->height) + track->height = st->codec->height; + + av_set_pts_info(st, 64, 1, track->timescale); + } + + mov_write_mdat_tag(pb, mov); + mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based + mov->nb_streams = s->nb_streams; + + put_flush_packet(pb); + + return 0; + error: + av_freep(&mov->tracks); + return -1; +} + static int mov_write_trailer(AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; From 0db6f6cfedaea5e1cbda35239023c06c5648ff3c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:02:33 +0000 Subject: [PATCH 006/301] movenc: Write QuickTime chapters backport r23022 by conrad Originally committed as revision 23173 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/movenc.c | 75 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1c32b6fd19..9f10aed193 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -77,12 +77,15 @@ typedef struct MOVIndex { MOVIentry *cluster; int audio_vbr; int height; ///< active picture (w/o VBI) height for D-10/IMX + uint32_t tref_tag; + int tref_id; ///< trackID of the referenced track } MOVTrack; typedef struct MOVMuxContext { int mode; int64_t time; int nb_streams; + int chapter_track; ///< qt chapter track number int64_t mdat_pos; uint64_t mdat_size; MOVTrack *tracks; @@ -1183,8 +1186,8 @@ static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) put_be32(pb, 0x40000000); /* reserved */ /* Track width and height, for visual only */ - if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO || - track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { + if(st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO || + track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) { double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio); if(!sample_aspect_ratio || track->height != track->enc->height) sample_aspect_ratio = 1; @@ -1217,6 +1220,16 @@ static int mov_write_edts_tag(ByteIOContext *pb, MOVTrack *track) return 0x24; } +static int mov_write_tref_tag(ByteIOContext *pb, MOVTrack *track) +{ + put_be32(pb, 20); // size + put_tag(pb, "tref"); + put_be32(pb, 12); // size (subatom) + put_le32(pb, track->tref_tag); + put_be32(pb, track->tref_id); + return 20; +} + // goes at the end of each track! ... Critical for PSP playback ("Incompatible data" without it) static int mov_write_uuid_tag_psp(ByteIOContext *pb, MOVTrack *mov) { @@ -1244,6 +1257,8 @@ static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) mov_write_tkhd_tag(pb, track, st); if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS) mov_write_edts_tag(pb, track); // PSP Movies require edts box + if (track->tref_tag) + mov_write_tref_tag(pb, track); mov_write_mdia_tag(pb, track); if (track->mode == MODE_PSP) mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box @@ -1656,11 +1671,17 @@ static int mov_write_moov_tag(ByteIOContext *pb, MOVMuxContext *mov, mov->tracks[i].trackID = i+1; } + if (mov->chapter_track) + for (i=0; inb_streams; i++) { + mov->tracks[i].tref_tag = MKTAG('c','h','a','p'); + mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].trackID; + } + mov_write_mvhd_tag(pb, mov); //mov_write_iods_tag(pb, mov); for (i=0; inb_streams; i++) { if(mov->tracks[i].entry > 0) { - mov_write_trak_tag(pb, &(mov->tracks[i]), s->streams[i]); + mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); } } @@ -1918,6 +1939,41 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } +// QuickTime chapters involve an additional text track with the chapter names +// as samples, and a tref pointing from the other tracks to the chapter one. +static void mov_create_chapter_track(AVFormatContext *s, int tracknum) +{ + MOVMuxContext *mov = s->priv_data; + MOVTrack *track = &mov->tracks[tracknum]; + AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY }; + int i, len; + + track->mode = mov->mode; + track->tag = MKTAG('t','e','x','t'); + track->timescale = MOV_TIMESCALE; + track->enc = avcodec_alloc_context(); + track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE; + + for (i = 0; i < s->nb_chapters; i++) { + AVChapter *c = s->chapters[i]; + AVMetadataTag *t; + + int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE}); + pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE}); + pkt.duration = end - pkt.dts; + + if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) { + len = strlen(t->value); + pkt.size = len+2; + pkt.data = av_malloc(pkt.size); + AV_WB16(pkt.data, len); + memcpy(pkt.data+2, t->value, len); + mov_write_packet(s, &pkt); + av_freep(&pkt.data); + } + } +} + static int mov_write_header(AVFormatContext *s) { ByteIOContext *pb = s->pb; @@ -1949,7 +2005,11 @@ static int mov_write_header(AVFormatContext *s) } } - mov->tracks = av_mallocz(s->nb_streams*sizeof(*mov->tracks)); + mov->nb_streams = s->nb_streams; + if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters) + mov->chapter_track = mov->nb_streams++; + + mov->tracks = av_mallocz(mov->nb_streams*sizeof(*mov->tracks)); if (!mov->tracks) return AVERROR(ENOMEM); @@ -2019,7 +2079,9 @@ static int mov_write_header(AVFormatContext *s) mov_write_mdat_tag(pb, mov); mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based - mov->nb_streams = s->nb_streams; + + if (mov->chapter_track) + mov_create_chapter_track(s, mov->chapter_track); put_flush_packet(pb); @@ -2053,6 +2115,9 @@ static int mov_write_trailer(AVFormatContext *s) mov_write_moov_tag(pb, mov, s); + if (mov->chapter_track) + av_freep(&mov->tracks[mov->chapter_track].enc); + for (i=0; inb_streams; i++) { av_freep(&mov->tracks[i].cluster); From 1673bf86d6390cb3f7aaaae115264afa1dc41a14 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:03:22 +0000 Subject: [PATCH 007/301] Make av_strerror() return -1 even in the case when av_strerror_r() is not defined. This allows applications to check if av_strerror() cannot provide a meaningful representation for the provided error code, without having to actually check the filled string. backport r23031 by stefano Originally committed as revision 23174 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/avutil.h | 2 +- libavutil/error.c | 4 +++- libavutil/error.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavutil/avutil.h b/libavutil/avutil.h index b2c49283b0..e9e07b92fd 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -41,7 +41,7 @@ #define LIBAVUTIL_VERSION_MAJOR 50 #define LIBAVUTIL_VERSION_MINOR 15 -#define LIBAVUTIL_VERSION_MICRO 0 +#define LIBAVUTIL_VERSION_MICRO 1 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/libavutil/error.c b/libavutil/error.c index 3dd38a351c..b6d6019061 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -36,8 +36,10 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) } else { #if HAVE_STRERROR_R ret = strerror_r(AVUNERROR(errnum), errbuf, errbuf_size); +#else + ret = -1; #endif - if (!HAVE_STRERROR_R || ret < 0) + if (ret < 0) snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum); } diff --git a/libavutil/error.h b/libavutil/error.h index a1b9ccc050..13a9a35930 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -64,7 +64,8 @@ * error message indicating the errnum provided to errbuf. * * @param errbuf_size the size in bytes of errbuf - * @return 0 on success, a negative value otherwise + * @return 0 on success, a negative value if a description for errnum + * cannot be found */ int av_strerror(int errnum, char *errbuf, size_t errbuf_size); From e0e0283778043220e25ca050f5bbd549ab570c6f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:03:50 +0000 Subject: [PATCH 008/301] Make print_error() use strerror() in case av_strerror() fails. Should provide a meaningful error message for systems which do not support strerror_r(). Fix roundup issue #1894. backport r23032 by stefano Originally committed as revision 23175 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- cmdutils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index e6efc491d7..d02b36e66e 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -292,6 +292,7 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags) void print_error(const char *filename, int err) { char errbuf[128]; + const char *errbuf_ptr = errbuf; switch(err) { #if CONFIG_NETWORK @@ -300,8 +301,9 @@ void print_error(const char *filename, int err) break; #endif default: - av_strerror(err, errbuf, sizeof(errbuf)); - fprintf(stderr, "%s: %s\n", filename, errbuf); + if (av_strerror(err, errbuf, sizeof(errbuf)) < 0) + errbuf_ptr = strerror(AVUNERROR(err)); + fprintf(stderr, "%s: %s\n", filename, errbuf_ptr); } } From da8e4f5f79a221be447c174943ac5c76047f6d24 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:04:25 +0000 Subject: [PATCH 009/301] Simplify print_error(), directly use av_strerror()/strerror() for printing the error code associated to FF_NETERROR(EPROTONOSUPPORT). backport r23033 by stefano Originally committed as revision 23176 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- cmdutils.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index d02b36e66e..592d52a94a 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -294,17 +294,9 @@ void print_error(const char *filename, int err) char errbuf[128]; const char *errbuf_ptr = errbuf; - switch(err) { -#if CONFIG_NETWORK - case FF_NETERROR(EPROTONOSUPPORT): - fprintf(stderr, "%s: Unsupported network protocol\n", filename); - break; -#endif - default: if (av_strerror(err, errbuf, sizeof(errbuf)) < 0) errbuf_ptr = strerror(AVUNERROR(err)); fprintf(stderr, "%s: %s\n", filename, errbuf_ptr); - } } #define PRINT_LIB_VERSION(outstream,libname,LIBNAME,indent) \ From 50dab6369095609bb22df76eaf68c4600565695b Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:04:41 +0000 Subject: [PATCH 010/301] Reindent after the last commit. backport r23034 by stefano Originally committed as revision 23177 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- cmdutils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 592d52a94a..7a58cead8d 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -294,9 +294,9 @@ void print_error(const char *filename, int err) char errbuf[128]; const char *errbuf_ptr = errbuf; - if (av_strerror(err, errbuf, sizeof(errbuf)) < 0) - errbuf_ptr = strerror(AVUNERROR(err)); - fprintf(stderr, "%s: %s\n", filename, errbuf_ptr); + if (av_strerror(err, errbuf, sizeof(errbuf)) < 0) + errbuf_ptr = strerror(AVUNERROR(err)); + fprintf(stderr, "%s: %s\n", filename, errbuf_ptr); } #define PRINT_LIB_VERSION(outstream,libname,LIBNAME,indent) \ From dd68bb3cab5ddc9bce93513ac0112a7a5fe3926f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 11:38:07 +0000 Subject: [PATCH 011/301] Make the faac inspired quantizer search make sense for a slightly narrower definition of "make sense." backport r23035 by alexc Originally committed as revision 23182 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aaccoder.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index e19fa3803f..d30f854b98 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -763,7 +763,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, const float *scaled = s->scoefs + start; const int size = sce->ics.swb_sizes[g]; int scf, prev_scf, step; - int min_scf = 0, max_scf = 255; + int min_scf = -1, max_scf = 256; float curdiff; if (maxq[w*16+g] < 21.544) { sce->zeroes[w*16+g] = 1; @@ -797,21 +797,23 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, } prev_scf = scf; curdiff = fabsf(dist - uplim[w*16+g]); - if (curdiff == 0.0f) + if (curdiff <= 1.0f) step = 0; else - step = fabsf(log2(curdiff)); + step = log2(curdiff); if (dist > uplim[w*16+g]) step = -step; + scf += step; + av_clip_uint8(scf); + step = scf - prev_scf; if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) { - sce->sf_idx[w*16+g] = scf; + sce->sf_idx[w*16+g] = av_clip(scf, min_scf, max_scf); break; } - scf += step; if (step > 0) - min_scf = scf; + min_scf = prev_scf; else - max_scf = scf; + max_scf = prev_scf; } start += size; } From 3589ac6334c1281a9b2bee10ea8e549a5bc29cb5 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 11:38:30 +0000 Subject: [PATCH 012/301] Error out when too many bits per frame are requested. backport r23036 by alexc Originally committed as revision 23183 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aacenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index ff68f84e7b..72e93a40c8 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -174,6 +174,10 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Unsupported profile %d\n", avctx->profile); return -1; } + if (1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * avctx->channels) { + av_log(avctx, AV_LOG_ERROR, "Too many bits per frame requested\n"); + return -1; + } s->samplerate_index = i; dsputil_init(&s->dsp, avctx); From 8ab1409a59fcb972ba1476312d8d3c5bc788323e Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 11:39:02 +0000 Subject: [PATCH 013/301] 10l: store the result of clipping added in r23035 backport r23037 by alexc Originally committed as revision 23184 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aaccoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index d30f854b98..0957469957 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -804,7 +804,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, if (dist > uplim[w*16+g]) step = -step; scf += step; - av_clip_uint8(scf); + scf = av_clip_uint8(scf); step = scf - prev_scf; if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) { sce->sf_idx[w*16+g] = av_clip(scf, min_scf, max_scf); From ba9cecf5e5eeb9191452ca52cf47f57484d2a4a1 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 11:44:45 +0000 Subject: [PATCH 014/301] Favor chunk size over hitting the correct position after reading the chunk size in asf. Fixes issue1923 backport r23040 by michael Originally committed as revision 23185 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/asfdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index bbc27305e2..8aea8c7ef6 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -204,9 +204,10 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) get_byte(pb); memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); for(;;) { + uint64_t gpos= url_ftell(pb); get_guid(pb, &g); gsize = get_le64(pb); - dprintf(s, "%08"PRIx64": ", url_ftell(pb) - 24); + dprintf(s, "%08"PRIx64": ", gpos); print_guid(&g); dprintf(s, " size=0x%"PRIx64"\n", gsize); if (!guidcmp(&g, &ff_asf_data_header)) { @@ -584,8 +585,10 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n"); } } - url_fseek(pb, gsize - 24, SEEK_CUR); } + if(url_ftell(pb) != gpos + gsize) + av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", url_ftell(pb)-gpos, gsize); + url_fseek(pb, gpos + gsize, SEEK_SET); } get_guid(pb, &g); get_le64(pb); From 77a023f422bd97e7b578480af4b3838bc6ed72a8 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 11:46:39 +0000 Subject: [PATCH 015/301] Document cmdutils.c:print_error(). backport r23051 by stefano Originally committed as revision 23186 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- cmdutils.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmdutils.h b/cmdutils.h index ad8cefdeee..5656370610 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -134,6 +134,15 @@ void parse_options(int argc, char **argv, const OptionDef *options, void set_context_opts(void *ctx, void *opts_ctx, int flags); +/** + * Prints an error message to stderr, indicating filename and a human + * readable description of the error code err. + * + * If strerror_r() is not available the use of this function in a + * multithreaded application may be unsafe. + * + * @see av_strerror() + */ void print_error(const char *filename, int err); void list_fmts(void (*get_fmt_string)(char *buf, int buf_size, int fmt), int nb_fmts); From 8740ed496cf7cfda237952f8b300a3e4f3003993 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 13:29:36 +0000 Subject: [PATCH 016/301] Another try for fixing/improving decode_video documentation. backport r23057 by reimar Originally committed as revision 23187 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/avcodec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b6437473e6..c6e3b7d820 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3464,8 +3464,8 @@ attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *pi * * @param avctx the codec context * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * Use avcodec_alloc_frame to get an AVFrame, the codec will call - * get_buffer to get memory for the actual image data. + * Use avcodec_alloc_frame to get an AVFrame, the codec will + * allocate memory for the actual bitmap. * @param[in] avpkt The input AVpacket containing the input buffer. * You can create such packet with av_init_packet() and by then setting * data and size, some decoders might in addition need other fields like From dc04fb36d7ab108fdc10aaa1188fe88bc784f96f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 13:30:30 +0000 Subject: [PATCH 017/301] Remove hardcoded-tables hack for IA-64: with latest binutils that now actually causes linking errors instead of avoiding them. backport r23058 by reimar Originally committed as revision 23188 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 5 ----- 1 file changed, 5 deletions(-) diff --git a/configure b/configure index 5d1ba2b006..9ae28270ee 100755 --- a/configure +++ b/configure @@ -2406,11 +2406,6 @@ EOF enabled_all armv6t2 shared !pic && enable_pic -elif enabled ia64; then - - # HACK: currently fails to build if .bss is > 4MB and shared libs are built - enabled shared && enable_weak hardcoded_tables - elif enabled mips; then check_asm loongson '"dmult.g $1, $2, $3"' From 40630a90ed95018a2b2e5c740f2510a29a226f0f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 13:43:34 +0000 Subject: [PATCH 018/301] Fix build with swscale disabled backport r23062 by mru Originally committed as revision 23189 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- cmdutils.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmdutils.c b/cmdutils.c index 7a58cead8d..80917c3a19 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -609,6 +609,11 @@ void show_pix_fmts(void) "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n" "-----\n"); +#if !CONFIG_SWSCALE +# define sws_isSupportedInput(x) 0 +# define sws_isSupportedOutput(x) 0 +#endif + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) { const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; printf("%c%c%c%c%c %-16s %d %2d\n", From 369e37e9002e8aa765429ba6e969dda69c8f06fb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 13:51:54 +0000 Subject: [PATCH 019/301] qt-faststart: Avoid leaking memory if encountering a file with double ftyp atoms backport r23065 by mstorsjo Originally committed as revision 23190 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- tools/qt-faststart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c index bcd5e478a6..f48ffc0b5d 100644 --- a/tools/qt-faststart.c +++ b/tools/qt-faststart.c @@ -116,6 +116,7 @@ int main(int argc, char *argv[]) /* keep ftyp atom */ if (atom_type == FTYP_ATOM) { ftyp_atom_size = atom_size; + free(ftyp_atom); ftyp_atom = malloc(ftyp_atom_size); if (!ftyp_atom) { printf ("could not allocate %"PRIu64" byte for ftyp atom\n", From 08a441d4ad378be0cfee231621f0f4ee121ed091 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 20 May 2010 22:45:00 +0000 Subject: [PATCH 020/301] bswap: 10L add missing parens around macro args backport r23070 by mru Originally committed as revision 23204 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/bswap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/bswap.h b/libavutil/bswap.h index 2d36f2e2ea..6dd2a3511a 100644 --- a/libavutil/bswap.h +++ b/libavutil/bswap.h @@ -43,8 +43,8 @@ #endif #define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) -#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C(x >> 16)) -#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C(x >> 32)) +#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) +#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) #define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) From d1026ab5063a3e4ed2259ea68ab6d6f2ecfb4435 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 20 May 2010 22:46:11 +0000 Subject: [PATCH 021/301] Make the nut demuxer issue a more meaningful error message if it cannot recognize the provided codec tag. backport r23071 by stefano Originally committed as revision 23205 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/nutdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 522affbb57..5d5cd557b3 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -334,7 +334,8 @@ static int decode_stream_header(NUTContext *nut){ return -1; } if(class<3 && st->codec->codec_id == CODEC_ID_NONE) - av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); + av_log(s, AV_LOG_ERROR, "Unknown codec tag '0x%04x' for stream number %d\n", + (unsigned int)tmp, stream_id); GET_V(stc->time_base_id , tmp < nut->time_base_count); GET_V(stc->msb_pts_shift , tmp < 16); From b50601e882a8b77d0c6367bc789afd00695fa1ac Mon Sep 17 00:00:00 2001 From: Thomas Devanneaux Date: Fri, 21 May 2010 18:03:57 +0000 Subject: [PATCH 022/301] Check NAL unit size to avoid reading past the buffer. This fixes issue1907 Patch by Thomas Devanneaux gmail(thomdev) backport r23078 by benoit Originally committed as revision 23211 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/h264_mp4toannexb_bsf.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 936418a8a0..0c92b36f65 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -55,7 +55,9 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, int keyframe) { H264BSFContext *ctx = bsfc->priv_data; uint8_t unit_type; - uint32_t nal_size, cumul_size = 0; + int32_t nal_size; + uint32_t cumul_size = 0; + const uint8_t *buf_end = buf + buf_size; /* nothing to filter */ if (!avctx->extradata || avctx->extradata_size < 6) { @@ -109,6 +111,9 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, *poutbuf_size = 0; *poutbuf = NULL; do { + if (buf + ctx->length_size > buf_end) + goto fail; + if (ctx->length_size == 1) nal_size = buf[0]; else if (ctx->length_size == 2) @@ -119,6 +124,9 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, buf += ctx->length_size; unit_type = *buf & 0x1f; + if (buf + nal_size > buf_end || nal_size < 0) + goto fail; + /* prepend only to the first type 5 NAL unit of an IDR picture */ if (ctx->first_idr && unit_type == 5) { alloc_and_copy(poutbuf, poutbuf_size, @@ -139,6 +147,11 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, } while (cumul_size < buf_size); return 1; + +fail: + av_freep(poutbuf); + *poutbuf_size = 0; + return AVERROR(EINVAL); } static void h264_mp4toannexb_close(AVBitStreamFilterContext *bsfc) From 37a0852009a863acfa7afd3ab709e590959b70b1 Mon Sep 17 00:00:00 2001 From: Ronaldo Moura Date: Fri, 21 May 2010 18:05:38 +0000 Subject: [PATCH 023/301] blackfin: fix yuv422 to yuv420 conversion The old code is correct only when stride = 2*width. Patch by Ronaldo Moura backport r31142 by mru Originally committed as revision 23212 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libswscale/bfin/internal_bfin.S | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libswscale/bfin/internal_bfin.S b/libswscale/bfin/internal_bfin.S index 98f69ef53f..5af46540a8 100644 --- a/libswscale/bfin/internal_bfin.S +++ b/libswscale/bfin/internal_bfin.S @@ -479,9 +479,6 @@ DEFUN(uyvytoyv12, mL3, (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8 r1 = [fp + ARG_srcStride]; r2 = r0 + r1; - r1 += -8; // i0,i1 is pre read need to correct - m0 = r1; - i0 = r0; // uyvy_T even i1 = r2; // uyvy_B odd @@ -494,6 +491,12 @@ DEFUN(uyvytoyv12, mL3, (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8 p4 = p4 >> 1; p5 = p5 >> 2; + r2 = r0 << 1; + r1 = r1 << 1; + r1 = r1 - r2; // srcStride + (srcStride - 2*width) + r1 += -8; // i0,i1 is pre read need to correct + m0 = r1; + r2 = [fp + ARG_chromStride]; r0 = r0 >> 1; r2 = r2 - r0; @@ -549,8 +552,6 @@ DEFUN(yuyvtoyv12, mL3, (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8 r1 = [fp + ARG_srcStride]; r2 = r0 + r1; - r1 += -8; // i0,i1 is pre read need to correct - m0 = r1; i0 = r0; // uyvy_T even i1 = r2; // uyvy_B odd @@ -564,6 +565,12 @@ DEFUN(yuyvtoyv12, mL3, (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8 p4 = p4 >> 1; p5 = p5 >> 2; + r2 = r0 << 1; + r1 = r1 << 1; + r1 = r1 - r2; // srcStride + (srcStride - 2*width) + r1 += -8; // i0,i1 is pre read need to correct + m0 = r1; + r2 = [fp + ARG_chromStride]; r0 = r0 >> 1; r2 = r2 - r0; From 7590718414d1ea39edca482fb3ea4c1ce49a75ef Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:19:13 +0000 Subject: [PATCH 024/301] Replace more "m" constraints with MANGLE to fix compilation issues with x86_32 gcc 4.4.4 and -fPIC. backport r23082 by reimar Originally committed as revision 23213 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/x86/h264dsp_mmx.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c index ab6e0834c8..fd16a02d6a 100644 --- a/libavcodec/x86/h264dsp_mmx.c +++ b/libavcodec/x86/h264dsp_mmx.c @@ -1138,7 +1138,7 @@ static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uin int h=8;\ __asm__ volatile(\ "pxor %%mm7, %%mm7 \n\t"\ - "movq %5, %%mm6 \n\t"\ + "movq "MANGLE(ff_pw_5)", %%mm6\n\t"\ "1: \n\t"\ "movq (%0), %%mm0 \n\t"\ "movq 1(%0), %%mm2 \n\t"\ @@ -1172,7 +1172,7 @@ static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uin "punpcklbw %%mm7, %%mm5 \n\t"\ "paddw %%mm3, %%mm2 \n\t"\ "paddw %%mm5, %%mm4 \n\t"\ - "movq %6, %%mm5 \n\t"\ + "movq "MANGLE(ff_pw_16)", %%mm5\n\t"\ "paddw %%mm5, %%mm2 \n\t"\ "paddw %%mm5, %%mm4 \n\t"\ "paddw %%mm2, %%mm0 \n\t"\ @@ -1186,7 +1186,7 @@ static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uin "decl %2 \n\t"\ " jnz 1b \n\t"\ : "+a"(src), "+c"(dst), "+g"(h)\ - : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ + : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\ : "memory"\ );\ }\ @@ -1640,7 +1640,7 @@ static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uin int h=8;\ __asm__ volatile(\ "pxor %%xmm7, %%xmm7 \n\t"\ - "movdqa %5, %%xmm6 \n\t"\ + "movdqa "MANGLE(ff_pw_5)", %%xmm6\n\t"\ "1: \n\t"\ "lddqu -2(%0), %%xmm1 \n\t"\ "movdqa %%xmm1, %%xmm0 \n\t"\ @@ -1660,7 +1660,7 @@ static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uin "paddw %%xmm4, %%xmm1 \n\t"\ "psllw $2, %%xmm2 \n\t"\ "psubw %%xmm1, %%xmm2 \n\t"\ - "paddw %6, %%xmm0 \n\t"\ + "paddw "MANGLE(ff_pw_16)", %%xmm0\n\t"\ "pmullw %%xmm6, %%xmm2 \n\t"\ "paddw %%xmm0, %%xmm2 \n\t"\ "psraw $5, %%xmm2 \n\t"\ @@ -1671,8 +1671,7 @@ static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uin "decl %2 \n\t"\ " jnz 1b \n\t"\ : "+a"(src), "+c"(dst), "+g"(h)\ - : "D"((x86_reg)srcStride), "S"((x86_reg)dstStride),\ - "m"(ff_pw_5), "m"(ff_pw_16)\ + : "D"((x86_reg)srcStride), "S"((x86_reg)dstStride)\ : "memory"\ );\ }\ From 26fe0ec7d69748f717278b10558dbcf84269286f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:19:49 +0000 Subject: [PATCH 025/301] Adding missing () to mathops.h. backport r23083 by michael Originally committed as revision 23214 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/x86/mathops.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 010cfb70bb..5949dfe3d4 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -31,17 +31,17 @@ "imull %3 \n\t"\ "shrdl %4, %%edx, %%eax \n\t"\ : "=a"(rt), "=d"(dummy)\ - : "a" ((int)ra), "rm" ((int)rb), "i"(shift));\ + : "a" ((int)(ra)), "rm" ((int)(rb)), "i"(shift));\ rt; }) #define MULH(ra, rb) \ ({ int rt, dummy;\ - __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)ra), "rm" ((int)rb));\ + __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)(ra)), "rm" ((int)(rb)));\ rt; }) #define MUL64(ra, rb) \ ({ int64_t rt;\ - __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)ra), "g" ((int)rb));\ + __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)(ra)), "g" ((int)(rb)));\ rt; }) #endif From b68d9df427908a78b86e5be61e43ad8cb5258202 Mon Sep 17 00:00:00 2001 From: Nick Brereton Date: Fri, 21 May 2010 18:22:32 +0000 Subject: [PATCH 026/301] mlpdec: Allocate channel decoding parameters for each substream. Some file was encountered with a channel range that overlapped the previous substreams, and the code assumed no such overlap was possible. Patch by Nick Brereton backport r23084 by ramiro Originally committed as revision 23215 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/mlpdec.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 9169948f51..508be6f768 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -62,6 +62,8 @@ typedef struct SubStream { //! For each channel output by the matrix, the output channel to map it to uint8_t ch_assign[MAX_CHANNELS]; + ChannelParams channel_params[MAX_CHANNELS]; + //! The left shift applied to random noise in 0x31ea substreams. uint8_t noise_shift; //! The current seed value for the pseudorandom noise generator(s). @@ -137,8 +139,6 @@ typedef struct MLPDecodeContext { SubStream substream[MAX_SUBSTREAMS]; - ChannelParams channel_params[MAX_CHANNELS]; - int matrix_changed; int filter_changed[MAX_CHANNELS][NUM_FILTERS]; @@ -173,8 +173,8 @@ static av_cold void init_static(void) static inline int32_t calculate_sign_huff(MLPDecodeContext *m, unsigned int substr, unsigned int ch) { - ChannelParams *cp = &m->channel_params[ch]; SubStream *s = &m->substream[substr]; + ChannelParams *cp = &s->channel_params[ch]; int lsb_bits = cp->huff_lsbs - s->quant_step_size[ch]; int sign_shift = lsb_bits + (cp->codebook ? 2 - cp->codebook : -1); int32_t sign_huff_offset = cp->huff_offset; @@ -202,7 +202,7 @@ static inline int read_huff_channels(MLPDecodeContext *m, GetBitContext *gbp, m->bypassed_lsbs[pos + s->blockpos][mat] = get_bits1(gbp); for (channel = s->min_channel; channel <= s->max_channel; channel++) { - ChannelParams *cp = &m->channel_params[channel]; + ChannelParams *cp = &s->channel_params[channel]; int codebook = cp->codebook; int quant_step_size = s->quant_step_size[channel]; int lsb_bits = cp->huff_lsbs - quant_step_size; @@ -450,7 +450,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, memset(s->quant_step_size, 0, sizeof(s->quant_step_size)); for (ch = s->min_channel; ch <= s->max_channel; ch++) { - ChannelParams *cp = &m->channel_params[ch]; + ChannelParams *cp = &s->channel_params[ch]; cp->filter_params[FIR].order = 0; cp->filter_params[IIR].order = 0; cp->filter_params[FIR].shift = 0; @@ -472,9 +472,11 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, /** Read parameters for one of the prediction filters. */ static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, - unsigned int channel, unsigned int filter) + unsigned int substr, unsigned int channel, + unsigned int filter) { - FilterParams *fp = &m->channel_params[channel].filter_params[filter]; + SubStream *s = &m->substream[substr]; + FilterParams *fp = &s->channel_params[channel].filter_params[filter]; const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER; const char fchar = filter ? 'I' : 'F'; int i, order; @@ -497,7 +499,7 @@ static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, fp->order = order; if (order > 0) { - int32_t *fcoeff = m->channel_params[channel].coeff[filter]; + int32_t *fcoeff = s->channel_params[channel].coeff[filter]; int coeff_bits, coeff_shift; fp->shift = get_bits(gbp, 4); @@ -610,19 +612,19 @@ static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitCo static int read_channel_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp, unsigned int ch) { - ChannelParams *cp = &m->channel_params[ch]; + SubStream *s = &m->substream[substr]; + ChannelParams *cp = &s->channel_params[ch]; FilterParams *fir = &cp->filter_params[FIR]; FilterParams *iir = &cp->filter_params[IIR]; - SubStream *s = &m->substream[substr]; if (s->param_presence_flags & PARAM_FIR) if (get_bits1(gbp)) - if (read_filter_params(m, gbp, ch, FIR) < 0) + if (read_filter_params(m, gbp, substr, ch, FIR) < 0) return -1; if (s->param_presence_flags & PARAM_IIR) if (get_bits1(gbp)) - if (read_filter_params(m, gbp, ch, IIR) < 0) + if (read_filter_params(m, gbp, substr, ch, IIR) < 0) return -1; if (fir->order + iir->order > 8) { @@ -697,7 +699,7 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, if (s->param_presence_flags & PARAM_QUANTSTEP) if (get_bits1(gbp)) for (ch = 0; ch <= s->max_channel; ch++) { - ChannelParams *cp = &m->channel_params[ch]; + ChannelParams *cp = &s->channel_params[ch]; s->quant_step_size[ch] = get_bits(gbp, 4); @@ -721,12 +723,12 @@ static void filter_channel(MLPDecodeContext *m, unsigned int substr, unsigned int channel) { SubStream *s = &m->substream[substr]; - const int32_t *fircoeff = m->channel_params[channel].coeff[FIR]; + const int32_t *fircoeff = s->channel_params[channel].coeff[FIR]; int32_t state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FIR_ORDER]; int32_t *firbuf = state_buffer[FIR] + MAX_BLOCKSIZE; int32_t *iirbuf = state_buffer[IIR] + MAX_BLOCKSIZE; - FilterParams *fir = &m->channel_params[channel].filter_params[FIR]; - FilterParams *iir = &m->channel_params[channel].filter_params[IIR]; + FilterParams *fir = &s->channel_params[channel].filter_params[FIR]; + FilterParams *iir = &s->channel_params[channel].filter_params[IIR]; unsigned int filter_shift = fir->shift; int32_t mask = MSB_MASK(s->quant_step_size[channel]); From 6f8fbbf8d7b0e7e1390ded7c9118daa235482bd6 Mon Sep 17 00:00:00 2001 From: Nick Brereton Date: Fri, 21 May 2010 18:22:49 +0000 Subject: [PATCH 027/301] mlpdec: Comment channel_params field in struct SubStream. Patch by Nick Brereton backport r23085 by ramiro Originally committed as revision 23216 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/mlpdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 508be6f768..80fbbdb07e 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -62,6 +62,7 @@ typedef struct SubStream { //! For each channel output by the matrix, the output channel to map it to uint8_t ch_assign[MAX_CHANNELS]; + //! Channel coding parameters for channels in the substream ChannelParams channel_params[MAX_CHANNELS]; //! The left shift applied to random noise in 0x31ea substreams. From a70e7cc928186da2a23e69225c340a8d9972525d Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Fri, 21 May 2010 18:25:46 +0000 Subject: [PATCH 028/301] Add -ldl to libfaadbin_extralibs instead of libfaadbin_decoder_extralibs. The latter does not exist and thus compilation fails. patch by Janne Grunau, janne-ffmpeg jannau.net backport r23087 by diego Originally committed as revision 23217 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 9ae28270ee..828af886ae 100755 --- a/configure +++ b/configure @@ -1334,7 +1334,7 @@ libdirac_decoder_deps="libdirac !libschroedinger" libdirac_encoder_deps="libdirac" libfaac_encoder_deps="libfaac" libfaad_decoder_deps="libfaad" -libfaadbin_decoder_extralibs='$ldl' +libfaadbin_extralibs='$ldl' libgsm_decoder_deps="libgsm" libgsm_encoder_deps="libgsm" libgsm_ms_decoder_deps="libgsm" From b12045c8c7676ba5cced050be2f7df60f1efc88a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:27:16 +0000 Subject: [PATCH 029/301] Set cur_channel in the AAC encoder context where needed. Most coder functions read it. Carting this around in the context may be suboptimal; a refactor should be considered. backport r23094 by alexc Originally committed as revision 23218 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aacenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 72e93a40c8..938df344bb 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -561,6 +561,7 @@ static int aac_encode_frame(AVCodecContext *avctx, chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; for (j = 0; j < chans; j++) { + s->cur_channel = start_ch + j; s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda); } cpe->common_window = 0; @@ -576,6 +577,7 @@ static int aac_encode_frame(AVCodecContext *avctx, } } } + s->cur_channel = start_ch; if (cpe->common_window && s->coder->search_for_ms) s->coder->search_for_ms(s, cpe, s->lambda); adjust_frame_information(s, cpe, chans); From dd92ff49c9b2d3b515238a525a3f94de7e891327 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:32:58 +0000 Subject: [PATCH 030/301] Make lsf_sf_expand() 4 times faster. backport r23096 by michael Originally committed as revision 23219 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/mpegaudiodec.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 40383a8143..25fad80284 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -1315,23 +1315,32 @@ static int mp_decode_layer2(MPADecodeContext *s) return 3 * 12; } -static inline void lsf_sf_expand(int *slen, +#define SPLIT(dst,sf,n)\ + if(n==3){\ + int m= (sf*171)>>9;\ + dst= sf - 3*m;\ + sf=m;\ + }else if(n==4){\ + dst= sf&3;\ + sf>>=2;\ + }else if(n==5){\ + int m= (sf*205)>>10;\ + dst= sf - 5*m;\ + sf=m;\ + }else if(n==6){\ + int m= (sf*171)>>10;\ + dst= sf - 6*m;\ + sf=m;\ + }else{\ + dst=0;\ + } + +static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2, int n3) { - if (n3) { - slen[3] = sf % n3; - sf /= n3; - } else { - slen[3] = 0; - } - if (n2) { - slen[2] = sf % n2; - sf /= n2; - } else { - slen[2] = 0; - } - slen[1] = sf % n1; - sf /= n1; + SPLIT(slen[3], sf, n3) + SPLIT(slen[2], sf, n2) + SPLIT(slen[1], sf, n1) slen[0] = sf; } From cff1f85c3f77aebad87c606db1da10787aae3ca6 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:38:39 +0000 Subject: [PATCH 031/301] Fix compilation of AC3 decoder if E-AC3 decoder was disabled. backport r23131 by cehoyos Originally committed as revision 23220 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/ac3dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 0f9052ec26..f2f6e5ce4d 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1268,7 +1268,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) } /* apply spectral extension to high frequency bins */ - if (s->spx_in_use) { + if (s->spx_in_use && CONFIG_EAC3_DECODER) { ff_eac3_apply_spectral_extension(s); } From a7216204eb845336d44ef43176516b5b11f885c2 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:46:03 +0000 Subject: [PATCH 032/301] Change MAX_READ_SIZE message during av_find_stream_info to DEBUG level. It is not harmful and it scares too many users. backport r23139 by bcoudurier Originally committed as revision 23221 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 9e6279a06b..1da1313e6e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2201,7 +2201,7 @@ int av_find_stream_info(AVFormatContext *ic) /* we did not get all the codec info, but we read too much data */ if (read_size >= ic->probesize) { ret = count; - av_log(ic, AV_LOG_WARNING, "MAX_READ_SIZE:%d reached\n", ic->probesize); + av_log(ic, AV_LOG_DEBUG, "MAX_READ_SIZE:%d reached\n", ic->probesize); break; } From 745414242485b7c33d140b0b73f11da729f73e82 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:46:59 +0000 Subject: [PATCH 033/301] Clarify descriptions for RGB4, BGR4, NV12, NV21, RGB48BE, and RGB48LE pixel formats. backport r23142 by stefano Originally committed as revision 23222 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/pixfmt.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index ef06049b12..75daed9afa 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -79,12 +79,12 @@ enum PixelFormat { PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) - PIX_FMT_BGR4, ///< packed RGB 1:2:1, 4bpp, (msb)1B 2G 1R(lsb) + PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) - PIX_FMT_RGB4, ///< packed RGB 1:2:1, 4bpp, (msb)1R 2G 1B(lsb) + PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) - PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV + PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) PIX_FMT_NV21, ///< as above, but U and V bytes are swapped PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... @@ -102,8 +102,8 @@ enum PixelFormat { PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers - PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, big-endian - PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, little-endian + PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian From daf864016d302c69d9fc6dfeb4c2c7cdbf153356 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:47:19 +0000 Subject: [PATCH 034/301] Clarify description for the MONOWHITE and MONOBLACK pixel formats. backport r23144 by stefano Originally committed as revision 23223 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/pixfmt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 75daed9afa..d976f343ba 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -68,8 +68,8 @@ enum PixelFormat { PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) PIX_FMT_GRAY8, ///< Y , 8bpp - PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black - PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white + PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb + PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG) PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG) From fcaba8390965d62b36a0aa4fe73cb9c6544ffd15 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 18:49:32 +0000 Subject: [PATCH 035/301] ffserver: Make sure a destination URL is set when creating the SDP Debugged by Howard Chu, hyc at highlandsun dot com. backport r23151 by mstorsjo Originally committed as revision 23224 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffserver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ffserver.c b/ffserver.c index e81245d9d3..7dcc9b23fd 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2946,6 +2946,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d", inet_ntoa(stream->multicast_ip), stream->multicast_port, stream->multicast_ttl); + } else { + snprintf(avc->filename, 1024, "rtp://0.0.0.0"); } for(i = 0; i < stream->nb_streams; i++) { From 85ed859e6b577eb03038d810048375e0ef703a80 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 20:13:34 +0000 Subject: [PATCH 036/301] set avg frame rate in mkv demuxer backport r23152 by bcoudurier Originally committed as revision 23225 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/matroskadec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4e6f375c5f..90356d818b 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1390,6 +1390,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) 255); if (st->codec->codec_id != CODEC_ID_H264) st->need_parsing = AVSTREAM_PARSE_HEADERS; + if (track->default_duration) + st->avg_frame_rate = av_d2q(1000000000.0/track->default_duration, INT_MAX); } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->sample_rate = track->audio.out_samplerate; From b9a35435a50ce160f13164f943c94c43d2affa81 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Fri, 21 May 2010 20:15:53 +0000 Subject: [PATCH 037/301] In ts demuxer, output pes packet as soon as they are complete. This is needed for subtitles where packets are infrequent. Patch by Janne Grunau, janne-ffmpeg at jannau dot net. backport r23157 by bcoudurier Originally committed as revision 23226 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/mpegts.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index c92a9c2585..59603384d2 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -807,6 +807,16 @@ static int mpegts_push_data(MpegTSFilter *filter, pes->data_index += buf_size; } buf_size = 0; + /* emit complete packets with known packet size + * decreases demuxer delay for infrequent packets like subtitles from + * a couple of seconds to milliseconds for properly muxed files. + * total_size is the number of bytes following pes_packet_length + * in the pes header, i.e. not counting the first 6 bytes */ + if (pes->total_size < MAX_PES_PAYLOAD && + pes->pes_header_size + pes->data_index == pes->total_size + 6) { + ts->stop_parse = 1; + new_pes_packet(pes, ts->pkt); + } break; case MPEGTS_SKIP: buf_size = 0; From 34a0dee17e924caec491e3a2002bdf743b3cacd3 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Fri, 21 May 2010 20:20:01 +0000 Subject: [PATCH 038/301] Fix signedness of q_delta field of the IVIMbInfo. Patch by Maxim max_pole () gmx * de backport r23170 by benoit Originally committed as revision 23227 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/ivi_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h index 9d0eac1a34..64793e479e 100644 --- a/libavcodec/ivi_common.h +++ b/libavcodec/ivi_common.h @@ -89,7 +89,7 @@ typedef struct { uint32_t buf_offs; ///< address in the output buffer for this mb uint8_t type; ///< macroblock type: 0 - INTRA, 1 - INTER uint8_t cbp; ///< coded block pattern - uint8_t q_delta; ///< quant delta + int8_t q_delta; ///< quant delta int8_t mv_x; ///< motion vector (x component) int8_t mv_y; ///< motion vector (y component) } IVIMbInfo; From 3588e6b7c5327eb0831d1b0fc4baf2ce96566b98 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 20:22:18 +0000 Subject: [PATCH 039/301] Fix a crash when opening WMS RTSP streams Fixes issue 1948 backport r23181 by mstorsjo Originally committed as revision 23228 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/rtsp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index fec91f11b8..6dbd796d31 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1337,6 +1337,8 @@ static int rtsp_read_play(AVFormatContext *s) RTSPStream *rtsp_st = rt->rtsp_streams[i]; RTPDemuxContext *rtpctx = rtsp_st->transport_priv; AVStream *st = NULL; + if (!rtpctx) + continue; if (rtsp_st->stream_index >= 0) st = s->streams[rtsp_st->stream_index]; rtpctx->last_rtcp_ntp_time = AV_NOPTS_VALUE; From e6ef35bc22681895983ce28809dd6b2544cfb5a8 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 20:23:22 +0000 Subject: [PATCH 040/301] Make aac_decode_frame() consume zero padding at the end of a packet. backport r23195 by alexc Originally committed as revision 23229 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/aac.c b/libavcodec/aac.c index ac8c9c6ec4..3330e1cefe 100644 --- a/libavcodec/aac.c +++ b/libavcodec/aac.c @@ -1954,6 +1954,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, int err, elem_id, data_size_tmp; int buf_consumed; int samples = 1024, multiplier; + int buf_offset; init_get_bits(&gb, buf, buf_size * 8); @@ -2065,7 +2066,11 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, ac->output_configured = OC_LOCKED; buf_consumed = (get_bits_count(&gb) + 7) >> 3; - return buf_size > buf_consumed ? buf_consumed : buf_size; + for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++) + if (buf[buf_offset]) + break; + + return buf_size > buf_offset ? buf_consumed : buf_size; } static av_cold int aac_decode_close(AVCodecContext *avccontext) From 7d8b893b7e7b86c760e6c35c5e422e55b4386b89 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 21 May 2010 20:24:08 +0000 Subject: [PATCH 041/301] Disable non interleaved avi code when there is no index available. Fixes issue1956. backport r23202 by michael Originally committed as revision 23230 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/avidec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index e866a93480..485c4eb93a 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -650,6 +650,16 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) avi_load_index(s); avi->index_loaded = 1; avi->non_interleaved |= guess_ni_flag(s); + for(i=0; inb_streams; i++){ + AVStream *st = s->streams[i]; + if(st->nb_index_entries) + break; + } + if(i==s->nb_streams && avi->non_interleaved) { + av_log(s, AV_LOG_WARNING, "non-interleaved AVI without index, switching to interleaved\n"); + avi->non_interleaved=0; + } + if(avi->non_interleaved) { av_log(s, AV_LOG_INFO, "non-interleaved AVI\n"); clean_index(s); From 3d24c2ce026d1d3080124b5af1c067eb635c0bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:43:40 +0000 Subject: [PATCH 042/301] Make ff_sdp_write_media a lavf-internal function This is in preparation for RTP hinting in the MOV muxer, where it needs to be able to create SDP fragments for each media stream. backport r23160 by mstorsjo Originally committed as revision 23233 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/internal.h | 17 +++++++++++++++++ libavformat/sdp.c | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 789988019d..a395c2f24b 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -137,4 +137,21 @@ int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt, ...); +/** + * Appends the media-specific SDP fragment for the media stream c + * to the buffer buff. + * + * Note, the buffer needs to be initialized, since it is appended to + * existing content. + * + * @param buff the buffer to append the SDP fragment to + * @param size the size of the buff buffer + * @param c the AVCodecContext of the media to describe + * @param dest_addr the destination address of the media stream, may be NULL + * @param port the destination port of the media stream, 0 if unknown + * @param ttl the time to live of the stream, 0 if not multicast + */ +void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, + const char *dest_addr, int port, int ttl); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/sdp.c b/libavformat/sdp.c index a8cab6a68f..6bf05dbe39 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -294,7 +294,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, return buff; } -static void sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, int port, int ttl) +void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, int port, int ttl) { const char *type; int payload_type; @@ -352,7 +352,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) resolve_destination(dst, sizeof(dst)); } for (j = 0; j < ac[i]->nb_streams; j++) { - sdp_write_media(buff, size, + ff_sdp_write_media(buff, size, ac[i]->streams[j]->codec, dst[0] ? dst : NULL, (port > 0) ? port + j * 2 : 0, ttl); if (port <= 0) { @@ -369,4 +369,9 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) { return AVERROR(ENOSYS); } + +void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, + const char *dest_addr, int port, int ttl) +{ +} #endif From ed2b1f80fa32bb2f71c6f6ed71d7a0013e26a5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:44:43 +0000 Subject: [PATCH 043/301] Add a flag for enabling RTP hinting backport r23161 by mstorsjo Originally committed as revision 23234 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/avformat.h | 1 + libavformat/options.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9928e84dad..cd164a3d73 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -653,6 +653,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled +#define AVFMT_FLAG_RTP_HINT 0x0040 ///< Add RTP hinting to the output file int loop_input; /** decoding: size of data to probe; encoding: unused. */ diff --git a/libavformat/options.c b/libavformat/options.c index 85d793ec09..0c1ac2d866 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -49,6 +49,7 @@ static const AVOption options[]={ {"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOFILLIN, INT_MIN, INT_MAX, D, "fflags"}, {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"}, {"igndts", "ingore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"}, +{"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_RTP_HINT, INT_MIN, INT_MAX, E, "fflags"}, #if LIBAVFORMAT_VERSION_INT < (53<<16) {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E}, {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E}, From 6438cb834cfe462588b37a76dd2c41125027db8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:45:21 +0000 Subject: [PATCH 044/301] Move the mov muxer structures to a separate header backport r23162 by mstorsjo Originally committed as revision 23235 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/movenc.c | 60 +----------------------------- libavformat/movenc.h | 88 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 59 deletions(-) create mode 100644 libavformat/movenc.h diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 9f10aed193..914bb2de12 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -21,6 +21,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "movenc.h" #include "avformat.h" #include "riff.h" #include "avio.h" @@ -32,65 +33,6 @@ #undef NDEBUG #include -#define MOV_INDEX_CLUSTER_SIZE 16384 -#define MOV_TIMESCALE 1000 - -#define MODE_MP4 0x01 -#define MODE_MOV 0x02 -#define MODE_3GP 0x04 -#define MODE_PSP 0x08 // example working PSP command line: -// ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4 -#define MODE_3G2 0x10 -#define MODE_IPOD 0x20 - -typedef struct MOVIentry { - unsigned int size; - uint64_t pos; - unsigned int samplesInChunk; - unsigned int entries; - int cts; - int64_t dts; -#define MOV_SYNC_SAMPLE 0x0001 -#define MOV_PARTIAL_SYNC_SAMPLE 0x0002 - uint32_t flags; -} MOVIentry; - -typedef struct MOVIndex { - int mode; - int entry; - unsigned timescale; - uint64_t time; - int64_t trackDuration; - long sampleCount; - long sampleSize; - int hasKeyframes; -#define MOV_TRACK_CTTS 0x0001 -#define MOV_TRACK_STPS 0x0002 - uint32_t flags; - int language; - int trackID; - int tag; ///< stsd fourcc - AVCodecContext *enc; - - int vosLen; - uint8_t *vosData; - MOVIentry *cluster; - int audio_vbr; - int height; ///< active picture (w/o VBI) height for D-10/IMX - uint32_t tref_tag; - int tref_id; ///< trackID of the referenced track -} MOVTrack; - -typedef struct MOVMuxContext { - int mode; - int64_t time; - int nb_streams; - int chapter_track; ///< qt chapter track number - int64_t mdat_pos; - uint64_t mdat_size; - MOVTrack *tracks; -} MOVMuxContext; - //FIXME support 64 bit variant with wide placeholders static int64_t updateSize(ByteIOContext *pb, int64_t pos) { diff --git a/libavformat/movenc.h b/libavformat/movenc.h new file mode 100644 index 0000000000..f490bd02a8 --- /dev/null +++ b/libavformat/movenc.h @@ -0,0 +1,88 @@ +/* + * MOV, 3GP, MP4 muxer + * Copyright (c) 2003 Thomas Raivio + * Copyright (c) 2004 Gildas Bazin + * Copyright (c) 2009 Baptiste Coudurier + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_MOVENC_H +#define AVFORMAT_MOVENC_H + +#include "avformat.h" + +#define MOV_INDEX_CLUSTER_SIZE 16384 +#define MOV_TIMESCALE 1000 + +#define MODE_MP4 0x01 +#define MODE_MOV 0x02 +#define MODE_3GP 0x04 +#define MODE_PSP 0x08 // example working PSP command line: +// ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4 +#define MODE_3G2 0x10 +#define MODE_IPOD 0x20 + +typedef struct MOVIentry { + unsigned int size; + uint64_t pos; + unsigned int samplesInChunk; + unsigned int entries; + int cts; + int64_t dts; +#define MOV_SYNC_SAMPLE 0x0001 +#define MOV_PARTIAL_SYNC_SAMPLE 0x0002 + uint32_t flags; +} MOVIentry; + +typedef struct MOVIndex { + int mode; + int entry; + unsigned timescale; + uint64_t time; + int64_t trackDuration; + long sampleCount; + long sampleSize; + int hasKeyframes; +#define MOV_TRACK_CTTS 0x0001 +#define MOV_TRACK_STPS 0x0002 + uint32_t flags; + int language; + int trackID; + int tag; ///< stsd fourcc + AVCodecContext *enc; + + int vosLen; + uint8_t *vosData; + MOVIentry *cluster; + int audio_vbr; + int height; ///< active picture (w/o VBI) height for D-10/IMX + uint32_t tref_tag; + int tref_id; ///< trackID of the referenced track +} MOVTrack; + +typedef struct MOVMuxContext { + int mode; + int64_t time; + int nb_streams; + int chapter_track; ///< qt chapter track number + int64_t mdat_pos; + uint64_t mdat_size; + MOVTrack *tracks; +} MOVMuxContext; + +#endif /* AVFORMAT_MOVENC_H */ From a14f86aac7bec3f1401efc2b0cdad4d5cdc2882f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:45:54 +0000 Subject: [PATCH 045/301] Make mov_write_packet non-static, add ff_ prefix backport r23163 by mstorsjo Originally committed as revision 23236 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/movenc.c | 16 ++++++++-------- libavformat/movenc.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 914bb2de12..41a95c9f00 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1785,7 +1785,7 @@ static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags) return 0; } -static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) +int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; ByteIOContext *pb = s->pb; @@ -1910,7 +1910,7 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum) pkt.data = av_malloc(pkt.size); AV_WB16(pkt.data, len); memcpy(pkt.data+2, t->value, len); - mov_write_packet(s, &pkt); + ff_mov_write_packet(s, &pkt); av_freep(&pkt.data); } } @@ -2084,7 +2084,7 @@ AVOutputFormat mov_muxer = { CODEC_ID_AAC, CODEC_ID_MPEG4, mov_write_header, - mov_write_packet, + ff_mov_write_packet, mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, .codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0}, @@ -2100,7 +2100,7 @@ AVOutputFormat tgp_muxer = { CODEC_ID_AMR_NB, CODEC_ID_H263, mov_write_header, - mov_write_packet, + ff_mov_write_packet, mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, @@ -2116,7 +2116,7 @@ AVOutputFormat mp4_muxer = { CODEC_ID_AAC, CODEC_ID_MPEG4, mov_write_header, - mov_write_packet, + ff_mov_write_packet, mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, @@ -2132,7 +2132,7 @@ AVOutputFormat psp_muxer = { CODEC_ID_AAC, CODEC_ID_MPEG4, mov_write_header, - mov_write_packet, + ff_mov_write_packet, mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, @@ -2148,7 +2148,7 @@ AVOutputFormat tg2_muxer = { CODEC_ID_AMR_NB, CODEC_ID_H263, mov_write_header, - mov_write_packet, + ff_mov_write_packet, mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, @@ -2164,7 +2164,7 @@ AVOutputFormat ipod_muxer = { CODEC_ID_AAC, CODEC_ID_H264, mov_write_header, - mov_write_packet, + ff_mov_write_packet, mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0}, diff --git a/libavformat/movenc.h b/libavformat/movenc.h index f490bd02a8..089701dcfe 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -85,4 +85,6 @@ typedef struct MOVMuxContext { MOVTrack *tracks; } MOVMuxContext; +int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); + #endif /* AVFORMAT_MOVENC_H */ From d48539fb85023119897728d869f741520da03f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:46:23 +0000 Subject: [PATCH 046/301] Add initial support for RTP hinting in the mov muxer backport r23164 by mstorsjo Originally committed as revision 23237 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/Makefile | 2 +- libavformat/movenc.c | 109 ++++++++++++++- libavformat/movenc.h | 14 ++ libavformat/movenchint.c | 292 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 414 insertions(+), 3 deletions(-) create mode 100644 libavformat/movenchint.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 43a4a2e0d4..a671e283e2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -114,7 +114,7 @@ OBJS-$(CONFIG_MM_DEMUXER) += mm.o OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o raw.o OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o -OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o +OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o movenchint.o OBJS-$(CONFIG_MP2_MUXER) += mp3.o id3v1.o OBJS-$(CONFIG_MP3_DEMUXER) += mp3.o id3v1.o id3v2.o OBJS-$(CONFIG_MP3_MUXER) += mp3.o id3v1.o id3v2.o diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 41a95c9f00..440c98ad26 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -29,6 +29,8 @@ #include "avc.h" #include "libavcodec/get_bits.h" #include "libavcodec/put_bits.h" +#include "internal.h" +#include "libavutil/avstring.h" #undef NDEBUG #include @@ -806,6 +808,26 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track) return updateSize(pb, pos); } +static int mov_write_rtp_tag(ByteIOContext *pb, MOVTrack *track) +{ + int64_t pos = url_ftell(pb); + put_be32(pb, 0); /* size */ + put_tag(pb, "rtp "); + put_be32(pb, 0); /* Reserved */ + put_be16(pb, 0); /* Reserved */ + put_be16(pb, 1); /* Data-reference index */ + + put_be16(pb, 1); /* Hint track version */ + put_be16(pb, 1); /* Highest compatible version */ + put_be32(pb, track->max_packet_size); /* Max packet size */ + + put_be32(pb, 12); /* size */ + put_tag(pb, "tims"); + put_be32(pb, track->timescale); + + return updateSize(pb, pos); +} + static int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack *track) { int64_t pos = url_ftell(pb); @@ -819,6 +841,8 @@ static int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack *track) mov_write_audio_tag(pb, track); else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) mov_write_subtitle_tag(pb, track); + else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) + mov_write_rtp_tag(pb, track); return updateSize(pb, pos); } @@ -918,7 +942,8 @@ static int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack *track) put_tag(pb, "stbl"); mov_write_stsd_tag(pb, track); mov_write_stts_tag(pb, track); - if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO && + if ((track->enc->codec_type == AVMEDIA_TYPE_VIDEO || + track->enc->codec_tag == MKTAG('r','t','p',' ')) && track->hasKeyframes && track->hasKeyframes < track->entry) mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE); if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS) @@ -1005,6 +1030,9 @@ static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack *track) if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl"; else hdlr_type = "text"; descr = "SubtitleHandler"; + } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) { + hdlr_type = "hint"; + descr = "HintHandler"; } } @@ -1024,6 +1052,21 @@ static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack *track) return updateSize(pb, pos); } +static int mov_write_hmhd_tag(ByteIOContext *pb) +{ + /* This atom must be present, but leaving the values at zero + * seems harmless. */ + put_be32(pb, 28); /* size */ + put_tag(pb, "hmhd"); + put_be32(pb, 0); /* version, flags */ + put_be16(pb, 0); /* maxPDUsize */ + put_be16(pb, 0); /* avgPDUsize */ + put_be32(pb, 0); /* maxbitrate */ + put_be32(pb, 0); /* avgbitrate */ + put_be32(pb, 0); /* reserved */ + return 28; +} + static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack *track) { int64_t pos = url_ftell(pb); @@ -1036,6 +1079,8 @@ static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack *track) else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (track->tag == MKTAG('t','e','x','t')) mov_write_gmhd_tag(pb); else mov_write_nmhd_tag(pb); + } else if (track->tag == MKTAG('r','t','p',' ')) { + mov_write_hmhd_tag(pb); } if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */ mov_write_hdlr_tag(pb, NULL); @@ -1191,6 +1236,25 @@ static int mov_write_uuid_tag_psp(ByteIOContext *pb, MOVTrack *mov) return 0x34; } +static int mov_write_udta_sdp(ByteIOContext *pb, AVCodecContext *ctx, int index) +{ + char buf[1000] = ""; + int len; + + ff_sdp_write_media(buf, sizeof(buf), ctx, NULL, 0, 0); + av_strlcatf(buf, sizeof(buf), "a=control:streamid=%d\r\n", index); + len = strlen(buf); + + put_be32(pb, len + 24); + put_tag (pb, "udta"); + put_be32(pb, len + 16); + put_tag (pb, "hnti"); + put_be32(pb, len + 8); + put_tag (pb, "sdp "); + put_buffer(pb, buf, len); + return len + 24; +} + static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) { int64_t pos = url_ftell(pb); @@ -1204,6 +1268,8 @@ static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) mov_write_mdia_tag(pb, track); if (track->mode == MODE_PSP) mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box + if (track->tag == MKTAG('r','t','p',' ')) + mov_write_udta_sdp(pb, track->rtp_ctx->streams[0]->codec, track->trackID); return updateSize(pb, pos); } @@ -1618,6 +1684,13 @@ static int mov_write_moov_tag(ByteIOContext *pb, MOVMuxContext *mov, mov->tracks[i].tref_tag = MKTAG('c','h','a','p'); mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].trackID; } + for (i = 0; i < mov->nb_streams; i++) { + if (mov->tracks[i].tag == MKTAG('r','t','p',' ')) { + mov->tracks[i].tref_tag = MKTAG('h','i','n','t'); + mov->tracks[i].tref_id = + mov->tracks[mov->tracks[i].src_track].trackID; + } + } mov_write_mvhd_tag(pb, mov); //mov_write_iods_tag(pb, mov); @@ -1878,6 +1951,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) mov->mdat_size += size; put_flush_packet(pb); + + if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) + ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry); return 0; } @@ -1920,7 +1996,7 @@ static int mov_write_header(AVFormatContext *s) { ByteIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; - int i; + int i, hint_track = 0; if (url_is_streamed(s->pb)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); @@ -1951,6 +2027,18 @@ static int mov_write_header(AVFormatContext *s) if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters) mov->chapter_track = mov->nb_streams++; + if (s->flags & AVFMT_FLAG_RTP_HINT) { + /* Add hint tracks for each audio and video stream */ + hint_track = mov->nb_streams; + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || + st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + mov->nb_streams++; + } + } + } + mov->tracks = av_mallocz(mov->nb_streams*sizeof(*mov->tracks)); if (!mov->tracks) return AVERROR(ENOMEM); @@ -1971,6 +2059,9 @@ static int mov_write_header(AVFormatContext *s) "codec not currently supported in container\n", i); goto error; } + /* If hinting of this track is enabled by a later hint track, + * this is updated. */ + track->hint_track = -1; if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || @@ -2025,6 +2116,18 @@ static int mov_write_header(AVFormatContext *s) if (mov->chapter_track) mov_create_chapter_track(s, mov->chapter_track); + if (s->flags & AVFMT_FLAG_RTP_HINT) { + /* Initialize the hint tracks for each audio and video stream */ + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || + st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + ff_mov_init_hinting(s, hint_track, i); + hint_track++; + } + } + } + put_flush_packet(pb); return 0; @@ -2061,6 +2164,8 @@ static int mov_write_trailer(AVFormatContext *s) av_freep(&mov->tracks[mov->chapter_track].enc); for (i=0; inb_streams; i++) { + if (mov->tracks[i].tag == MKTAG('r','t','p',' ')) + ff_mov_close_hinting(&mov->tracks[i]); av_freep(&mov->tracks[i].cluster); if(mov->tracks[i].vosLen) av_free(mov->tracks[i].vosData); diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 089701dcfe..3d8f4ba499 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -29,6 +29,8 @@ #define MOV_INDEX_CLUSTER_SIZE 16384 #define MOV_TIMESCALE 1000 +#define RTP_MAX_PACKET_SIZE 1450 + #define MODE_MP4 0x01 #define MODE_MOV 0x02 #define MODE_3GP 0x04 @@ -73,6 +75,13 @@ typedef struct MOVIndex { int height; ///< active picture (w/o VBI) height for D-10/IMX uint32_t tref_tag; int tref_id; ///< trackID of the referenced track + + int hint_track; ///< the track that hints this track, -1 if no hint track is set + int src_track; ///< the track that this hint track describes + AVFormatContext *rtp_ctx; ///< the format context for the hinting rtp muxer + uint32_t prev_rtp_ts; + int64_t cur_rtp_ts_unwrapped; + uint32_t max_packet_size; } MOVTrack; typedef struct MOVMuxContext { @@ -87,4 +96,9 @@ typedef struct MOVMuxContext { int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); +int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index); +int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, + int track_index, int sample); +void ff_mov_close_hinting(MOVTrack *track); + #endif /* AVFORMAT_MOVENC_H */ diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c new file mode 100644 index 0000000000..e830b741a8 --- /dev/null +++ b/libavformat/movenchint.c @@ -0,0 +1,292 @@ +/* + * MOV, 3GP, MP4 muxer RTP hinting + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "movenc.h" +#include "libavutil/intreadwrite.h" + +int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) +{ + MOVMuxContext *mov = s->priv_data; + MOVTrack *track = &mov->tracks[index]; + MOVTrack *src_track = &mov->tracks[src_index]; + AVStream *src_st = s->streams[src_index]; + int ret = AVERROR(ENOMEM); + AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); + + track->tag = MKTAG('r','t','p',' '); + track->src_track = src_index; + + if (!rtp_format) { + ret = AVERROR(ENOENT); + goto fail; + } + + track->enc = avcodec_alloc_context(); + if (!track->enc) + goto fail; + track->enc->codec_type = AVMEDIA_TYPE_DATA; + track->enc->codec_tag = track->tag; + + track->rtp_ctx = avformat_alloc_context(); + if (!track->rtp_ctx) + goto fail; + track->rtp_ctx->oformat = rtp_format; + if (!av_new_stream(track->rtp_ctx, 0)) + goto fail; + + /* Copy stream parameters */ + track->rtp_ctx->streams[0]->sample_aspect_ratio = + src_st->sample_aspect_ratio; + + /* Remove the allocated codec context, link to the original one + * instead, to give the rtp muxer access to codec parameters. */ + av_free(track->rtp_ctx->streams[0]->codec); + track->rtp_ctx->streams[0]->codec = src_st->codec; + + if ((ret = url_open_dyn_packet_buf(&track->rtp_ctx->pb, + RTP_MAX_PACKET_SIZE)) < 0) + goto fail; + ret = av_write_header(track->rtp_ctx); + if (ret) + goto fail; + + /* Copy the RTP AVStream timebase back to the hint AVStream */ + track->timescale = track->rtp_ctx->streams[0]->time_base.den; + + /* Mark the hinted track that packets written to it should be + * sent to this track for hinting. */ + src_track->hint_track = index; + return 0; +fail: + av_log(s, AV_LOG_WARNING, + "Unable to initialize hinting of stream %d\n", src_index); + if (track->rtp_ctx && track->rtp_ctx->pb) { + uint8_t *buf; + url_close_dyn_buf(track->rtp_ctx->pb, &buf); + av_free(buf); + } + if (track->rtp_ctx && track->rtp_ctx->streams[0]) { + av_metadata_free(&track->rtp_ctx->streams[0]->metadata); + av_free(track->rtp_ctx->streams[0]); + } + if (track->rtp_ctx) { + av_metadata_free(&track->rtp_ctx->metadata); + av_free(track->rtp_ctx->priv_data); + av_freep(&track->rtp_ctx); + } + av_freep(&track->enc); + /* Set a default timescale, to avoid crashes in dump_format */ + track->timescale = 90000; + return ret; +} + +static void output_immediate(const uint8_t *data, int size, + ByteIOContext *out, int *entries) +{ + while (size > 0) { + int len = size; + if (len > 14) + len = 14; + put_byte(out, 1); /* immediate constructor */ + put_byte(out, len); /* amount of valid data */ + put_buffer(out, data, len); + data += len; + size -= len; + + for (; len < 14; len++) + put_byte(out, 0); + + (*entries)++; + } +} + +static void describe_payload(const uint8_t *data, int size, + ByteIOContext *out, int *entries) +{ + /* Describe the payload using different constructors */ + output_immediate(data, size, out, entries); +} + +/** + * Write an RTP hint (that may contain one or more RTP packets) + * for the packets in data. data contains one or more packets with a + * BE32 size header. + * + * @param out buffer where the hints are written + * @param data buffer containing RTP packets + * @param size the size of the data buffer + * @param trk the MOVTrack for the hint track + * @param pts pointer where the timestamp for the written RTP hint is stored + * @return the number of RTP packets in the written hint + */ +static int write_hint_packets(ByteIOContext *out, const uint8_t *data, + int size, MOVTrack *trk, int64_t *pts) +{ + int64_t curpos; + int64_t count_pos, entries_pos; + int count = 0, entries; + + count_pos = url_ftell(out); + /* RTPsample header */ + put_be16(out, 0); /* packet count */ + put_be16(out, 0); /* reserved */ + + while (size > 4) { + uint32_t packet_len = AV_RB32(data); + uint16_t seq; + uint32_t ts; + + data += 4; + size -= 4; + if (packet_len > size || packet_len <= 12) + break; + if (data[1] >= 200 && data[1] <= 204) { + /* RTCP packet, just skip */ + data += packet_len; + size -= packet_len; + continue; + } + + if (packet_len > trk->max_packet_size) + trk->max_packet_size = packet_len; + + seq = AV_RB16(&data[2]); + ts = AV_RB32(&data[4]); + + if (trk->prev_rtp_ts == 0) + trk->prev_rtp_ts = ts; + /* Unwrap the 32-bit RTP timestamp that wraps around often + * into a not (as often) wrapping 64-bit timestamp. */ + trk->cur_rtp_ts_unwrapped += (int32_t) (ts - trk->prev_rtp_ts); + trk->prev_rtp_ts = ts; + if (*pts == AV_NOPTS_VALUE) + *pts = trk->cur_rtp_ts_unwrapped; + + count++; + /* RTPpacket header */ + put_be32(out, 0); /* relative_time */ + put_buffer(out, data, 2); /* RTP header */ + put_be16(out, seq); /* RTPsequenceseed */ + put_be16(out, 0); /* reserved + flags */ + entries_pos = url_ftell(out); + put_be16(out, 0); /* entry count */ + + data += 12; + size -= 12; + packet_len -= 12; + + entries = 0; + /* Write one or more constructors describing the payload data */ + describe_payload(data, packet_len, out, &entries); + data += packet_len; + size -= packet_len; + + curpos = url_ftell(out); + url_fseek(out, entries_pos, SEEK_SET); + put_be16(out, entries); + url_fseek(out, curpos, SEEK_SET); + } + + curpos = url_ftell(out); + url_fseek(out, count_pos, SEEK_SET); + put_be16(out, count); + url_fseek(out, curpos, SEEK_SET); + return count; +} + +int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, + int track_index, int sample) +{ + MOVMuxContext *mov = s->priv_data; + MOVTrack *trk = &mov->tracks[track_index]; + AVFormatContext *rtp_ctx = trk->rtp_ctx; + uint8_t *buf = NULL; + int size; + ByteIOContext *hintbuf = NULL; + AVPacket hint_pkt; + AVPacket local_pkt; + int ret = 0, count; + + if (!rtp_ctx) + return AVERROR(ENOENT); + if (!rtp_ctx->pb) + return AVERROR(ENOMEM); + + /* Feed the packet to the RTP muxer */ + local_pkt = *pkt; + local_pkt.stream_index = 0; + local_pkt.pts = av_rescale_q(pkt->pts, + s->streams[pkt->stream_index]->time_base, + rtp_ctx->streams[0]->time_base); + local_pkt.dts = av_rescale_q(pkt->dts, + s->streams[pkt->stream_index]->time_base, + rtp_ctx->streams[0]->time_base); + av_write_frame(rtp_ctx, &local_pkt); + + /* Fetch the output from the RTP muxer, open a new output buffer + * for next time. */ + size = url_close_dyn_buf(rtp_ctx->pb, &buf); + if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, + RTP_MAX_PACKET_SIZE)) < 0) + goto done; + + if (size <= 0) + goto done; + + /* Open a buffer for writing the hint */ + if ((ret = url_open_dyn_buf(&hintbuf)) < 0) + goto done; + av_init_packet(&hint_pkt); + count = write_hint_packets(hintbuf, buf, size, trk, &hint_pkt.dts); + av_freep(&buf); + + /* Write the hint data into the hint track */ + hint_pkt.size = size = url_close_dyn_buf(hintbuf, &buf); + hint_pkt.data = buf; + hint_pkt.pts = hint_pkt.dts; + hint_pkt.stream_index = track_index; + if (pkt->flags & AV_PKT_FLAG_KEY) + hint_pkt.flags |= AV_PKT_FLAG_KEY; + if (count > 0) + ff_mov_write_packet(s, &hint_pkt); +done: + av_free(buf); + return ret; +} + +void ff_mov_close_hinting(MOVTrack *track) { + AVFormatContext* rtp_ctx = track->rtp_ctx; + uint8_t *ptr; + + av_freep(&track->enc); + if (!rtp_ctx) + return; + if (rtp_ctx->pb) { + av_write_trailer(rtp_ctx); + url_close_dyn_buf(rtp_ctx->pb, &ptr); + av_free(ptr); + } + av_metadata_free(&rtp_ctx->streams[0]->metadata); + av_metadata_free(&rtp_ctx->metadata); + av_free(rtp_ctx->streams[0]); + av_freep(&rtp_ctx); +} + From 1dea5cfbb07d89b26a1a530779079e268a72c3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:46:52 +0000 Subject: [PATCH 047/301] Use a heuristic for describing the RTP packets using sample data backport r23165 by mstorsjo Originally committed as revision 23238 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/movenc.h | 16 +++ libavformat/movenchint.c | 216 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 230 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 3d8f4ba499..182c5edc8c 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -51,6 +51,20 @@ typedef struct MOVIentry { uint32_t flags; } MOVIentry; +typedef struct HintSample { + uint8_t *data; + int size; + int sample_number; + int offset; + int own_data; +} HintSample; + +typedef struct { + int size; + int len; + HintSample *samples; +} HintSampleQueue; + typedef struct MOVIndex { int mode; int entry; @@ -82,6 +96,8 @@ typedef struct MOVIndex { uint32_t prev_rtp_ts; int64_t cur_rtp_ts_unwrapped; uint32_t max_packet_size; + + HintSampleQueue sample_queue; } MOVTrack; typedef struct MOVMuxContext { diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index e830b741a8..d90ac67911 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -98,6 +98,188 @@ fail: return ret; } +/** + * Remove the first sample from the sample queue. + */ +static void sample_queue_pop(HintSampleQueue *queue) +{ + if (queue->len <= 0) + return; + if (queue->samples[0].own_data) + av_free(queue->samples[0].data); + queue->len--; + memmove(queue->samples, queue->samples + 1, sizeof(HintSample)*queue->len); +} + +/** + * Empty the sample queue, releasing all memory. + */ +static void sample_queue_free(HintSampleQueue *queue) +{ + int i; + for (i = 0; i < queue->len; i++) + if (queue->samples[i].own_data) + av_free(queue->samples[i].data); + av_freep(&queue->samples); + queue->len = 0; + queue->size = 0; +} + +/** + * Add a reference to the sample data to the sample queue. The data is + * not copied. sample_queue_retain should be called before pkt->data + * is reused/freed. + */ +static void sample_queue_push(HintSampleQueue *queue, AVPacket *pkt, int sample) +{ + /* No need to keep track of smaller samples, since describing them + * with immediates is more efficient. */ + if (pkt->size <= 14) + return; + if (!queue->samples || queue->len >= queue->size) { + HintSample* samples; + queue->size += 10; + samples = av_realloc(queue->samples, sizeof(HintSample)*queue->size); + if (!samples) + return; + queue->samples = samples; + } + queue->samples[queue->len].data = pkt->data; + queue->samples[queue->len].size = pkt->size; + queue->samples[queue->len].sample_number = sample; + queue->samples[queue->len].offset = 0; + queue->samples[queue->len].own_data = 0; + queue->len++; +} + +/** + * Make local copies of all referenced sample data in the queue. + */ +static void sample_queue_retain(HintSampleQueue *queue) +{ + int i; + for (i = 0; i < queue->len; ) { + HintSample *sample = &queue->samples[i]; + if (!sample->own_data) { + uint8_t* ptr = av_malloc(sample->size); + if (!ptr) { + /* Unable to allocate memory for this one, remove it */ + memmove(queue->samples + i, queue->samples + i + 1, + sizeof(HintSample)*(queue->len - i - 1)); + queue->len--; + continue; + } + memcpy(ptr, sample->data, sample->size); + sample->data = ptr; + sample->own_data = 1; + } + i++; + } +} + +/** + * Find matches of needle[n_pos ->] within haystack. If a sufficiently + * large match is found, matching bytes before n_pos are included + * in the match, too (within the limits of the arrays). + * + * @param haystack buffer that may contain parts of needle + * @param h_len length of the haystack buffer + * @param needle buffer containing source data that have been used to + * construct haystack + * @param n_pos start position in needle used for looking for matches + * @param n_len length of the needle buffer + * @param match_h_offset_ptr offset of the first matching byte within haystack + * @param match_n_offset_ptr offset of the first matching byte within needle + * @param match_len_ptr length of the matched segment + * @return 0 if a match was found, < 0 if no match was found + */ +static int match_segments(const uint8_t *haystack, int h_len, + const uint8_t *needle, int n_pos, int n_len, + int *match_h_offset_ptr, int *match_n_offset_ptr, + int *match_len_ptr) +{ + int h_pos; + for (h_pos = 0; h_pos < h_len; h_pos++) { + int match_len = 0; + int match_h_pos, match_n_pos; + + /* Check how many bytes match at needle[n_pos] and haystack[h_pos] */ + while (h_pos + match_len < h_len && n_pos + match_len < n_len && + needle[n_pos + match_len] == haystack[h_pos + match_len]) + match_len++; + if (match_len <= 8) + continue; + + /* If a sufficiently large match was found, try to expand + * the matched segment backwards. */ + match_h_pos = h_pos; + match_n_pos = n_pos; + while (match_n_pos > 0 && match_h_pos > 0 && + needle[match_n_pos - 1] == haystack[match_h_pos - 1]) { + match_n_pos--; + match_h_pos--; + match_len++; + } + if (match_len <= 14) + continue; + *match_h_offset_ptr = match_h_pos; + *match_n_offset_ptr = match_n_pos; + *match_len_ptr = match_len; + return 0; + } + return -1; +} + +/** + * Look for segments in samples in the sample queue matching the data + * in ptr. Samples not matching are removed from the queue. If a match + * is found, the next time it will look for matches starting from the + * end of the previous matched segment. + * + * @param data data to find matches for in the sample queue + * @param len length of the data buffer + * @param queue samples used for looking for matching segments + * @param pos the offset in data of the matched segment + * @param match_sample the number of the sample that contained the match + * @param match_offset the offset of the matched segment within the sample + * @param match_len the length of the matched segment + * @return 0 if a match was found, < 0 if no match was found + */ +static int find_sample_match(const uint8_t *data, int len, + HintSampleQueue *queue, int *pos, + int *match_sample, int *match_offset, + int *match_len) +{ + while (queue->len > 0) { + HintSample *sample = &queue->samples[0]; + /* If looking for matches in a new sample, skip the first 5 bytes, + * since they often may be modified/removed in the output packet. */ + if (sample->offset == 0 && sample->size > 5) + sample->offset = 5; + + if (match_segments(data, len, sample->data, sample->offset, + sample->size, pos, match_offset, match_len) == 0) { + *match_sample = sample->sample_number; + /* Next time, look for matches at this offset, with a little + * margin to this match. */ + sample->offset = *match_offset + *match_len + 5; + if (sample->offset + 10 >= sample->size) + sample_queue_pop(queue); /* Not enough useful data left */ + return 0; + } + + if (sample->offset < 10 && sample->size > 20) { + /* No match found from the start of the sample, + * try from the middle of the sample instead. */ + sample->offset = sample->size/2; + } else { + /* No match for this sample, remove it */ + sample_queue_pop(queue); + } + } + return -1; +} + static void output_immediate(const uint8_t *data, int size, ByteIOContext *out, int *entries) { @@ -118,10 +300,36 @@ static void output_immediate(const uint8_t *data, int size, } } +static void output_match(ByteIOContext *out, int match_sample, + int match_offset, int match_len, int *entries) +{ + put_byte(out, 2); /* sample constructor */ + put_byte(out, 0); /* track reference */ + put_be16(out, match_len); + put_be32(out, match_sample); + put_be32(out, match_offset); + put_be16(out, 1); /* bytes per block */ + put_be16(out, 1); /* samples per block */ + (*entries)++; +} + static void describe_payload(const uint8_t *data, int size, - ByteIOContext *out, int *entries) + ByteIOContext *out, int *entries, + HintSampleQueue *queue) { /* Describe the payload using different constructors */ + while (size > 0) { + int match_sample, match_offset, match_len, pos; + if (find_sample_match(data, size, queue, &pos, &match_sample, + &match_offset, &match_len) < 0) + break; + output_immediate(data, pos, out, entries); + data += pos; + size -= pos; + output_match(out, match_sample, match_offset, match_len, entries); + data += match_len; + size -= match_len; + } output_immediate(data, size, out, entries); } @@ -195,7 +403,7 @@ static int write_hint_packets(ByteIOContext *out, const uint8_t *data, entries = 0; /* Write one or more constructors describing the payload data */ - describe_payload(data, packet_len, out, &entries); + describe_payload(data, packet_len, out, &entries, &trk->sample_queue); data += packet_len; size -= packet_len; @@ -230,6 +438,8 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, if (!rtp_ctx->pb) return AVERROR(ENOMEM); + sample_queue_push(&trk->sample_queue, pkt, sample); + /* Feed the packet to the RTP muxer */ local_pkt = *pkt; local_pkt.stream_index = 0; @@ -269,6 +479,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, ff_mov_write_packet(s, &hint_pkt); done: av_free(buf); + sample_queue_retain(&trk->sample_queue); return ret; } @@ -277,6 +488,7 @@ void ff_mov_close_hinting(MOVTrack *track) { uint8_t *ptr; av_freep(&track->enc); + sample_queue_free(&track->sample_queue); if (!rtp_ctx) return; if (rtp_ctx->pb) { From 15b20ef6f98fe7e0b10ff0ee3b046e807ff837e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:47:48 +0000 Subject: [PATCH 048/301] Add a changelog entry for the RTP hinting in the mov muxer backport r23178 by mstorsjo Originally committed as revision 23239 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index 218f6cf690..a2dbdce936 100644 --- a/Changelog +++ b/Changelog @@ -70,6 +70,7 @@ version 0.6: - Psygnosis YOP demuxer and video decoder - spectral extension support in the E-AC-3 decoder - unsharp video filter +- RTP hinting in the mov/3gp/mp4 muxer From c9b841c2b14f8bfdbda23bfb0cf0beda7de331e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:48:17 +0000 Subject: [PATCH 049/301] Late bump of the minor version, for the addition of AVFMT_FLAG_RTP_HINT backport r23179 by mstorsjo Originally committed as revision 23240 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/avformat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index cd164a3d73..3b77b2d121 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,7 +22,7 @@ #define AVFORMAT_AVFORMAT_H #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 62 +#define LIBAVFORMAT_VERSION_MINOR 63 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ From f8a6c707a59c6ada21d76c9055fdc0df5e2ae9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:49:28 +0000 Subject: [PATCH 050/301] Add an APIchanges note regarding the new rtp hinting flag backport r23180 by mstorsjo Originally committed as revision 23241 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- doc/APIchanges | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index eb1a93b32e..d521b59e29 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,9 @@ libavutil: 2009-03-08 API changes, most recent first: +2010-05-18 - r23161 - lavf 52.63.0 - AVFMT_FLAG_RTP_HINT + Add AVFMT_FLAG_RTP_HINT as possible value for AVFormatContext.flags + 2010-05-01 - r23002 - lavf 52.62.0 - probe function Add av_probe_input_format2 to API, it allows ignoring probe results below given score and returns the actual probe score. From 28631e9393fd8cf55e6f1fca1a6676a8d6755b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 21 May 2010 21:50:07 +0000 Subject: [PATCH 051/301] Mention RTP hinting in the 0.6 release notes Originally committed as revision 23242 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE b/RELEASE index 54f074f23c..c3857fafdc 100644 --- a/RELEASE +++ b/RELEASE @@ -75,6 +75,7 @@ Added Codecs: - HE-AAC v1 decoder - Kega Game Video (KGV1) decoder - Psygnosis YOP demuxer and video decoder +- RTP hinting in the mov/3gp/mp4 muxer Notable license related changes From a22222dadb6353410d50053f97cafb34eb4121fb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 23 May 2010 18:50:15 +0000 Subject: [PATCH 052/301] Open 2-pass logfile in binary mode for both reading and writing. This fixes a regression on Windows introduced by r22769 in which the data read from the file was not properly zero terminated. The file was read as text, which caused the \r characters to be suppressed. Since the zero termination happens at the end of the buffer, and there was one byte less read per line, this caused the remaining space on the buffer to contain random data. backport r23251 by ramiro Originally committed as revision 23261 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- cmdutils.c | 2 +- ffmpeg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 80917c3a19..2349b7052e 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -641,7 +641,7 @@ int read_yesno(void) int read_file(const char *filename, char **bufptr, size_t *size) { - FILE *f = fopen(filename, "r"); + FILE *f = fopen(filename, "rb"); if (!f) { fprintf(stderr, "Cannot read file '%s': %s\n", filename, strerror(errno)); diff --git a/ffmpeg.c b/ffmpeg.c index 66c80396ce..67b7a51e65 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2093,7 +2093,7 @@ static int av_transcode(AVFormatContext **output_files, pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { - f = fopen(logfilename, "w"); + f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); av_exit(1); From 327afd42b4016066f90e4a295b6ffbc2353a135c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 23 May 2010 19:12:27 +0000 Subject: [PATCH 053/301] In ogg muxer, pack multiple frames into one page, much lower overhead backport r23231 by bcoudurier Originally committed as revision 23263 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/oggenc.c | 274 ++++++++++++++++++++++++------------ tests/ref/lavf/ogg | 4 +- tests/ref/seek/lavf.ogg.ref | 39 ++--- 3 files changed, 196 insertions(+), 121 deletions(-) diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 36ea21cd41..70264a4383 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -27,6 +27,18 @@ #include "internal.h" #include "vorbiscomment.h" +#define MAX_PAGE_SIZE 65025 + +typedef struct { + int64_t granule; + int stream_index; + uint8_t flags; + uint8_t segments_count; + uint8_t segments[255]; + uint8_t data[MAX_PAGE_SIZE]; + uint16_t size; +} OGGPage; + typedef struct { int64_t duration; unsigned page_counter; @@ -37,9 +49,19 @@ typedef struct { int64_t last_kf_pts; int vrev; int eos; - unsigned packet_count; ///< number of packet buffered + unsigned page_count; ///< number of page buffered + OGGPage page; ///< current page } OGGStreamContext; +typedef struct OGGPageList { + OGGPage page; + struct OGGPageList *next; +} OGGPageList; + +typedef struct { + OGGPageList *page_list; +} OGGContext; + static void ogg_update_checksum(AVFormatContext *s, int64_t crc_offset) { int64_t pos = url_ftell(s->pb); @@ -49,39 +71,122 @@ static void ogg_update_checksum(AVFormatContext *s, int64_t crc_offset) url_fseek(s->pb, pos, SEEK_SET); } -static int ogg_write_page(AVFormatContext *s, const uint8_t *data, int size, - int64_t granule, int stream_index, int flags) +static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) { - OGGStreamContext *oggstream = s->streams[stream_index]->priv_data; + OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data; int64_t crc_offset; - int page_segments, i; - - if (size >= 255*255) { - granule = -1; - size = 255*255; - } else if (oggstream->eos) - flags |= 4; - - page_segments = FFMIN(size/255 + 1, 255); init_checksum(s->pb, ff_crc04C11DB7_update, 0); put_tag(s->pb, "OggS"); put_byte(s->pb, 0); - put_byte(s->pb, flags); - put_le64(s->pb, granule); - put_le32(s->pb, stream_index); + put_byte(s->pb, page->flags | extra_flags); + put_le64(s->pb, page->granule); + put_le32(s->pb, page->stream_index); put_le32(s->pb, oggstream->page_counter++); crc_offset = url_ftell(s->pb); put_le32(s->pb, 0); // crc - put_byte(s->pb, page_segments); - for (i = 0; i < page_segments-1; i++) - put_byte(s->pb, 255); - put_byte(s->pb, size - (page_segments-1)*255); - put_buffer(s->pb, data, size); + put_byte(s->pb, page->segments_count); + put_buffer(s->pb, page->segments, page->segments_count); + put_buffer(s->pb, page->data, page->size); ogg_update_checksum(s, crc_offset); put_flush_packet(s->pb); - return size; + oggstream->page_count--; +} + +static int64_t ogg_granule_to_timestamp(OGGStreamContext *oggstream, OGGPage *page) +{ + if (oggstream->kfgshift) + return (page->granule>>oggstream->kfgshift) + + (page->granule & ((1<kfgshift)-1)); + else + return page->granule; +} + +static int ogg_compare_granule(AVFormatContext *s, OGGPage *next, OGGPage *page) +{ + AVStream *st2 = s->streams[next->stream_index]; + AVStream *st = s->streams[page->stream_index]; + int64_t next_granule, cur_granule; + + if (next->granule == -1 || page->granule == -1) + return 0; + + next_granule = av_rescale_q(ogg_granule_to_timestamp(st2->priv_data, next), + st2->time_base, AV_TIME_BASE_Q); + cur_granule = av_rescale_q(ogg_granule_to_timestamp(st->priv_data, page), + st ->time_base, AV_TIME_BASE_Q); + return next_granule > cur_granule; +} + +static int ogg_reset_cur_page(OGGStreamContext *oggstream) +{ + oggstream->page.granule = -1; + oggstream->page.flags = 0; + oggstream->page.segments_count = 0; + oggstream->page.size = 0; + return 0; +} + +static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream) +{ + OGGContext *ogg = s->priv_data; + OGGPageList **p = &ogg->page_list; + OGGPageList *l = av_mallocz(sizeof(*l)); + + if (!l) + return AVERROR(ENOMEM); + l->page = oggstream->page; + + oggstream->page_count++; + ogg_reset_cur_page(oggstream); + + while (*p) { + if (ogg_compare_granule(s, &(*p)->page, &l->page)) + break; + p = &(*p)->next; + } + l->next = *p; + *p = l; + + return 0; +} + +static int ogg_buffer_data(AVFormatContext *s, AVStream *st, + uint8_t *data, unsigned size, int64_t granule) +{ + OGGStreamContext *oggstream = st->priv_data; + int total_segments = size / 255 + 1; + uint8_t *p = data; + int i, segments, len; + + for (i = 0; i < total_segments; ) { + OGGPage *page = &oggstream->page; + + segments = FFMIN(total_segments - i, 255 - page->segments_count); + + if (i && !page->segments_count) + page->flags |= 1; // continued packet + + memset(page->segments+page->segments_count, 255, segments - 1); + page->segments_count += segments - 1; + + len = FFMIN(size, segments*255); + page->segments[page->segments_count++] = len - (segments-1)*255; + memcpy(page->data+page->size, p, len); + p += len; + size -= len; + i += segments; + page->size += len; + + if (i == total_segments) + page->granule = granule; + + if (page->segments_count == 255) { + ogg_buffer_page(s, oggstream); + } + } + return 0; } static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact, @@ -195,6 +300,7 @@ static int ogg_write_header(AVFormatContext *s) return -1; } oggstream = av_mallocz(sizeof(*oggstream)); + oggstream->page.stream_index = i; st->priv_data = oggstream; if (st->codec->codec_id == CODEC_ID_FLAC) { int err = ogg_build_flac_headers(st->codec, oggstream, @@ -232,25 +338,54 @@ static int ogg_write_header(AVFormatContext *s) } } } - for (i = 0; i < 3; i++) { - for (j = 0; j < s->nb_streams; j++) { - AVStream *st = s->streams[j]; - OGGStreamContext *oggstream = st->priv_data; - if (oggstream && oggstream->header_len[i]) { - ogg_write_page(s, oggstream->header[i], oggstream->header_len[i], - 0, st->index, i ? 0 : 2); // bos - } + + for (j = 0; j < s->nb_streams; j++) { + OGGStreamContext *oggstream = s->streams[j]->priv_data; + ogg_buffer_data(s, s->streams[j], oggstream->header[0], + oggstream->header_len[0], 0); + oggstream->page.flags |= 2; // bos + ogg_buffer_page(s, oggstream); + } + for (j = 0; j < s->nb_streams; j++) { + AVStream *st = s->streams[j]; + OGGStreamContext *oggstream = st->priv_data; + for (i = 1; i < 3; i++) { + if (oggstream && oggstream->header_len[i]) + ogg_buffer_data(s, st, oggstream->header[i], + oggstream->header_len[i], 0); } + ogg_buffer_page(s, oggstream); } return 0; } +static void ogg_write_pages(AVFormatContext *s, int flush) +{ + OGGContext *ogg = s->priv_data; + OGGPageList *next, *p; + + if (!ogg->page_list) + return; + + for (p = ogg->page_list; p; ) { + OGGStreamContext *oggstream = + s->streams[p->page.stream_index]->priv_data; + if (oggstream->page_count < 2 && !flush) + break; + ogg_write_page(s, &p->page, + flush && oggstream->page_count == 1 ? 4 : 0); // eos + next = p->next; + av_freep(&p); + p = next; + } + ogg->page_list = p; +} + static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt) { AVStream *st = s->streams[pkt->stream_index]; OGGStreamContext *oggstream = st->priv_data; - uint8_t *ptr = pkt->data; - int ret, size = pkt->size; + int ret; int64_t granule; if (st->codec->codec_id == CODEC_ID_THEORA) { @@ -268,72 +403,26 @@ static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt) } else granule = pkt->pts + pkt->duration; oggstream->duration = granule; - do { - ret = ogg_write_page(s, ptr, size, granule, pkt->stream_index, ptr != pkt->data); - ptr += ret; size -= ret; - } while (size > 0 || ret == 255*255); // need to output a last nil page + + ret = ogg_buffer_data(s, st, pkt->data, pkt->size, granule); + if (ret < 0) + return ret; + + ogg_write_pages(s, 0); return 0; } -static int ogg_compare_granule(AVFormatContext *s, AVPacket *next, AVPacket *pkt) -{ - AVStream *st2 = s->streams[next->stream_index]; - AVStream *st = s->streams[pkt ->stream_index]; - - int64_t next_granule = av_rescale_q(next->pts + next->duration, - st2->time_base, AV_TIME_BASE_Q); - int64_t cur_granule = av_rescale_q(pkt ->pts + pkt ->duration, - st ->time_base, AV_TIME_BASE_Q); - return next_granule > cur_granule; -} - -static int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) -{ - OGGStreamContext *ogg; - int i, stream_count = 0; - int interleaved = 0; - - if (pkt) { - ff_interleave_add_packet(s, pkt, ogg_compare_granule); - ogg = s->streams[pkt->stream_index]->priv_data; - ogg->packet_count++; - } - - for (i = 0; i < s->nb_streams; i++) { - ogg = s->streams[i]->priv_data; - stream_count += !!ogg->packet_count; - interleaved += ogg->packet_count > 1; - } - - if ((s->nb_streams == stream_count && interleaved == stream_count) || - (flush && stream_count)) { - AVPacketList *pktl= s->packet_buffer; - *out= pktl->pkt; - s->packet_buffer = pktl->next; - - ogg = s->streams[out->stream_index]->priv_data; - if (flush && ogg->packet_count == 1) - ogg->eos = 1; - ogg->packet_count--; - - if(!s->packet_buffer) - s->packet_buffer_end= NULL; - - if(s->streams[out->stream_index]->last_in_packet_buffer == pktl) - s->streams[out->stream_index]->last_in_packet_buffer= NULL; - - av_freep(&pktl); - return 1; - } else { - av_init_packet(out); - return 0; - } -} - static int ogg_write_trailer(AVFormatContext *s) { int i; + + /* flush current page */ + for (i = 0; i < s->nb_streams; i++) + ogg_buffer_page(s, s->streams[i]->priv_data); + + ogg_write_pages(s, 1); + for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; OGGStreamContext *oggstream = st->priv_data; @@ -352,12 +441,11 @@ AVOutputFormat ogg_muxer = { NULL_IF_CONFIG_SMALL("Ogg"), "application/ogg", "ogg,ogv,spx", - 0, + sizeof(OGGContext), CODEC_ID_FLAC, CODEC_ID_THEORA, ogg_write_header, ogg_write_packet, ogg_write_trailer, - .interleave_packet = ogg_interleave_per_granule, .metadata_conv = ff_vorbiscomment_metadata_conv, }; diff --git a/tests/ref/lavf/ogg b/tests/ref/lavf/ogg index d6eb447cc5..eb96fd92c0 100644 --- a/tests/ref/lavf/ogg +++ b/tests/ref/lavf/ogg @@ -1,3 +1,3 @@ -89faca973d88ff2f5dd20992a11de107 *./tests/data/lavf/lavf.ogg -14063 ./tests/data/lavf/lavf.ogg +364714f1087f3c1320b60f4209191d23 *./tests/data/lavf/lavf.ogg +13820 ./tests/data/lavf/lavf.ogg ./tests/data/lavf/lavf.ogg CRC=0xf1ae5536 diff --git a/tests/ref/seek/lavf.ogg.ref b/tests/ref/seek/lavf.ogg.ref index 0c49d89b6a..c9be9c68bb 100644 --- a/tests/ref/seek/lavf.ogg.ref +++ b/tests/ref/seek/lavf.ogg.ref @@ -1,40 +1,27 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 125 size: 1364 -ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 4353 size: 1382 +ret:-1 st:-1 flags:0 ts:-1.000000 ret:-1 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:0 ts: 0.788345 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 11410 size: 1365 -ret: 0 st: 0 flags:1 ts:-0.317506 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 1522 size: 1381 +ret:-1 st: 0 flags:0 ts: 0.788345 +ret:-1 st: 0 flags:1 ts:-0.317506 ret:-1 st:-1 flags:0 ts: 2.576668 ret:-1 st:-1 flags:1 ts: 1.470835 -ret: 0 st: 0 flags:0 ts: 0.365011 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 7191 size: 1370 -ret: 0 st: 0 flags:1 ts:-0.740839 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 1522 size: 1381 +ret:-1 st: 0 flags:0 ts: 0.365011 +ret:-1 st: 0 flags:1 ts:-0.740839 ret:-1 st:-1 flags:0 ts: 2.153336 ret:-1 st:-1 flags:1 ts: 1.047503 -ret: 0 st: 0 flags:0 ts:-0.058322 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 4353 size: 1382 +ret:-1 st: 0 flags:0 ts:-0.058322 ret:-1 st: 0 flags:1 ts: 2.835828 ret:-1 st:-1 flags:0 ts: 1.730004 -ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 5768 size: 1390 -ret: 0 st: 0 flags:0 ts:-0.481655 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 4353 size: 1382 +ret:-1 st:-1 flags:1 ts: 0.624171 +ret:-1 st: 0 flags:0 ts:-0.481655 ret:-1 st: 0 flags:1 ts: 2.412494 ret:-1 st:-1 flags:0 ts: 1.306672 -ret: 0 st:-1 flags:1 ts: 0.200839 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 1522 size: 1381 -ret: 0 st: 0 flags:0 ts:-0.904989 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 4353 size: 1382 +ret:-1 st:-1 flags:1 ts: 0.200839 +ret:-1 st: 0 flags:0 ts:-0.904989 ret:-1 st: 0 flags:1 ts: 1.989184 ret:-1 st:-1 flags:0 ts: 0.883340 -ret: 0 st:-1 flags:1 ts:-0.222493 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 1522 size: 1381 +ret:-1 st:-1 flags:1 ts:-0.222493 ret:-1 st: 0 flags:0 ts: 2.671678 ret:-1 st: 0 flags:1 ts: 1.565850 -ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 8594 size: 1381 -ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: NOPTS pts: NOPTS pos: 1522 size: 1381 +ret:-1 st:-1 flags:0 ts: 0.460008 +ret:-1 st:-1 flags:1 ts:-0.645825 From 4a7c99d6f315c8fb07a839d3d3727fe69fc9cb25 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 23 May 2010 21:30:21 +0000 Subject: [PATCH 054/301] small spelling fixes Originally committed as revision 23271 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE b/RELEASE index c3857fafdc..837d16cb9a 100644 --- a/RELEASE +++ b/RELEASE @@ -1,7 +1,7 @@ Release Notes ============= -* 0.6 "Works with HTML5" May, 2010 +* 0.6 "Works with HTML 5" May, 2010 General notes ------------- @@ -19,9 +19,9 @@ guidelines. API and other notable Changes ----------------------------- -Please see the file doc/APIchanges for programmer centric information +Please see the file doc/APIchanges for programmer-centric information. -Notably changes: +Notable changes: - deprecated vhook subsystem removed - deprecated old scaler removed - nonfree libamr support for AMR-NB/WB decoding/encoding removed From 36edfb558b0e9c83a0e37608c51f33935b067bd0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 23 May 2010 22:07:22 +0000 Subject: [PATCH 055/301] Add VERSION file for 0.6 release. Originally committed as revision 23274 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..5a2a5806df --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.6 From fb2fc3a4f0bb207a682d473c9d299fe599769a4f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 23 May 2010 23:28:24 +0000 Subject: [PATCH 056/301] Merge last round of Changelog updates for HTML 5 features. Originally committed as revision 23278 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Changelog b/Changelog index a2dbdce936..09587f8670 100644 --- a/Changelog +++ b/Changelog @@ -71,6 +71,13 @@ version 0.6: - spectral extension support in the E-AC-3 decoder - unsharp video filter - RTP hinting in the mov/3gp/mp4 muxer +- Dirac in Ogg demuxing +- seek to keyframes in Ogg +- 4:2:2 and 4:4:4 Theora decoding +- 35% faster VP3/Theora decoding +- faster AAC decoding +- faster H.264 decoding +- low overhead Ogg muxing From 49aa53f2d7830e349ee6e0a1d83763ebf3f44cee Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 24 May 2010 01:33:39 +0000 Subject: [PATCH 057/301] Ignore generated files in the libswscale directory. Originally committed as revision 23281 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 From a2a26d108b9ef0689493387c7058032e4245b74d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 24 May 2010 02:09:36 +0000 Subject: [PATCH 058/301] Enable AVFMT_GENERIC_INDEX for Ogg demuxer. This avoids the many seeks needed for binary search when seeking to a previously seen location. backport r23279 by reimar Originally committed as revision 23282 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/oggdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f24f697ada..3161e68c6c 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -642,4 +642,5 @@ AVInputFormat ogg_demuxer = { ogg_read_timestamp, .extensions = "ogg", .metadata_conv = ff_vorbiscomment_metadata_conv, + .flags = AVFMT_GENERIC_INDEX, }; From 0b374e40b1df87d21c6870e998849dd51027c637 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 24 May 2010 02:27:43 +0000 Subject: [PATCH 059/301] Convert NaN to 0/0 in av_d2q This fixes aspect ratio calculation for encoding from files with 0/0 stored, common with ogg/theora backport r23280 by conrad Originally committed as revision 23283 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/rational.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavutil/rational.c b/libavutil/rational.c index 3217b7daeb..3e8b885d49 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -98,6 +98,8 @@ AVRational av_d2q(double d, int max){ #define LOG2 0.69314718055994530941723212145817656807550013436025 int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); int64_t den= 1LL << (61 - exponent); + if (isnan(d)) + return (AVRational){0,0}; av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); return a; From 9d3bb3501de9c9221c90a5ef22ba899e29fbd231 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 25 May 2010 18:20:59 +0000 Subject: [PATCH 060/301] matroskadec: Support webm doctype Patch by James Zern backport r23245 by conrad Originally committed as revision 23313 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 1 + doc/general.texi | 1 + libavformat/avformat.h | 2 +- libavformat/matroskadec.c | 29 +++++++++++++++++++++-------- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Changelog b/Changelog index 09587f8670..76f6a89a3f 100644 --- a/Changelog +++ b/Changelog @@ -78,6 +78,7 @@ version 0.6: - faster AAC decoding - faster H.264 decoding - low overhead Ogg muxing +- WebM support in Matroska demuxer diff --git a/doc/general.texi b/doc/general.texi index 1bfde02bc2..bb199f6501 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -234,6 +234,7 @@ library: @item VC-1 test bitstream @tab X @tab X @item WAV @tab X @tab X @item WavPack @tab @tab X +@item WebM @tab @tab X @item Wing Commander III movie @tab @tab X @tab Multimedia format used in Origin's Wing Commander III computer game. @item Westwood Studios audio @tab @tab X diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 3b77b2d121..48c5061d49 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,7 +22,7 @@ #define AVFORMAT_AVFORMAT_H #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 63 +#define LIBAVFORMAT_VERSION_MINOR 64 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 90356d818b..df7edac131 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -505,6 +505,8 @@ static EbmlSyntax matroska_clusters[] = { { 0 } }; +static const char *matroska_doctypes[] = { "matroska", "webm" }; + /* * Return: Whether we reached the end of a level in the hierarchy or not. */ @@ -823,8 +825,7 @@ static void ebml_free(EbmlSyntax *syntax, void *data) static int matroska_probe(AVProbeData *p) { uint64_t total = 0; - int len_mask = 0x80, size = 1, n = 1; - static const char probe_data[] = "matroska"; + int len_mask = 0x80, size = 1, n = 1, i; /* EBML header? */ if (AV_RB32(p->buf) != EBML_ID_HEADER) @@ -846,13 +847,16 @@ static int matroska_probe(AVProbeData *p) if (p->buf_size < 4 + size + total) return 0; - /* The header must contain the document type 'matroska'. For now, + /* The header should contain a known document type. For now, * we don't parse the whole header but simply check for the * availability of that array of characters inside the header. * Not fully fool-proof, but good enough. */ - for (n = 4+size; n <= 4+size+total-(sizeof(probe_data)-1); n++) - if (!memcmp(p->buf+n, probe_data, sizeof(probe_data)-1)) - return AVPROBE_SCORE_MAX; + for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) { + int probelen = strlen(matroska_doctypes[i]); + for (n = 4+size; n <= 4+size+total-probelen; n++) + if (!memcmp(p->buf+n, matroska_doctypes[i], probelen)) + return AVPROBE_SCORE_MAX; + } return 0; } @@ -1139,14 +1143,23 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) /* First read the EBML header. */ if (ebml_parse(matroska, ebml_syntax, &ebml) || ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t) - || ebml.id_length > sizeof(uint32_t) || strcmp(ebml.doctype, "matroska") - || ebml.doctype_version > 2) { + || ebml.id_length > sizeof(uint32_t) || ebml.doctype_version > 2) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML header using unsupported features\n" "(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n", ebml.version, ebml.doctype, ebml.doctype_version); + ebml_free(ebml_syntax, &ebml); return AVERROR_PATCHWELCOME; } + for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) + if (!strcmp(ebml.doctype, matroska_doctypes[i])) + break; + if (i >= FF_ARRAY_ELEMS(matroska_doctypes)) { + av_log(s, AV_LOG_ERROR, "Unknown EBML doctype '%s'\n", ebml.doctype); + ebml_free(ebml_syntax, &ebml); + return AVERROR_PATCHWELCOME; + } + av_metadata_set2(&s->metadata, "doctype", ebml.doctype, 0); ebml_free(ebml_syntax, &ebml); /* The next thing is a segment. */ From 6ae05f541a3feea250bcd2f36bbe7294b6f4049c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 25 May 2010 18:21:59 +0000 Subject: [PATCH 061/301] matroskadec: Allow unknown EBML doctype backport r23246 by conrad Originally committed as revision 23314 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/matroskadec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index df7edac131..e254a31416 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -858,7 +858,8 @@ static int matroska_probe(AVProbeData *p) return AVPROBE_SCORE_MAX; } - return 0; + // probably valid EBML header but no recognized doctype + return AVPROBE_SCORE_MAX/2; } static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska, @@ -1155,9 +1156,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!strcmp(ebml.doctype, matroska_doctypes[i])) break; if (i >= FF_ARRAY_ELEMS(matroska_doctypes)) { - av_log(s, AV_LOG_ERROR, "Unknown EBML doctype '%s'\n", ebml.doctype); - ebml_free(ebml_syntax, &ebml); - return AVERROR_PATCHWELCOME; + av_log(s, AV_LOG_WARNING, "Unknown EBML doctype '%s'\n", ebml.doctype); } av_metadata_set2(&s->metadata, "doctype", ebml.doctype, 0); ebml_free(ebml_syntax, &ebml); From b5afece6071bf1e106a7592cd33bdb344814368b Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 25 May 2010 18:22:30 +0000 Subject: [PATCH 062/301] matroskaenc: Don't write track timecode scale It's not required for mkv and unsupported in webm backport r23247 by conrad Originally committed as revision 23315 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/matroskaenc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 76c74173c5..2fa31bad0a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -544,7 +544,6 @@ static int mkv_write_tracks(AVFormatContext *s) put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER , i + 1); put_ebml_uint (pb, MATROSKA_ID_TRACKUID , i + 1); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0); // no lacing (yet) - put_ebml_float(pb, MATROSKA_ID_TRACKTIMECODESCALE, 1.0); if ((tag = av_metadata_get(st->metadata, "title", NULL, 0))) put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value); From 5f1a8c5e808b2b5f98e76fffbb6082b85e50236b Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 25 May 2010 18:33:38 +0000 Subject: [PATCH 063/301] Update regression tests after removing track timecode scale from mkvenc backport r23248 by conrad Originally committed as revision 23320 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- tests/ref/acodec/pcm | 8 ++--- tests/ref/lavf/mkv | 4 +-- tests/ref/seek/lavf.mkv.ref | 44 +++++++++++++------------- tests/ref/seek/pcm_s16be.mkv.ref | 54 ++++++++++++++++---------------- tests/ref/seek/pcm_s16le.mkv.ref | 54 ++++++++++++++++---------------- 5 files changed, 82 insertions(+), 82 deletions(-) diff --git a/tests/ref/acodec/pcm b/tests/ref/acodec/pcm index e9e3fa1610..8e344087eb 100644 --- a/tests/ref/acodec/pcm +++ b/tests/ref/acodec/pcm @@ -22,12 +22,12 @@ stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 1058444 ./tests/data/acodec/pcm_s16le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 -33c64392615a70aa1132b6f87215b8a9 *./tests/data/acodec/pcm_s16be.mkv -1060705 ./tests/data/acodec/pcm_s16be.mkv +43440f8078f2383c0dd618ad606f6830 *./tests/data/acodec/pcm_s16be.mkv + 1060693 ./tests/data/acodec/pcm_s16be.mkv 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 -ff09423d5ead01dee128b5875682de2a *./tests/data/acodec/pcm_s16le.mkv -1060705 ./tests/data/acodec/pcm_s16le.mkv +1e63166f1672b7eb00877c697c06743c *./tests/data/acodec/pcm_s16le.mkv + 1060693 ./tests/data/acodec/pcm_s16le.mkv 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 07ffe7ffb78f3648b6524debdde5aec1 *./tests/data/acodec/pcm_s24be.mov diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv index dc8dfef6d2..bcf7ff309f 100644 --- a/tests/ref/lavf/mkv +++ b/tests/ref/lavf/mkv @@ -1,3 +1,3 @@ -bd21b559633e3789a1fd00da1eb3e6a3 *./tests/data/lavf/lavf.mkv - 320487 ./tests/data/lavf/lavf.mkv +a0ce20d849aea1c6e138dd1101c8f162 *./tests/data/lavf/lavf.mkv + 320463 ./tests/data/lavf/lavf.mkv ./tests/data/lavf/lavf.mkv CRC=0x2a83e6b0 diff --git a/tests/ref/seek/lavf.mkv.ref b/tests/ref/seek/lavf.mkv.ref index fd161b0168..0cc6839a8a 100644 --- a/tests/ref/seek/lavf.mkv.ref +++ b/tests/ref/seek/lavf.mkv.ref @@ -1,53 +1,53 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291918 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291918 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st: 1 flags:0 ts: 2.577000 ret:-EOF ret: 0 st: 1 flags:1 ts: 1.471000 -ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320191 size: 209 +ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320167 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146703 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146679 size: 27925 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st: 0 flags:0 ts: 2.153000 ret:-EOF ret: 0 st: 0 flags:1 ts: 1.048000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291918 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 ret: 0 st: 1 flags:0 ts:-0.058000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st: 1 flags:1 ts: 2.836000 -ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320191 size: 209 +ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320167 size: 209 ret: 0 st:-1 flags:0 ts: 1.730004 ret:-EOF ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146703 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146679 size: 27925 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291918 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 ret: 0 st: 1 flags:0 ts: 1.307000 ret:-EOF ret: 0 st: 1 flags:1 ts: 0.201000 -ret: 0 st: 1 flags:1 dts: 0.183000 pts: 0.183000 pos: 72099 size: 209 +ret: 0 st: 1 flags:1 dts: 0.183000 pts: 0.183000 pos: 72075 size: 209 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291918 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 ret: 0 st: 0 flags:0 ts: 0.883000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291918 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 ret: 0 st: 0 flags:1 ts:-0.222000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 ret: 0 st: 1 flags:0 ts: 2.672000 ret:-EOF ret: 0 st: 1 flags:1 ts: 1.566000 -ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320191 size: 209 +ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320167 size: 209 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146703 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146679 size: 27925 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 529 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 diff --git a/tests/ref/seek/pcm_s16be.mkv.ref b/tests/ref/seek/pcm_s16be.mkv.ref index 99f3de3f19..8889c423b7 100644 --- a/tests/ref/seek/pcm_s16be.mkv.ref +++ b/tests/ref/seek/pcm_s16be.mkv.ref @@ -1,53 +1,53 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 1.881000 pts: 1.881000 pos: 332767 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.881000 pts: 1.881000 pos: 332755 size: 4096 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.789000 pts: 0.789000 pos: 139926 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.789000 pts: 0.789000 pos: 139914 size: 4096 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:0 ts: 2.576668 -ret: 0 st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos: 455857 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos: 455845 size: 4096 ret: 0 st:-1 flags:1 ts: 1.470835 -ret: 0 st: 0 flags:1 dts: 1.463000 pts: 1.463000 pos: 258913 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.463000 pts: 1.463000 pos: 258901 size: 4096 ret: 0 st: 0 flags:0 ts: 0.365000 -ret: 0 st: 0 flags:1 dts: 0.372000 pts: 0.372000 pos: 66072 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.372000 pts: 0.372000 pos: 66060 size: 4096 ret: 0 st: 0 flags:1 ts:-0.741000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:0 ts: 2.153336 -ret: 0 st: 0 flags:1 dts: 2.159000 pts: 2.159000 pos: 382003 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.159000 pts: 2.159000 pos: 381991 size: 4096 ret: 0 st:-1 flags:1 ts: 1.047503 -ret: 0 st: 0 flags:1 dts: 1.045000 pts: 1.045000 pos: 185059 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.045000 pts: 1.045000 pos: 185047 size: 4096 ret: 0 st: 0 flags:0 ts:-0.058000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:1 ts: 2.836000 -ret: 0 st: 0 flags:1 dts: 2.833000 pts: 2.833000 pos: 500990 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.833000 pts: 2.833000 pos: 500978 size: 4096 ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 0 flags:1 dts: 1.741000 pts: 1.741000 pos: 308149 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.741000 pts: 1.741000 pos: 308137 size: 4096 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.604000 pts: 0.604000 pos: 107102 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.604000 pts: 0.604000 pos: 107090 size: 4096 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 0 flags:1 dts: 2.392000 pts: 2.392000 pos: 423033 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.392000 pts: 2.392000 pos: 423021 size: 4096 ret: 0 st:-1 flags:0 ts: 1.306672 -ret: 0 st: 0 flags:1 dts: 1.324000 pts: 1.324000 pos: 234295 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.324000 pts: 1.324000 pos: 234283 size: 4096 ret: 0 st:-1 flags:1 ts: 0.200839 -ret: 0 st: 0 flags:1 dts: 0.186000 pts: 0.186000 pos: 33248 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.186000 pts: 0.186000 pos: 33236 size: 4096 ret: 0 st: 0 flags:0 ts:-0.905000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:1 ts: 1.989000 -ret: 0 st: 0 flags:1 dts: 1.974000 pts: 1.974000 pos: 349179 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.974000 pts: 1.974000 pos: 349167 size: 4096 ret: 0 st:-1 flags:0 ts: 0.883340 -ret: 0 st: 0 flags:1 dts: 0.906000 pts: 0.906000 pos: 160441 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.906000 pts: 0.906000 pos: 160429 size: 4096 ret: 0 st:-1 flags:1 ts:-0.222493 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:0 ts: 2.672000 -ret: 0 st: 0 flags:1 dts: 2.694000 pts: 2.694000 pos: 476372 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.694000 pts: 2.694000 pos: 476360 size: 4096 ret: 0 st: 0 flags:1 ts: 1.566000 -ret: 0 st: 0 flags:1 dts: 1.556000 pts: 1.556000 pos: 275325 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.556000 pts: 1.556000 pos: 275313 size: 4096 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.464000 pts: 0.464000 pos: 82484 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.464000 pts: 0.464000 pos: 82472 size: 4096 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 diff --git a/tests/ref/seek/pcm_s16le.mkv.ref b/tests/ref/seek/pcm_s16le.mkv.ref index 99f3de3f19..8889c423b7 100644 --- a/tests/ref/seek/pcm_s16le.mkv.ref +++ b/tests/ref/seek/pcm_s16le.mkv.ref @@ -1,53 +1,53 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 1.881000 pts: 1.881000 pos: 332767 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.881000 pts: 1.881000 pos: 332755 size: 4096 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.789000 pts: 0.789000 pos: 139926 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.789000 pts: 0.789000 pos: 139914 size: 4096 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:0 ts: 2.576668 -ret: 0 st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos: 455857 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos: 455845 size: 4096 ret: 0 st:-1 flags:1 ts: 1.470835 -ret: 0 st: 0 flags:1 dts: 1.463000 pts: 1.463000 pos: 258913 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.463000 pts: 1.463000 pos: 258901 size: 4096 ret: 0 st: 0 flags:0 ts: 0.365000 -ret: 0 st: 0 flags:1 dts: 0.372000 pts: 0.372000 pos: 66072 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.372000 pts: 0.372000 pos: 66060 size: 4096 ret: 0 st: 0 flags:1 ts:-0.741000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st:-1 flags:0 ts: 2.153336 -ret: 0 st: 0 flags:1 dts: 2.159000 pts: 2.159000 pos: 382003 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.159000 pts: 2.159000 pos: 381991 size: 4096 ret: 0 st:-1 flags:1 ts: 1.047503 -ret: 0 st: 0 flags:1 dts: 1.045000 pts: 1.045000 pos: 185059 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.045000 pts: 1.045000 pos: 185047 size: 4096 ret: 0 st: 0 flags:0 ts:-0.058000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:1 ts: 2.836000 -ret: 0 st: 0 flags:1 dts: 2.833000 pts: 2.833000 pos: 500990 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.833000 pts: 2.833000 pos: 500978 size: 4096 ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 0 flags:1 dts: 1.741000 pts: 1.741000 pos: 308149 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.741000 pts: 1.741000 pos: 308137 size: 4096 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.604000 pts: 0.604000 pos: 107102 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.604000 pts: 0.604000 pos: 107090 size: 4096 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 0 flags:1 dts: 2.392000 pts: 2.392000 pos: 423033 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.392000 pts: 2.392000 pos: 423021 size: 4096 ret: 0 st:-1 flags:0 ts: 1.306672 -ret: 0 st: 0 flags:1 dts: 1.324000 pts: 1.324000 pos: 234295 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.324000 pts: 1.324000 pos: 234283 size: 4096 ret: 0 st:-1 flags:1 ts: 0.200839 -ret: 0 st: 0 flags:1 dts: 0.186000 pts: 0.186000 pos: 33248 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.186000 pts: 0.186000 pos: 33236 size: 4096 ret: 0 st: 0 flags:0 ts:-0.905000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:1 ts: 1.989000 -ret: 0 st: 0 flags:1 dts: 1.974000 pts: 1.974000 pos: 349179 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.974000 pts: 1.974000 pos: 349167 size: 4096 ret: 0 st:-1 flags:0 ts: 0.883340 -ret: 0 st: 0 flags:1 dts: 0.906000 pts: 0.906000 pos: 160441 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.906000 pts: 0.906000 pos: 160429 size: 4096 ret: 0 st:-1 flags:1 ts:-0.222493 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 ret: 0 st: 0 flags:0 ts: 2.672000 -ret: 0 st: 0 flags:1 dts: 2.694000 pts: 2.694000 pos: 476372 size: 4096 +ret: 0 st: 0 flags:1 dts: 2.694000 pts: 2.694000 pos: 476360 size: 4096 ret: 0 st: 0 flags:1 ts: 1.566000 -ret: 0 st: 0 flags:1 dts: 1.556000 pts: 1.556000 pos: 275325 size: 4096 +ret: 0 st: 0 flags:1 dts: 1.556000 pts: 1.556000 pos: 275313 size: 4096 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.464000 pts: 0.464000 pos: 82484 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.464000 pts: 0.464000 pos: 82472 size: 4096 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 424 size: 4096 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 412 size: 4096 From cdfe333493f54edc4d27ac88fd31f81acdd45954 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 25 May 2010 18:34:19 +0000 Subject: [PATCH 064/301] Document CODEC_FLAG_EMU_EDGE and avcodec_align_dimensions interaction. backport r23258 by reimar Originally committed as revision 23321 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/avcodec.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c6e3b7d820..72db24642c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3303,12 +3303,20 @@ unsigned avcodec_get_edge_width(void); * Modifies width and height values so that they will result in a memory * buffer that is acceptable for the codec if you do not use any horizontal * padding. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. */ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); /** * Modifies width and height values so that they will result in a memory * buffer that is acceptable for the codec if you also ensure that all * line sizes are a multiple of the respective linesize_align[i]. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. */ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]); From 2c3439b0089f45051970689df7f75e0aa16ad5a6 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 25 May 2010 20:55:57 +0000 Subject: [PATCH 065/301] FFplay : Avoid manipulating NULL data pointers so that future checks remain valid. This fixes segfaults for those cases where data copy to this invalid pointer is attempted. backport r23264 by jai_menon Originally committed as revision 23326 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffplay.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ffplay.c b/ffplay.c index e84e290be7..4a0e42ec2f 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1593,7 +1593,9 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) unsigned hshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_w; unsigned vshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h; + if (ref->data[i]) { ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); + } pic->data[i] = ref->data[i]; pic->linesize[i] = ref->linesize[i]; } From 12ca60ec15b540586dd78c86645b394e7d5a1128 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 25 May 2010 20:56:34 +0000 Subject: [PATCH 066/301] Cosmetics : re-indent after last commit. backport r23265 by jai_menon Originally committed as revision 23327 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 4a0e42ec2f..e79e17bd24 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1594,7 +1594,7 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) unsigned vshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h; if (ref->data[i]) { - ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); + ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); } pic->data[i] = ref->data[i]; pic->linesize[i] = ref->linesize[i]; From 0078216f0746b7a683805c8305457d73e000cc4d Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 27 May 2010 20:40:09 +0000 Subject: [PATCH 067/301] change author metadata to artist in mov de/muxer backport r23266 by bcoudurier Originally committed as revision 23353 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/avformat.h | 2 +- libavformat/mov.c | 2 +- libavformat/movenc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 48c5061d49..c312d98ab8 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -23,7 +23,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 52 #define LIBAVFORMAT_VERSION_MINOR 64 -#define LIBAVFORMAT_VERSION_MICRO 0 +#define LIBAVFORMAT_VERSION_MICRO 1 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff --git a/libavformat/mov.c b/libavformat/mov.c index e37bcf5f57..2edd27e440 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -144,7 +144,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) switch (atom.type) { case MKTAG(0xa9,'n','a','m'): key = "title"; break; case MKTAG(0xa9,'a','u','t'): - case MKTAG(0xa9,'A','R','T'): key = "author"; break; + case MKTAG(0xa9,'A','R','T'): key = "artist"; break; case MKTAG(0xa9,'w','r','t'): key = "composer"; break; case MKTAG( 'c','p','r','t'): case MKTAG(0xa9,'c','p','y'): key = "copyright"; break; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 440c98ad26..f4b8e06cea 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1452,7 +1452,7 @@ static int mov_write_ilst_tag(ByteIOContext *pb, MOVMuxContext *mov, put_be32(pb, 0); /* size */ put_tag(pb, "ilst"); mov_write_string_metadata(s, pb, "\251nam", "title" , 1); - mov_write_string_metadata(s, pb, "\251ART", "author" , 1); + mov_write_string_metadata(s, pb, "\251ART", "artist" , 1); mov_write_string_metadata(s, pb, "aART", "album_artist", 1); mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1); mov_write_string_metadata(s, pb, "\251alb", "album" , 1); From 0ff244dea23e5628c71210b9e5b5ee7a1bd68f66 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 27 May 2010 20:47:03 +0000 Subject: [PATCH 068/301] write 3gp perf tag for artist metadata backport r23268 by bcoudurier Originally committed as revision 23354 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/movenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index f4b8e06cea..00f69902c4 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1579,6 +1579,7 @@ static int mov_write_udta_tag(ByteIOContext *pb, MOVMuxContext *mov, return ret; if (mov->mode & MODE_3GP) { + mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist"); mov_write_3gp_udta_tag(pb_buf, s, "titl", "title"); mov_write_3gp_udta_tag(pb_buf, s, "auth", "author"); mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre"); From 1746657479b09433dbe7f2cc243aa173ada4964b Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 27 May 2010 20:47:48 +0000 Subject: [PATCH 069/301] Fix detection of some stereo atrac files by not comparing the block size mode and info byte. backport r23272 by banan Originally committed as revision 23355 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/aea.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/aea.c b/libavformat/aea.c index 4b85f91068..6075031abe 100644 --- a/libavformat/aea.c +++ b/libavformat/aea.c @@ -46,10 +46,9 @@ static int aea_read_probe(AVProbeData *p) /* Check so that the redundant bsm bytes and info bytes are valid * the block size mode bytes have to be the same * the info bytes have to be the same - * the block size mode and info byte can't be the same */ - if (bsm_s == bsm_e && inb_s == inb_e && bsm_s != inb_s) - return AVPROBE_SCORE_MAX / 2; + if (bsm_s == bsm_e && inb_s == inb_e) + return AVPROBE_SCORE_MAX / 2 + 1; } return 0; } From 057287c9cd34c94baa0de5935104ddcccc138f93 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 27 May 2010 20:48:19 +0000 Subject: [PATCH 070/301] Reduce the score for the aea demuxer probing function. backport r23273 by banan Originally committed as revision 23356 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/aea.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/aea.c b/libavformat/aea.c index 6075031abe..518995c4b0 100644 --- a/libavformat/aea.c +++ b/libavformat/aea.c @@ -48,7 +48,7 @@ static int aea_read_probe(AVProbeData *p) * the info bytes have to be the same */ if (bsm_s == bsm_e && inb_s == inb_e) - return AVPROBE_SCORE_MAX / 2 + 1; + return AVPROBE_SCORE_MAX / 4 + 1; } return 0; } From 7920dc88024c881d4848604339c4d2d709f625c5 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 28 May 2010 20:35:13 +0000 Subject: [PATCH 071/301] matroskaenc: Write codec time base as default duration for video tracks. This isn't exactly semantically equivalent, but the field has already been long abused to mean this, and writing it helps in determining a decent cfr time base when transcoding from a mkv where the video codec stores none (VP8). backport r23284 by conrad Originally committed as revision 23365 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/matroskaenc.c | 1 + tests/ref/lavf/mkv | 4 ++-- tests/ref/seek/lavf.mkv.ref | 44 ++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2fa31bad0a..01e6e79f3f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -566,6 +566,7 @@ static int mkv_write_tracks(AVFormatContext *s) switch (codec->codec_type) { case AVMEDIA_TYPE_VIDEO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO); + put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, av_q2d(codec->time_base)*1E9); if (!native_id && ff_codec_get_tag(codec_movvideo_tags, codec->codec_id) && diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv index bcf7ff309f..213d38b758 100644 --- a/tests/ref/lavf/mkv +++ b/tests/ref/lavf/mkv @@ -1,3 +1,3 @@ -a0ce20d849aea1c6e138dd1101c8f162 *./tests/data/lavf/lavf.mkv - 320463 ./tests/data/lavf/lavf.mkv +cf230e089e737ed9449fbfb3cb87da92 *./tests/data/lavf/lavf.mkv + 320471 ./tests/data/lavf/lavf.mkv ./tests/data/lavf/lavf.mkv CRC=0x2a83e6b0 diff --git a/tests/ref/seek/lavf.mkv.ref b/tests/ref/seek/lavf.mkv.ref index 0cc6839a8a..5af4488d2c 100644 --- a/tests/ref/seek/lavf.mkv.ref +++ b/tests/ref/seek/lavf.mkv.ref @@ -1,53 +1,53 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291902 size: 27834 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291902 size: 27834 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st: 1 flags:0 ts: 2.577000 ret:-EOF ret: 0 st: 1 flags:1 ts: 1.471000 -ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320167 size: 209 +ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320175 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146679 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146687 size: 27925 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st: 0 flags:0 ts: 2.153000 ret:-EOF ret: 0 st: 0 flags:1 ts: 1.048000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291902 size: 27834 ret: 0 st: 1 flags:0 ts:-0.058000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st: 1 flags:1 ts: 2.836000 -ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320167 size: 209 +ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320175 size: 209 ret: 0 st:-1 flags:0 ts: 1.730004 ret:-EOF ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146679 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146687 size: 27925 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291902 size: 27834 ret: 0 st: 1 flags:0 ts: 1.307000 ret:-EOF ret: 0 st: 1 flags:1 ts: 0.201000 -ret: 0 st: 1 flags:1 dts: 0.183000 pts: 0.183000 pos: 72075 size: 209 +ret: 0 st: 1 flags:1 dts: 0.183000 pts: 0.183000 pos: 72083 size: 209 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291902 size: 27834 ret: 0 st: 0 flags:0 ts: 0.883000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291894 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 291902 size: 27834 ret: 0 st: 0 flags:1 ts:-0.222000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 ret: 0 st: 1 flags:0 ts: 2.672000 ret:-EOF ret: 0 st: 1 flags:1 ts: 1.566000 -ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320167 size: 209 +ret: 0 st: 1 flags:1 dts: 1.019000 pts: 1.019000 pos: 320175 size: 209 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146679 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146687 size: 27925 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 505 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 513 size: 27837 From e63d03e7e24e51edd08496e40bac1eb946917917 Mon Sep 17 00:00:00 2001 From: Cyril Russo Date: Sat, 29 May 2010 13:11:21 +0000 Subject: [PATCH 072/301] Fix documentation of av_audio_convert. Patch by Cyril Russo, stage D nexvision A laposte net backport r23285 by cehoyos Originally committed as revision 23372 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/audioconvert.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/audioconvert.h b/libavcodec/audioconvert.h index e0f9bb06e2..81b6cded39 100644 --- a/libavcodec/audioconvert.h +++ b/libavcodec/audioconvert.h @@ -103,9 +103,9 @@ void av_audio_convert_free(AVAudioConvert *ctx); /** * Convert between audio sample formats * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel. - * @param[in] out_stride distance between consecutive input samples (measured in bytes) + * @param[in] out_stride distance between consecutive output samples (measured in bytes) * @param[in] in array of input buffers for each channel - * @param[in] in_stride distance between consecutive output samples (measured in bytes) + * @param[in] in_stride distance between consecutive input samples (measured in bytes) * @param len length of audio frame size (measured in samples) */ int av_audio_convert(AVAudioConvert *ctx, From df62b0d9f5cb8bebd0dee94dc826e1617cb14274 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 13:11:56 +0000 Subject: [PATCH 073/301] Display a more descriptive log message when probe buffer limit is reached. backport r23288 by jai_menon Originally committed as revision 23373 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1da1313e6e..e975f5de24 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2201,7 +2201,7 @@ int av_find_stream_info(AVFormatContext *ic) /* we did not get all the codec info, but we read too much data */ if (read_size >= ic->probesize) { ret = count; - av_log(ic, AV_LOG_DEBUG, "MAX_READ_SIZE:%d reached\n", ic->probesize); + av_log(ic, AV_LOG_DEBUG, "Probe buffer size limit %d reached\n", ic->probesize); break; } From 8261cce1f0bbaaf521a2ec7e7028cfaa6c3a5682 Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 29 May 2010 14:03:03 +0000 Subject: [PATCH 074/301] VP8 decoding via libvpx Patch by James Zern for Google, Inc., jzern google com backportd r23191,23303,23307-23308 by conrad, cehoyos and mstorsjo Originally committed as revision 23374 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 2 +- configure | 5 ++ doc/general.texi | 2 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 5 +- libavcodec/libvpxdec.c | 124 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 libavcodec/libvpxdec.c diff --git a/Changelog b/Changelog index 76f6a89a3f..1febc493a6 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,6 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. - version 0.6: - PB-frame decoding for H.263 @@ -79,6 +78,7 @@ version 0.6: - faster H.264 decoding - low overhead Ogg muxing - WebM support in Matroska demuxer +- VP8 decoding via libvpx diff --git a/configure b/configure index 828af886ae..8b3ebf6449 100755 --- a/configure +++ b/configure @@ -183,6 +183,7 @@ External library support: --enable-libtheora enable Theora encoding via libtheora [no] --enable-libvorbis enable Vorbis encoding via libvorbis, native implementation exists [no] + --enable-libvpx enable VP8 support via libvpx [no] --enable-libx264 enable H.264 encoding via x264 [no] --enable-libxvid enable Xvid encoding via xvidcore, native MPEG-4/Xvid encoder exists [no] @@ -927,6 +928,7 @@ CONFIG_LIST=" libspeex libtheora libvorbis + libvpx libx264 libxvid lpc @@ -1349,6 +1351,7 @@ libschroedinger_encoder_deps="libschroedinger" libspeex_decoder_deps="libspeex" libtheora_encoder_deps="libtheora" libvorbis_encoder_deps="libvorbis" +libvpx_decoder_deps="libvpx" libx264_encoder_deps="libx264" libxvid_encoder_deps="libxvid" @@ -2612,6 +2615,7 @@ enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) && enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg +enabled libvpx && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm && { check_cpp_condition x264.h "X264_BUILD >= 83" || die "ERROR: libx264 version must be >= 0.83."; } @@ -2881,6 +2885,7 @@ echo "libschroedinger enabled ${libschroedinger-no}" echo "libspeex enabled ${libspeex-no}" echo "libtheora enabled ${libtheora-no}" echo "libvorbis enabled ${libvorbis-no}" +echo "libvpx enabled ${libvpx-no}" echo "libx264 enabled ${libx264-no}" echo "libxvid enabled ${libxvid-no}" echo "zlib enabled ${zlib-no}" diff --git a/doc/general.texi b/doc/general.texi index bb199f6501..a2ad3bb4a1 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -437,6 +437,8 @@ following image formats are supported: @tab fourcc: VP50 @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62 + at item VP8 @tab @tab X + @tab fourcc: VP80, decoding supported through external library libvpx @item planar RGB @tab @tab X @tab fourcc: 8BPS @item Q-team QPEG @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1885adeccc..2356c09dd6 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -525,6 +525,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o +OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 6db65cfdde..63a70e6aff 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -344,6 +344,7 @@ void avcodec_register_all(void) REGISTER_DECODER (LIBSPEEX, libspeex); REGISTER_ENCODER (LIBTHEORA, libtheora); REGISTER_ENCODER (LIBVORBIS, libvorbis); + REGISTER_DECODER (LIBVPX, libvpx); REGISTER_ENCODER (LIBX264, libx264); REGISTER_ENCODER (LIBXVID, libxvid); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 72db24642c..996bc15b70 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,8 +30,8 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 66 -#define LIBAVCODEC_VERSION_MICRO 0 +#define LIBAVCODEC_VERSION_MINOR 69 +#define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -210,6 +210,7 @@ enum CodecID { CODEC_ID_IFF_BYTERUN1, CODEC_ID_KGV1, CODEC_ID_YOP, + CODEC_ID_VP8, /* various PCM "codecs" */ CODEC_ID_PCM_S16LE= 0x10000, diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c new file mode 100644 index 0000000000..0464d12e71 --- /dev/null +++ b/libavcodec/libvpxdec.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2010, Google, Inc. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * VP8 decoder support via libvpx + */ + +#define VPX_CODEC_DISABLE_COMPAT 1 +#include +#include + +#include "avcodec.h" + +typedef struct VP8DecoderContext { + struct vpx_codec_ctx decoder; +} VP8Context; + +static av_cold int vp8_init(AVCodecContext *avctx) +{ + VP8Context *ctx = avctx->priv_data; + const struct vpx_codec_iface *iface = &vpx_codec_vp8_dx_algo; + struct vpx_codec_dec_cfg deccfg = { + /* token partitions+1 would be a decent choice */ + .threads = FFMIN(avctx->thread_count, 16) + }; + + av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); + av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); + + if (vpx_codec_dec_init(&ctx->decoder, iface, &deccfg, 0) != VPX_CODEC_OK) { + const char *error = vpx_codec_error(&ctx->decoder); + av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n", + error); + return AVERROR(EINVAL); + } + + avctx->pix_fmt = PIX_FMT_YUV420P; + return 0; +} + +static int vp8_decode(AVCodecContext *avctx, + void *data, int *data_size, AVPacket *avpkt) +{ + VP8Context *ctx = avctx->priv_data; + AVFrame *picture = data; + const void *iter = NULL; + struct vpx_image *img; + + if (vpx_codec_decode(&ctx->decoder, avpkt->data, avpkt->size, NULL, 0) != + VPX_CODEC_OK) { + const char *error = vpx_codec_error(&ctx->decoder); + const char *detail = vpx_codec_error_detail(&ctx->decoder); + + av_log(avctx, AV_LOG_ERROR, "Failed to decode frame: %s\n", error); + if (detail) + av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", + detail); + return AVERROR_INVALIDDATA; + } + + if ((img = vpx_codec_get_frame(&ctx->decoder, &iter))) { + if (img->fmt != VPX_IMG_FMT_I420) { + av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d)\n", + img->fmt); + return AVERROR_INVALIDDATA; + } + + if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) { + av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n", + avctx->width, avctx->height, img->d_w, img->d_h); + if (avcodec_check_dimensions(avctx, img->d_w, img->d_h)) + return AVERROR_INVALIDDATA; + avcodec_set_dimensions(avctx, img->d_w, img->d_h); + } + picture->data[0] = img->planes[0]; + picture->data[1] = img->planes[1]; + picture->data[2] = img->planes[2]; + picture->data[3] = NULL; + picture->linesize[0] = img->stride[0]; + picture->linesize[1] = img->stride[1]; + picture->linesize[2] = img->stride[2]; + picture->linesize[3] = 0; + *data_size = sizeof(AVPicture); + } + return avpkt->size; +} + +static av_cold int vp8_free(AVCodecContext *avctx) +{ + VP8Context *ctx = avctx->priv_data; + vpx_codec_destroy(&ctx->decoder); + return 0; +} + +AVCodec libvpx_decoder = { + "libvpx", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_VP8, + sizeof(VP8Context), + vp8_init, + NULL, /* encode */ + vp8_free, + vp8_decode, + 0, /* capabilities */ + .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), +}; From 9181adff9c218e6b4b6a8e5f8c61ff99ccc3365e Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:05:05 +0000 Subject: [PATCH 075/301] Fix VP8 listing in general.texi backport r23306 by mstorsjo Originally committed as revision 23375 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- doc/general.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index a2ad3bb4a1..fbee13b2ab 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -437,7 +437,7 @@ following image formats are supported: @tab fourcc: VP50 @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62 - at item VP8 @tab @tab X +@item VP8 @tab @tab X @tab fourcc: VP80, decoding supported through external library libvpx @item planar RGB @tab @tab X @tab fourcc: 8BPS From 9052b5b73ba45520ed4f9d7db1c3458c641f8d14 Mon Sep 17 00:00:00 2001 From: Google <> Date: Sat, 29 May 2010 14:11:03 +0000 Subject: [PATCH 076/301] matroska: Add V_VP8 Patch by Google backport r23192 by conrad Originally committed as revision 23376 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/matroska.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 214825a180..dac4735a50 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -76,6 +76,7 @@ const CodecTags ff_mkv_codec_tags[]={ {"V_SNOW" , CODEC_ID_SNOW}, {"V_THEORA" , CODEC_ID_THEORA}, {"V_UNCOMPRESSED" , CODEC_ID_RAWVIDEO}, + {"V_VP8" , CODEC_ID_VP8}, {"" , CODEC_ID_NONE} }; From 46ac6315fdda4580dbefde96870d848c5bbca608 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:20:05 +0000 Subject: [PATCH 077/301] api-example: Try to avoid decoding incomplete frames Use a larger input audio buffer, refill it when it has less than 4 KB data left. backport r23323 by mstorsjo Originally committed as revision 23377 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/api-example.c | 47 ++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/libavcodec/api-example.c b/libavcodec/api-example.c index fb48b1f6d6..f34075e666 100644 --- a/libavcodec/api-example.c +++ b/libavcodec/api-example.c @@ -39,6 +39,8 @@ #include "libavutil/mathematics.h" #define INBUF_SIZE 4096 +#define AUDIO_INBUF_SIZE 20480 +#define AUDIO_REFILL_THRESH 4096 /* * Audio encoding example @@ -118,7 +120,7 @@ static void audio_decode_example(const char *outfilename, const char *filename) int out_size, len; FILE *f, *outfile; uint8_t *outbuf; - uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; av_init_packet(&avpkt); @@ -155,25 +157,32 @@ static void audio_decode_example(const char *outfilename, const char *filename) /* decode until eof */ avpkt.data = inbuf; - for(;;) { - avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); - if (avpkt.size == 0) - break; + avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); - avpkt.data = inbuf; - while (avpkt.size > 0) { - out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); - if (len < 0) { - fprintf(stderr, "Error while decoding\n"); - exit(1); - } - if (out_size > 0) { - /* if a frame has been decoded, output it */ - fwrite(outbuf, 1, out_size, outfile); - } - avpkt.size -= len; - avpkt.data += len; + while (avpkt.size > 0) { + out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); + if (len < 0) { + fprintf(stderr, "Error while decoding\n"); + exit(1); + } + if (out_size > 0) { + /* if a frame has been decoded, output it */ + fwrite(outbuf, 1, out_size, outfile); + } + avpkt.size -= len; + avpkt.data += len; + if (avpkt.size < AUDIO_REFILL_THRESH) { + /* Refill the input buffer, to avoid trying to decode + * incomplete frames. Instead of this, one could also use + * a parser, or use a proper container format through + * libavformat. */ + memmove(inbuf, avpkt.data, avpkt.size); + avpkt.data = inbuf; + len = fread(avpkt.data + avpkt.size, 1, + AUDIO_INBUF_SIZE - avpkt.size, f); + if (len > 0) + avpkt.size += len; } } From 4e62a6738972275ab4cda625304f1cd25d8a0772 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:25:18 +0000 Subject: [PATCH 078/301] Check for VUI overeading and reset num_reoder_frames. This helps the video from issue1831 backport r23328 by michael Originally committed as revision 23378 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/h264_ps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index e5ae403204..7648e2c7a6 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -205,6 +205,12 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){ sps->num_reorder_frames= get_ue_golomb(&s->gb); get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/ + if(s->gb.size_in_bits < get_bits_count(&s->gb)){ + av_log(h->s.avctx, AV_LOG_ERROR, "Overread VUI by %d bits\n", get_bits_count(&s->gb) - s->gb.size_in_bits); + sps->num_reorder_frames=0; + sps->bitstream_restriction_flag= 0; + } + if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames); return -1; From 3fa19f68287be4fc06776a4a52a7415e47822876 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 29 May 2010 14:33:02 +0000 Subject: [PATCH 079/301] Add CODEC_CAP_EXPERIMENTAL and prefer encoders without it. Patch by Janne Grunau, janne-ffmpeg jannau net backport r23334,23337-23338 by cehoyos and stefano Originally committed as revision 23379 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 1 + doc/APIchanges | 3 +++ libavcodec/avcodec.h | 7 ++++++- libavcodec/utils.c | 12 ++++++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 1febc493a6..187264d1cd 100644 --- a/Changelog +++ b/Changelog @@ -79,6 +79,7 @@ version 0.6: - low overhead Ogg muxing - WebM support in Matroska demuxer - VP8 decoding via libvpx +- CODEC_CAP_EXPERIMENTAL added diff --git a/doc/APIchanges b/doc/APIchanges index d521b59e29..4d574108b8 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,9 @@ libavutil: 2009-03-08 API changes, most recent first: +2010-05-26 - r23334 - lavc 52.72.0 - CODEC_CAP_EXPERIMENTAL + Add CODEC_CAP_EXPERIMENTAL flag. + 2010-05-18 - r23161 - lavf 52.63.0 - AVFMT_FLAG_RTP_HINT Add AVFMT_FLAG_RTP_HINT as possible value for AVFormatContext.flags diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 996bc15b70..8832014a72 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,7 +30,7 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 69 +#define LIBAVCODEC_VERSION_MINOR 72 #define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -644,6 +644,11 @@ typedef struct RcOverride{ * as a last resort. */ #define CODEC_CAP_SUBFRAMES 0x0100 +/** + * Codec is experimental and is thus avoided in favor of non experimental + * encoders + */ +#define CODEC_CAP_EXPERIMENTAL 0x0200 //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 87facec8f4..014427d59f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -724,14 +724,18 @@ av_cold int avcodec_close(AVCodecContext *avctx) AVCodec *avcodec_find_encoder(enum CodecID id) { - AVCodec *p; + AVCodec *p, *experimental=NULL; p = first_avcodec; while (p) { - if (p->encode != NULL && p->id == id) - return p; + if (p->encode != NULL && p->id == id) { + if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { + experimental = p; + } else + return p; + } p = p->next; } - return NULL; + return experimental; } AVCodec *avcodec_find_encoder_by_name(const char *name) From bf20d5e4bba3d2056eb4dfeac8f82a8d32c033fd Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:33:50 +0000 Subject: [PATCH 080/301] Mark AAC encoder as experimental. backport r23350 by alexc Originally committed as revision 23380 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aacenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 938df344bb..90dff15dd5 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -645,7 +645,7 @@ AVCodec aac_encoder = { aac_encode_init, aac_encode_frame, aac_encode_end, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, + .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), }; From 8f3504c3ca87f75e2eee437678b670ffa0b67ad1 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:34:37 +0000 Subject: [PATCH 081/301] Mark vorbis encoder as experimental. backport r23339 by cehoyos Originally committed as revision 23381 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/vorbis_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbis_enc.c index 2bc0a24096..934463d1e1 100644 --- a/libavcodec/vorbis_enc.c +++ b/libavcodec/vorbis_enc.c @@ -1099,7 +1099,7 @@ AVCodec vorbis_encoder = { vorbis_encode_init, vorbis_encode_frame, vorbis_encode_close, - .capabilities= CODEC_CAP_DELAY, + .capabilities= CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), }; From 2a546cecbf063950a4e5c3a53b53622ca7ea2be9 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:40:31 +0000 Subject: [PATCH 082/301] backport latest ffserver fixes like memory leaks and invalid reads Patches by Howard Chu, hyc at highlandsun dot com backport r23290-23295 by mstorsjo Originally committed as revision 23382 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffserver.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/ffserver.c b/ffserver.c index 7dcc9b23fd..17fa9100bf 100644 --- a/ffserver.c +++ b/ffserver.c @@ -847,6 +847,8 @@ static void close_connection(HTTPContext *c) ctx = c->rtp_ctx[i]; if (ctx) { av_write_trailer(ctx); + av_metadata_free(&ctx->metadata); + av_free(ctx->streams[0]); av_free(ctx); } h = c->rtp_handles[i]; @@ -2280,6 +2282,7 @@ static int http_prepare_data(HTTPContext *c) http_log("Error writing output header\n"); return -1; } + av_metadata_free(&c->fmt_ctx.metadata); len = url_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; @@ -2343,7 +2346,7 @@ static int http_prepare_data(HTTPContext *c) } } for(i=0;istream->nb_streams;i++) { - if (c->feed_streams[i] == pkt.stream_index) { + if (c->stream->feed_streams[i] == pkt.stream_index) { AVStream *st = c->fmt_in->streams[source_index]; pkt.stream_index = i; if (pkt.flags & AV_PKT_FLAG_KEY && @@ -2879,7 +2882,7 @@ static int rtsp_parse_request(HTTPContext *c) if (*p == '\n') p++; while (*p != '\0') { - p1 = strchr(p, '\n'); + p1 = memchr(p, '\n', (char *)c->buffer_ptr - p); if (!p1) break; p2 = p1; @@ -2956,6 +2959,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, } *pbuffer = av_mallocz(2048); avf_sdp_create(&avc, 1, *pbuffer, 2048); + av_metadata_free(&avc->metadata); av_free(avc); return strlen(*pbuffer); @@ -3012,6 +3016,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url) url_fprintf(c->pb, "Content-Length: %d\r\n", content_length); url_fprintf(c->pb, "\r\n"); put_buffer(c->pb, content, content_length); + av_free(content); } static HTTPContext *find_rtp_session(const char *session_id) @@ -3378,7 +3383,6 @@ static int rtp_new_av_stream(HTTPContext *c, st = av_mallocz(sizeof(AVStream)); if (!st) goto fail; - st->codec= avcodec_alloc_context(); ctx->nb_streams = 1; ctx->streams[0] = st; @@ -3454,16 +3458,28 @@ static int rtp_new_av_stream(HTTPContext *c, /********************************************************************/ /* ffserver initialization */ -static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec) +static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int copy) { AVStream *fst; fst = av_mallocz(sizeof(AVStream)); if (!fst) return NULL; - fst->codec= avcodec_alloc_context(); + if (copy) { + fst->codec= avcodec_alloc_context(); + memcpy(fst->codec, codec, sizeof(AVCodecContext)); + if (codec->extradata_size) { + fst->codec->extradata = av_malloc(codec->extradata_size); + memcpy(fst->codec->extradata, codec->extradata, + codec->extradata_size); + } + } else { + /* live streams must use the actual feed's codec since it may be + * updated later to carry extradata needed by the streams. + */ + fst->codec = codec; + } fst->priv_data = av_mallocz(sizeof(FeedData)); - memcpy(fst->codec, codec, sizeof(AVCodecContext)); fst->index = stream->nb_streams; av_set_pts_info(fst, 33, 1, 90000); stream->streams[stream->nb_streams++] = fst; @@ -3505,7 +3521,7 @@ static int add_av_stream(FFStream *feed, AVStream *st) } } - fst = add_av_stream1(feed, av); + fst = add_av_stream1(feed, av, 0); if (!fst) return -1; return feed->nb_streams - 1; @@ -3616,7 +3632,7 @@ static void build_file_streams(void) extract_mpeg4_header(infile); for(i=0;inb_streams;i++) - add_av_stream1(stream, infile->streams[i]->codec); + add_av_stream1(stream, infile->streams[i]->codec, 1); av_close_input_file(infile); } @@ -3683,7 +3699,7 @@ static void build_feed_streams(void) ccs = ss->codec; #define CHECK_CODEC(x) (ccf->x != ccs->x) - if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) { + if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) { http_log("Codecs do not match for stream %d\n", i); matches = 0; } else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) { From 1f1d2fa75cd4a900b398e117c5ea8b68d55f23d6 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:41:26 +0000 Subject: [PATCH 083/301] ffserver: Send a Content-Base header in the reply to RTSP DESCRIBE requests This is needed for QuickTime Player to be able to connect properly. backport r23325 by mstorsjo Originally committed as revision 23383 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffserver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffserver.c b/ffserver.c index 17fa9100bf..a1bd5262f0 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3012,6 +3012,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url) return; } rtsp_reply_header(c, RTSP_STATUS_OK); + url_fprintf(c->pb, "Content-Base: %s/\r\n", url); url_fprintf(c->pb, "Content-Type: application/sdp\r\n"); url_fprintf(c->pb, "Content-Length: %d\r\n", content_length); url_fprintf(c->pb, "\r\n"); From 55291e37f550097171f7a11871f522580dbf1be5 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 14:45:13 +0000 Subject: [PATCH 084/301] Samsung uses SIPP as FourCC for MPEG-4 ASP. backport r23309 by cehoyos Originally committed as revision 23384 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 340fd760c0..04b710854a 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -80,6 +80,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') }, { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') }, { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') }, + { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */ { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, From f7f9f18f8394806b2e11b1a4412f8c4847332fcb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 29 May 2010 15:07:08 +0000 Subject: [PATCH 085/301] Treat SIPP like xvid, fixed issue1966 backport r23336 by michael Originally committed as revision 23385 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/h263dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index f5df5560c5..c80cfcfa2d 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -428,7 +428,9 @@ retry: if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){ if(s->stream_codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") || - s->codec_tag == AV_RL32("RMP4")) + s->codec_tag == AV_RL32("RMP4") || + s->codec_tag == AV_RL32("SIPP") + ) s->xvid_build= 0; #if 0 if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1 From 661092004f9cbe300f1c45c68282b4f9856c6dd5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 30 May 2010 22:25:40 +0000 Subject: [PATCH 086/301] Require --enable-nonfree flag for libvpx. The license of libvpx is incompatible with the (L)GPL. As long as this is the case, the only way to use it is by marking the result as nonfree. backport r23371 by diego Originally committed as revision 23390 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 8b3ebf6449..4c37a02e98 100755 --- a/configure +++ b/configure @@ -2335,6 +2335,7 @@ die_license_disabled gpl postproc die_license_disabled gpl x11grab die_license_disabled nonfree libfaac +die_license_disabled nonfree libvpx die_license_disabled version3 libopencore_amrnb die_license_disabled version3 libopencore_amrwb From 70ea5176a55a20f54d579e45a9cfeaf5d5ee0eb5 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 31 May 2010 21:49:53 +0000 Subject: [PATCH 087/301] Add a short note about libvpx. backport r23394 by diego Originally committed as revision 23395 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- LICENSE | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LICENSE b/LICENSE index 668350b185..b87e399747 100644 --- a/LICENSE +++ b/LICENSE @@ -48,3 +48,7 @@ version needs to be upgraded by passing --enable-version3 to configure. The nonfree external library libfaac can be hooked up in FFmpeg. You need to pass --enable-nonfree to configure to enable it. Employ this option with care as FFmpeg then becomes nonfree and unredistributable. + +The libvpx external library has a license that is (L)GPL incompatible. If you +combine it with FFmpeg the resulting binaries are unredistributable. Thus you +need to pass --enable-nonfree to configure to enable it. From 0546386dffe219e2f6c93f64aac4accefe2b1f93 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 1 Jun 2010 06:28:19 +0000 Subject: [PATCH 088/301] ffmpeg: fail if user selected codec is experimental and strict_std_compliance > experimental backport r23397 by janne Originally committed as revision 23399 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffmpeg.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 67b7a51e65..e2ea308d81 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2912,7 +2912,7 @@ static int opt_input_ts_offset(const char *opt, const char *arg) return 0; } -static enum CodecID find_codec_or_die(const char *name, int type, int encoder) +static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; @@ -2930,6 +2930,13 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder) fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name); av_exit(1); } + if(codec->capabilities & CODEC_CAP_EXPERIMENTAL && + strict > FF_COMPLIANCE_EXPERIMENTAL) { + fprintf(stderr, "%s '%s' is experimental and might produce bad " + "results.\nAdd '-strict experimental' if you want to use it.\n", + codec_string, codec->name); + av_exit(1); + } return codec->id; } @@ -2977,9 +2984,15 @@ static void opt_input_file(const char *filename) set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM); - ic->video_codec_id = find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0); - ic->audio_codec_id = find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0); - ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0); + ic->video_codec_id = + find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0, + avcodec_opts[AVMEDIA_TYPE_VIDEO ]->strict_std_compliance); + ic->audio_codec_id = + find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0, + avcodec_opts[AVMEDIA_TYPE_AUDIO ]->strict_std_compliance); + ic->subtitle_codec_id= + find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0, + avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); ic->flags |= AVFMT_FLAG_NONBLOCK; if(pgmyuv_compatibility_hack) @@ -3208,7 +3221,8 @@ static void new_video_stream(AVFormatContext *oc) AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1}; if (video_codec_name) { - codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1); + codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, + video_enc->strict_std_compliance); codec = avcodec_find_encoder_by_name(video_codec_name); output_codecs[nb_ocodecs] = codec; } else { @@ -3339,7 +3353,8 @@ static void new_audio_stream(AVFormatContext *oc) set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM); if (audio_codec_name) { - codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1); + codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, + audio_enc->strict_std_compliance); codec = avcodec_find_encoder_by_name(audio_codec_name); output_codecs[nb_ocodecs] = codec; } else { @@ -3399,7 +3414,8 @@ static void new_subtitle_stream(AVFormatContext *oc) st->stream_copy = 1; } else { set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM); - subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1); + subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, + subtitle_enc->strict_std_compliance); output_codecs[nb_ocodecs] = avcodec_find_encoder_by_name(subtitle_codec_name); } nb_ocodecs++; From 4979362ae4202395df99627803cae7180d7473cb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 1 Jun 2010 06:29:50 +0000 Subject: [PATCH 089/301] ffmpeg: offer alternatives for experimental codecs if they exist backport r23398 by janne Originally committed as revision 23400 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- ffmpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ffmpeg.c b/ffmpeg.c index e2ea308d81..6b9380f77a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2935,6 +2935,12 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder, i fprintf(stderr, "%s '%s' is experimental and might produce bad " "results.\nAdd '-strict experimental' if you want to use it.\n", codec_string, codec->name); + codec = encoder ? + avcodec_find_encoder(codec->id) : + avcodec_find_decoder(codec->id); + if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) + fprintf(stderr, "Or use the non experimental %s '%s'.\n", + codec_string, codec->name); av_exit(1); } return codec->id; From 4b51239df3149977f35af650659ae4c56d17d61f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 1 Jun 2010 20:14:00 +0000 Subject: [PATCH 090/301] disable (native) vorbis encoder for the 0.6 branch Originally committed as revision 23416 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/allcodecs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 63a70e6aff..9ee81fed8f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -253,7 +253,7 @@ void avcodec_register_all(void) REGISTER_DECODER (TTA, tta); REGISTER_DECODER (TWINVQ, twinvq); REGISTER_DECODER (VMDAUDIO, vmdaudio); - REGISTER_ENCDEC (VORBIS, vorbis); + REGISTER_DECODER (VORBIS, vorbis); REGISTER_DECODER (WAVPACK, wavpack); REGISTER_DECODER (WMAPRO, wmapro); REGISTER_ENCDEC (WMAV1, wmav1); From e5880b3f24292ee86929d4cab7fd98d7afed1feb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 2 Jun 2010 09:25:37 +0000 Subject: [PATCH 091/301] updates: introductionary and more general notes, add missing items from changelog Originally committed as revision 23420 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index 837d16cb9a..ff06d2077b 100644 --- a/RELEASE +++ b/RELEASE @@ -1,11 +1,22 @@ Release Notes ============= -* 0.6 "Works with HTML 5" May, 2010 +* 0.6 "Works with HTML5" June, 2010 General notes ------------- +This release features a lot of improvements that are relevant for HTML5 video. +The H.264 and Theora decoders are now significantly faster, the vorbis decoder +has seen important updates and this release supports Google's newly released +libvpx library. Please note that for license reasons, we consider binaries of +FFmpeg and libavcodec that are linked against libvpx unredistributable. We are +confident that the situation will improve upstream; in this case, we will +rectify this issue in a (future) point release. + +Other important changes are additions of decoders for popular codecs as +Intel Indeo 5, WMA Pro, WMA Voice and HE-AAC. + See the Changelog file for a list of significant changes. Please note that our policy on bug reports has not changed. We still only accept @@ -29,6 +40,7 @@ Notable changes: - -formats option split into -formats, -codecs, -bsfs, and -protocols - ffprobe tool - RTMP/RTMPT/RTMPS/RTMPE/RTMPTE protocol support via librtmp +- CODEC_CAP_EXPERIMENTAL added Added Codecs: @@ -76,6 +88,7 @@ Added Codecs: - Kega Game Video (KGV1) decoder - Psygnosis YOP demuxer and video decoder - RTP hinting in the mov/3gp/mp4 muxer +- VP8 decoding via libvpx Notable license related changes @@ -83,3 +96,4 @@ Notable license related changes - remaining GPL parts in AC-3 decoder converted to LGPL - libswscale can now be compiled in LGPL mode +- libvpx is considered (L)GPL incompatible From 20d4a1f020242fa2df2399728310d5549b52091e Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 3 Jun 2010 20:16:42 +0000 Subject: [PATCH 092/301] Add an entry to APIchanges for the addition of sws_convertPalette8ToPacked32 -24 backport r23415 by siretart Originally committed as revision 23446 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- doc/APIchanges | 3 +++ libswscale/rgb2rgb.c | 38 ++++---------------------------------- libswscale/rgb2rgb.h | 20 +++++++++++++------- libswscale/swscale.c | 35 +++++++++++++++++++++++++++++------ libswscale/swscale.h | 27 ++++++++++++++++++++++++++- 5 files changed, 75 insertions(+), 48 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4d574108b8..db696580f4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,9 @@ libavutil: 2009-03-08 API changes, most recent first: +2010-06-01 - r31301 - lsws 0.11.0 - convertPalette API + Add sws_convertPalette8ToPacked32 and sws_convertPalette8ToPacked24 + 2010-05-26 - r23334 - lavc 52.72.0 - CODEC_CAP_EXPERIMENTAL Add CODEC_CAP_EXPERIMENTAL flag. diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 7d1cefca3a..b506b12edc 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -207,31 +207,15 @@ void sws_rgb2rgb_init(int flags) rgb2rgb_init_C(); } -/** - * Convert the palette to the same packet 32-bit format as the palette - */ +#if LIBSWSCALE_VERSION_MAJOR < 1 void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) { - long i; - - for (i=0; i dst format: ABC - */ void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) { - long i; - - for (i=0; i +#include "libswscale/swscale.h" +#include "libavutil/avutil.h" + /* A full collection of RGB to RGB(BGR) converters */ extern void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); @@ -66,12 +69,15 @@ void shuffle_bytes_2103(const uint8_t *src, uint8_t *dst, long src_size); void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, long src_size); void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, long src_size); -void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); -void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); -void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); -void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); -void palette8torgb15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); -void palette8tobgr15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); +#if LIBSWSCALE_VERSION_MAJOR < 1 +/* deprecated, use the public versions in swscale.h */ +attribute_deprecated void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); +attribute_deprecated void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); + +/* totally deprecated, please fix code that uses this */ +attribute_deprecated void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); +attribute_deprecated void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); +#endif /** * Height should be a multiple of 2 and width should be a multiple of 16. diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2b02dd3dfd..81f475c6e2 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1424,12 +1424,12 @@ static int palToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], if (usePal(srcFormat)) { switch (dstFormat) { - case PIX_FMT_RGB32 : conv = palette8topacked32; break; - case PIX_FMT_BGR32 : conv = palette8topacked32; break; - case PIX_FMT_BGR32_1: conv = palette8topacked32; break; - case PIX_FMT_RGB32_1: conv = palette8topacked32; break; - case PIX_FMT_RGB24 : conv = palette8topacked24; break; - case PIX_FMT_BGR24 : conv = palette8topacked24; break; + case PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break; + case PIX_FMT_BGR32 : conv = sws_convertPalette8ToPacked32; break; + case PIX_FMT_BGR32_1: conv = sws_convertPalette8ToPacked32; break; + case PIX_FMT_RGB32_1: conv = sws_convertPalette8ToPacked32; break; + case PIX_FMT_RGB24 : conv = sws_convertPalette8ToPacked24; break; + case PIX_FMT_BGR24 : conv = sws_convertPalette8ToPacked24; break; } } @@ -1962,3 +1962,26 @@ int sws_scale_ordered(SwsContext *c, const uint8_t* const src[], int srcStride[] return sws_scale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride); } #endif + +/* Convert the palette to the same packed 32-bit format as the palette */ +void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) +{ + long i; + + for (i=0; i dst format: ABC */ +void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) +{ + long i; + + for (i=0; i Date: Thu, 3 Jun 2010 21:36:38 +0000 Subject: [PATCH 093/301] VP8 encoding via libvpx. Patch by James Zern, Google, Inc. backport r23449 by cehoyos Originally committed as revision 23455 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 2 +- configure | 4 +- doc/general.texi | 4 +- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 2 +- libavcodec/avcodec.h | 2 +- libavcodec/libvpxenc.c | 489 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 498 insertions(+), 6 deletions(-) create mode 100644 libavcodec/libvpxenc.c diff --git a/Changelog b/Changelog index 187264d1cd..9fc9bbc0c4 100644 --- a/Changelog +++ b/Changelog @@ -78,7 +78,7 @@ version 0.6: - faster H.264 decoding - low overhead Ogg muxing - WebM support in Matroska demuxer -- VP8 decoding via libvpx +- VP8 de/encoding via libvpx - CODEC_CAP_EXPERIMENTAL added diff --git a/configure b/configure index 4c37a02e98..73dff04178 100755 --- a/configure +++ b/configure @@ -1352,6 +1352,7 @@ libspeex_decoder_deps="libspeex" libtheora_encoder_deps="libtheora" libvorbis_encoder_deps="libvorbis" libvpx_decoder_deps="libvpx" +libvpx_encoder_deps="libvpx" libx264_encoder_deps="libx264" libxvid_encoder_deps="libxvid" @@ -2616,7 +2617,8 @@ enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) && enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg -enabled libvpx && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx +enabled libvpx && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx && + require2 libvpx "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver" -lvpx enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm && { check_cpp_condition x264.h "X264_BUILD >= 83" || die "ERROR: libx264 version must be >= 0.83."; } diff --git a/doc/general.texi b/doc/general.texi index fbee13b2ab..e7eb83f04c 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -437,8 +437,8 @@ following image formats are supported: @tab fourcc: VP50 @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62 -@item VP8 @tab @tab X - @tab fourcc: VP80, decoding supported through external library libvpx +@item VP8 @tab X @tab X + @tab fourcc: VP80, de/encoding supported through external library libvpx @item planar RGB @tab @tab X @tab fourcc: 8BPS @item Q-team QPEG @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 2356c09dd6..562e162511 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -526,6 +526,7 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o +OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 9ee81fed8f..aa3001c546 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -344,7 +344,7 @@ void avcodec_register_all(void) REGISTER_DECODER (LIBSPEEX, libspeex); REGISTER_ENCODER (LIBTHEORA, libtheora); REGISTER_ENCODER (LIBVORBIS, libvorbis); - REGISTER_DECODER (LIBVPX, libvpx); + REGISTER_ENCDEC (LIBVPX, libvpx); REGISTER_ENCODER (LIBX264, libx264); REGISTER_ENCODER (LIBXVID, libxvid); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 8832014a72..974e87cc53 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -31,7 +31,7 @@ #define LIBAVCODEC_VERSION_MAJOR 52 #define LIBAVCODEC_VERSION_MINOR 72 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MICRO 2 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c new file mode 100644 index 0000000000..fa393b8f42 --- /dev/null +++ b/libavcodec/libvpxenc.c @@ -0,0 +1,489 @@ +/* + * Copyright (c) 2010, Google, Inc. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * VP8 encoder support via libvpx + */ + +#define VPX_DISABLE_CTRL_TYPECHECKS 1 +#define VPX_CODEC_DISABLE_COMPAT 1 +#include +#include + +#include "avcodec.h" +#include "libavutil/base64.h" + +/** + * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. + * One encoded frame returned from the library. + */ +struct FrameListData { + void *buf; /**≤ compressed data buffer */ + size_t sz; /**≤ length of compressed data */ + int64_t pts; /**≤ time stamp to show frame + (in timebase units) */ + unsigned long duration; /**≤ duration to show frame + (in timebase units) */ + uint32_t flags; /**≤ flags for this frame */ + struct FrameListData *next; +}; + +typedef struct VP8EncoderContext { + struct vpx_codec_ctx encoder; + struct vpx_image rawimg; + struct vpx_fixed_buf twopass_stats; + unsigned long deadline; //i.e., RT/GOOD/BEST + struct FrameListData *coded_frame_list; +} VP8Context; + +/** String mappings for enum vp8e_enc_control_id */ +static const char *ctlidstr[] = { + [VP8E_UPD_ENTROPY] = "VP8E_UPD_ENTROPY", + [VP8E_UPD_REFERENCE] = "VP8E_UPD_REFERENCE", + [VP8E_USE_REFERENCE] = "VP8E_USE_REFERENCE", + [VP8E_SET_ROI_MAP] = "VP8E_SET_ROI_MAP", + [VP8E_SET_ACTIVEMAP] = "VP8E_SET_ACTIVEMAP", + [VP8E_SET_SCALEMODE] = "VP8E_SET_SCALEMODE", + [VP8E_SET_CPUUSED] = "VP8E_SET_CPUUSED", + [VP8E_SET_ENABLEAUTOALTREF] = "VP8E_SET_ENABLEAUTOALTREF", + [VP8E_SET_NOISE_SENSITIVITY] = "VP8E_SET_NOISE_SENSITIVITY", + [VP8E_SET_SHARPNESS] = "VP8E_SET_SHARPNESS", + [VP8E_SET_STATIC_THRESHOLD] = "VP8E_SET_STATIC_THRESHOLD", + [VP8E_SET_TOKEN_PARTITIONS] = "VP8E_SET_TOKEN_PARTITIONS", + [VP8E_GET_LAST_QUANTIZER] = "VP8E_GET_LAST_QUANTIZER", + [VP8E_SET_ARNR_MAXFRAMES] = "VP8E_SET_ARNR_MAXFRAMES", + [VP8E_SET_ARNR_STRENGTH] = "VP8E_SET_ARNR_STRENGTH", + [VP8E_SET_ARNR_TYPE] = "VP8E_SET_ARNR_TYPE", +}; + +static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) +{ + VP8Context *ctx = avctx->priv_data; + const char *error = vpx_codec_error(&ctx->encoder); + const char *detail = vpx_codec_error_detail(&ctx->encoder); + + av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error); + if (detail) + av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail); +} + +static av_cold void dump_enc_cfg(AVCodecContext *avctx, + const struct vpx_codec_enc_cfg *cfg) +{ + int width = -30; + int level = AV_LOG_DEBUG; + + av_log(avctx, level, "vpx_codec_enc_cfg\n"); + av_log(avctx, level, "generic settings\n" + " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n" + " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n", + width, "g_usage:", cfg->g_usage, + width, "g_threads:", cfg->g_threads, + width, "g_profile:", cfg->g_profile, + width, "g_w:", cfg->g_w, + width, "g_h:", cfg->g_h, + width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den, + width, "g_error_resilient:", cfg->g_error_resilient, + width, "g_pass:", cfg->g_pass, + width, "g_lag_in_frames:", cfg->g_lag_in_frames); + av_log(avctx, level, "rate control settings\n" + " %*s%u\n %*s%u\n %*s%u\n %*s%u\n" + " %*s%d\n %*s%p(%zu)\n %*s%u\n", + width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh, + width, "rc_resize_allowed:", cfg->rc_resize_allowed, + width, "rc_resize_up_thresh:", cfg->rc_resize_up_thresh, + width, "rc_resize_down_thresh:", cfg->rc_resize_down_thresh, + width, "rc_end_usage:", cfg->rc_end_usage, + width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz, + width, "rc_target_bitrate:", cfg->rc_target_bitrate); + av_log(avctx, level, "quantizer settings\n" + " %*s%u\n %*s%u\n", + width, "rc_min_quantizer:", cfg->rc_min_quantizer, + width, "rc_max_quantizer:", cfg->rc_max_quantizer); + av_log(avctx, level, "bitrate tolerance\n" + " %*s%u\n %*s%u\n", + width, "rc_undershoot_pct:", cfg->rc_undershoot_pct, + width, "rc_overshoot_pct:", cfg->rc_overshoot_pct); + av_log(avctx, level, "decoder buffer model\n" + " %*s%u\n %*s%u\n %*s%u\n", + width, "rc_buf_sz:", cfg->rc_buf_sz, + width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz, + width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz); + av_log(avctx, level, "2 pass rate control settings\n" + " %*s%u\n %*s%u\n %*s%u\n", + width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct, + width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct, + width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct); + av_log(avctx, level, "keyframing settings\n" + " %*s%d\n %*s%u\n %*s%u\n", + width, "kf_mode:", cfg->kf_mode, + width, "kf_min_dist:", cfg->kf_min_dist, + width, "kf_max_dist:", cfg->kf_max_dist); + av_log(avctx, level, "\n"); +} + +static void coded_frame_add(void *list, struct FrameListData *cx_frame) +{ + struct FrameListData **p = list; + + while (*p != NULL) + p = &(*p)->next; + *p = cx_frame; + cx_frame->next = NULL; +} + +static av_cold void free_coded_frame(struct FrameListData *cx_frame) +{ + av_freep(&cx_frame->buf); + av_freep(&cx_frame); +} + +static av_cold void free_frame_list(struct FrameListData *list) +{ + struct FrameListData *p = list; + + while (p) { + list = list->next; + free_coded_frame(p); + p = list; + } +} + +static av_cold int codecctl_int(AVCodecContext *avctx, + enum vp8e_enc_control_id id, int val) +{ + VP8Context *ctx = avctx->priv_data; + char buf[80]; + int width = -30; + int res; + + snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]); + av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val); + + res = vpx_codec_control(&ctx->encoder, id, val); + if (res != VPX_CODEC_OK) { + snprintf(buf, sizeof(buf), "Failed to set %s codec control", + ctlidstr[id]); + log_encoder_error(avctx, buf); + } + + return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL); +} + +static av_cold int vp8_free(AVCodecContext *avctx) +{ + VP8Context *ctx = avctx->priv_data; + + vpx_codec_destroy(&ctx->encoder); + av_freep(&ctx->twopass_stats.buf); + av_freep(&avctx->coded_frame); + av_freep(&avctx->stats_out); + free_frame_list(ctx->coded_frame_list); + return 0; +} + +static av_cold int vp8_init(AVCodecContext *avctx) +{ + VP8Context *ctx = avctx->priv_data; + const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo; + int cpuused = 3; + struct vpx_codec_enc_cfg enccfg; + int res; + + av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); + av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); + + if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) { + av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n", + vpx_codec_err_to_string(res)); + return AVERROR(EINVAL); + } + dump_enc_cfg(avctx, &enccfg); + + enccfg.g_w = avctx->width; + enccfg.g_h = avctx->height; + enccfg.g_timebase.num = avctx->time_base.num; + enccfg.g_timebase.den = avctx->time_base.den; + enccfg.g_threads = avctx->thread_count; + + if (avctx->flags & CODEC_FLAG_PASS1) + enccfg.g_pass = VPX_RC_FIRST_PASS; + else if (avctx->flags & CODEC_FLAG_PASS2) + enccfg.g_pass = VPX_RC_LAST_PASS; + else + enccfg.g_pass = VPX_RC_ONE_PASS; + + if (avctx->rc_min_rate == avctx->rc_max_rate && + avctx->rc_min_rate == avctx->bit_rate) + enccfg.rc_end_usage = VPX_CBR; + enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000, + AV_ROUND_NEAR_INF); + + //convert [1,51] -> [0,63] + enccfg.rc_min_quantizer = ((avctx->qmin * 5 + 1) >> 2) - 1; + enccfg.rc_max_quantizer = ((avctx->qmax * 5 + 1) >> 2) - 1; + + if (avctx->keyint_min == avctx->gop_size) + enccfg.kf_mode = VPX_KF_FIXED; + //_enc_init() will balk if kf_min_dist is set in this case + if (enccfg.kf_mode != VPX_KF_AUTO) + enccfg.kf_min_dist = avctx->keyint_min; + enccfg.kf_max_dist = avctx->gop_size; + + if (enccfg.g_pass == VPX_RC_FIRST_PASS) + enccfg.g_lag_in_frames = 0; + else if (enccfg.g_pass == VPX_RC_LAST_PASS) { + int decode_size; + + if (!avctx->stats_in) { + av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n"); + return AVERROR_INVALIDDATA; + } + + ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4; + ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz); + if (!ctx->twopass_stats.buf) { + av_log(avctx, AV_LOG_ERROR, + "Stat buffer alloc (%zu bytes) failed\n", + ctx->twopass_stats.sz); + return AVERROR(ENOMEM); + } + decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in, + ctx->twopass_stats.sz); + if (decode_size < 0) { + av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n"); + return AVERROR_INVALIDDATA; + } + + ctx->twopass_stats.sz = decode_size; + enccfg.rc_twopass_stats_in = ctx->twopass_stats; + } + + ctx->deadline = VPX_DL_GOOD_QUALITY; + + dump_enc_cfg(avctx, &enccfg); + /* Construct Encoder Context */ + res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0); + if (res != VPX_CODEC_OK) { + log_encoder_error(avctx, "Failed to initialize encoder"); + return AVERROR(EINVAL); + } + + //codec control failures are currently treated only as warnings + av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n"); + codecctl_int(avctx, VP8E_SET_CPUUSED, cpuused); + codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction); + + //provide dummy value to initialize wrapper, values will be updated each _encode() + vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1, + (unsigned char*)1); + + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->coded_frame) { + av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n"); + vp8_free(avctx); + return AVERROR(ENOMEM); + } + return 0; +} + +static inline void cx_pktcpy(struct FrameListData *dst, + const struct vpx_codec_cx_pkt *src) +{ + dst->pts = src->data.frame.pts; + dst->duration = src->data.frame.duration; + dst->flags = src->data.frame.flags; + dst->sz = src->data.frame.sz; + dst->buf = src->data.frame.buf; +} + +/** + * Store coded frame information in format suitable for return from encode(). + * + * Write buffer information from @a cx_frame to @a buf & @a buf_size. + * Timing/frame details to @a coded_frame. + * @return Frame size written to @a buf on success + * @return AVERROR(EINVAL) on error + */ +static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, + uint8_t *buf, int buf_size, AVFrame *coded_frame) +{ + if ((int) cx_frame->sz <= buf_size) { + buf_size = cx_frame->sz; + memcpy(buf, cx_frame->buf, buf_size); + coded_frame->pts = cx_frame->pts; + coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY); + + if (coded_frame->key_frame) + coded_frame->pict_type = FF_I_TYPE; + else + coded_frame->pict_type = FF_P_TYPE; + } else { + av_log(avctx, AV_LOG_ERROR, + "Compressed frame larger than storage provided! (%zu/%d)\n", + cx_frame->sz, buf_size); + return AVERROR(EINVAL); + } + return buf_size; +} + +/** + * Queue multiple output frames from the encoder, returning the front-most. + * In cases where vpx_codec_get_cx_data() returns more than 1 frame append + * the frame queue. Return the head frame if available. + * @return Stored frame size + * @return AVERROR(EINVAL) on output size error + * @return AVERROR(ENOMEM) on coded frame queue data allocation error + */ +static int queue_frames(AVCodecContext *avctx, uint8_t *buf, int buf_size, + AVFrame *coded_frame) +{ + VP8Context *ctx = avctx->priv_data; + const struct vpx_codec_cx_pkt *pkt; + const void *iter = NULL; + int size = 0; + + if (ctx->coded_frame_list) { + struct FrameListData *cx_frame = ctx->coded_frame_list; + /* return the leading frame if we've already begun queueing */ + size = storeframe(avctx, cx_frame, buf, buf_size, coded_frame); + if (size < 0) + return AVERROR(EINVAL); + ctx->coded_frame_list = cx_frame->next; + free_coded_frame(cx_frame); + } + + /* consume all available output from the encoder before returning. buffers + are only good through the next vpx_codec call */ + while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter))) { + switch (pkt->kind) { + case VPX_CODEC_CX_FRAME_PKT: + if (!size) { + struct FrameListData cx_frame; + + /* avoid storing the frame when the list is empty and we haven't yet + provided a frame for output */ + assert(!ctx->coded_frame_list); + cx_pktcpy(&cx_frame, pkt); + size = storeframe(avctx, &cx_frame, buf, buf_size, coded_frame); + if (size < 0) + return AVERROR(EINVAL); + } else { + struct FrameListData *cx_frame = + av_malloc(sizeof(struct FrameListData)); + + if (!cx_frame) { + av_log(avctx, AV_LOG_ERROR, + "Frame queue element alloc failed\n"); + return AVERROR(ENOMEM); + } + cx_pktcpy(cx_frame, pkt); + cx_frame->buf = av_malloc(cx_frame->sz); + + if (!cx_frame->buf) { + av_log(avctx, AV_LOG_ERROR, + "Data buffer alloc (%zu bytes) failed\n", + cx_frame->sz); + return AVERROR(ENOMEM); + } + memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz); + coded_frame_add(&ctx->coded_frame_list, cx_frame); + } + break; + case VPX_CODEC_STATS_PKT: { + struct vpx_fixed_buf *stats = &ctx->twopass_stats; + stats->buf = av_realloc(stats->buf, + stats->sz + pkt->data.twopass_stats.sz); + if (!stats->buf) { + av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n"); + return AVERROR(ENOMEM); + } + memcpy((uint8_t*)stats->buf + stats->sz, + pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz); + stats->sz += pkt->data.twopass_stats.sz; + break; + } + case VPX_CODEC_PSNR_PKT: //FIXME add support for CODEC_FLAG_PSNR + case VPX_CODEC_CUSTOM_PKT: + //ignore unsupported/unrecognized packet types + break; + } + } + + return size; +} + +static int vp8_encode(AVCodecContext *avctx, uint8_t *buf, int buf_size, + void *data) +{ + VP8Context *ctx = avctx->priv_data; + AVFrame *frame = data; + struct vpx_image *rawimg = NULL; + int64_t timestamp = 0; + int res, coded_size; + + if (frame) { + rawimg = &ctx->rawimg; + rawimg->planes[VPX_PLANE_Y] = frame->data[0]; + rawimg->planes[VPX_PLANE_U] = frame->data[1]; + rawimg->planes[VPX_PLANE_V] = frame->data[2]; + rawimg->stride[VPX_PLANE_Y] = frame->linesize[0]; + rawimg->stride[VPX_PLANE_U] = frame->linesize[1]; + rawimg->stride[VPX_PLANE_V] = frame->linesize[2]; + timestamp = frame->pts; + } + + res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp, + avctx->ticks_per_frame, 0, ctx->deadline); + if (res != VPX_CODEC_OK) { + log_encoder_error(avctx, "Error encoding frame"); + return AVERROR_INVALIDDATA; + } + coded_size = queue_frames(avctx, buf, buf_size, avctx->coded_frame); + + if (!frame && avctx->flags & CODEC_FLAG_PASS1) { + unsigned int b64_size = ((ctx->twopass_stats.sz + 2) / 3) * 4 + 1; + + avctx->stats_out = av_malloc(b64_size); + if (!avctx->stats_out) { + av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n", + b64_size); + return AVERROR(ENOMEM); + } + av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf, + ctx->twopass_stats.sz); + } + return coded_size; +} + +AVCodec libvpx_encoder = { + "libvpx", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_VP8, + sizeof(VP8Context), + vp8_init, + vp8_encode, + vp8_free, + NULL, + CODEC_CAP_DELAY, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), +}; From 373010971efc60c2361bca7df598969b78dae360 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 5 Jun 2010 08:30:55 +0000 Subject: [PATCH 094/301] update RELEASE notes VP8 license issues seem to have solved, plus include wording suggestion from discussion on -cvslog Originally committed as revision 23483 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/RELEASE b/RELEASE index ff06d2077b..c68e42a272 100644 --- a/RELEASE +++ b/RELEASE @@ -9,12 +9,9 @@ General notes This release features a lot of improvements that are relevant for HTML5 video. The H.264 and Theora decoders are now significantly faster, the vorbis decoder has seen important updates and this release supports Google's newly released -libvpx library. Please note that for license reasons, we consider binaries of -FFmpeg and libavcodec that are linked against libvpx unredistributable. We are -confident that the situation will improve upstream; in this case, we will -rectify this issue in a (future) point release. +libvpx library for the VP8 codec and WEBM container. -Other important changes are additions of decoders for popular codecs as +Other important changes are additions of decoders including, but not limited to, Intel Indeo 5, WMA Pro, WMA Voice and HE-AAC. See the Changelog file for a list of significant changes. From eb4b8b96fcb2192ba118315bfee6651400888323 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 5 Jun 2010 13:58:13 +0000 Subject: [PATCH 095/301] libvpx now has an (L)GPL-compatible license. backport r23482 by diego Originally committed as revision 23487 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- LICENSE | 4 ---- configure | 1 - 2 files changed, 5 deletions(-) diff --git a/LICENSE b/LICENSE index b87e399747..668350b185 100644 --- a/LICENSE +++ b/LICENSE @@ -48,7 +48,3 @@ version needs to be upgraded by passing --enable-version3 to configure. The nonfree external library libfaac can be hooked up in FFmpeg. You need to pass --enable-nonfree to configure to enable it. Employ this option with care as FFmpeg then becomes nonfree and unredistributable. - -The libvpx external library has a license that is (L)GPL incompatible. If you -combine it with FFmpeg the resulting binaries are unredistributable. Thus you -need to pass --enable-nonfree to configure to enable it. diff --git a/configure b/configure index 73dff04178..cdec2f59a3 100755 --- a/configure +++ b/configure @@ -2336,7 +2336,6 @@ die_license_disabled gpl postproc die_license_disabled gpl x11grab die_license_disabled nonfree libfaac -die_license_disabled nonfree libvpx die_license_disabled version3 libopencore_amrnb die_license_disabled version3 libopencore_amrwb From db06ddf8c6711d99eb903359c0118b63ec129c27 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 9 Jun 2010 15:54:27 +0000 Subject: [PATCH 096/301] Add WebM muxer Patch by James Zern backport r23474 by conrad Originally committed as revision 23549 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 1 + doc/general.texi | 2 +- libavcodec/Makefile | 2 ++ libavformat/Makefile | 3 +++ libavformat/allformats.c | 1 + libavformat/avformat.h | 2 +- libavformat/matroskaenc.c | 42 ++++++++++++++++++++++++++++++++++++--- 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 9fc9bbc0c4..ef59fd7e17 100644 --- a/Changelog +++ b/Changelog @@ -76,6 +76,7 @@ version 0.6: - 35% faster VP3/Theora decoding - faster AAC decoding - faster H.264 decoding +- WebM support in Matroska de/muxer - low overhead Ogg muxing - WebM support in Matroska demuxer - VP8 de/encoding via libvpx diff --git a/doc/general.texi b/doc/general.texi index e7eb83f04c..dfa5b07e18 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -234,7 +234,7 @@ library: @item VC-1 test bitstream @tab X @tab X @item WAV @tab X @tab X @item WavPack @tab @tab X -@item WebM @tab @tab X +@item WebM @tab X @tab X @item Wing Commander III movie @tab @tab X @tab Multimedia format used in Origin's Wing Commander III computer game. @item Westwood Studios audio @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 562e162511..00e6b57fd3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -501,6 +501,8 @@ OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \ dirac.o mpeg12data.o OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o OBJS-$(CONFIG_RTP_MUXER) += mpegvideo.o +OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ + flacdec.o flacdata.o flac.o # external codec libraries OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o diff --git a/libavformat/Makefile b/libavformat/Makefile index a671e283e2..7a2d00fb45 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -255,6 +255,9 @@ OBJS-$(CONFIG_W64_DEMUXER) += wav.o riff.o raw.o OBJS-$(CONFIG_WAV_DEMUXER) += wav.o riff.o raw.o OBJS-$(CONFIG_WAV_MUXER) += wav.o riff.o OBJS-$(CONFIG_WC3_DEMUXER) += wc3movie.o +OBJS-$(CONFIG_WEBM_MUXER) += matroskaenc.o matroska.o \ + riff.o isom.o avc.o \ + flacenc_header.o OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o id3v1.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 27dba103d2..27a955594b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -203,6 +203,7 @@ void av_register_all(void) REGISTER_DEMUXER (W64, w64); REGISTER_MUXDEMUX (WAV, wav); REGISTER_DEMUXER (WC3, wc3); + REGISTER_MUXER (WEBM, webm); REGISTER_DEMUXER (WSAUD, wsaud); REGISTER_DEMUXER (WSVQA, wsvqa); REGISTER_DEMUXER (WV, wv); diff --git a/libavformat/avformat.h b/libavformat/avformat.h index c312d98ab8..0e93376bdb 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -23,7 +23,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 52 #define LIBAVFORMAT_VERSION_MINOR 64 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MICRO 2 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 01e6e79f3f..c004bd6464 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -65,7 +65,11 @@ typedef struct { int write_dts; } mkv_track; +#define MODE_MATROSKAv2 0x01 +#define MODE_WEBM 0x02 + typedef struct MatroskaMuxContext { + int mode; ByteIOContext *dyn_bc; ebml_master segment; int64_t segment_offset; @@ -563,6 +567,13 @@ static int mkv_write_tracks(AVFormatContext *s) } } + if (mkv->mode == MODE_WEBM && !(codec->codec_id == CODEC_ID_VP8 || + codec->codec_id == CODEC_ID_VORBIS)) { + av_log(s, AV_LOG_ERROR, + "Only VP8 video and Vorbis audio are supported for WebM.\n"); + return AVERROR(EINVAL); + } + switch (codec->codec_type) { case AVMEDIA_TYPE_VIDEO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO); @@ -684,6 +695,9 @@ static int mkv_write_header(AVFormatContext *s) AVMetadataTag *tag; int ret; + if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM; + else mkv->mode = MODE_MATROSKAv2; + mkv->md5_ctx = av_mallocz(av_md5_size); av_md5_init(mkv->md5_ctx); mkv->tracks = av_mallocz(s->nb_streams * sizeof(*mkv->tracks)); @@ -693,7 +707,7 @@ static int mkv_write_header(AVFormatContext *s) put_ebml_uint (pb, EBML_ID_EBMLREADVERSION , 1); put_ebml_uint (pb, EBML_ID_EBMLMAXIDLENGTH , 4); put_ebml_uint (pb, EBML_ID_EBMLMAXSIZELENGTH , 8); - put_ebml_string (pb, EBML_ID_DOCTYPE , "matroska"); + put_ebml_string (pb, EBML_ID_DOCTYPE , s->oformat->name); put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , 2); put_ebml_uint (pb, EBML_ID_DOCTYPEREADVERSION , 2); end_ebml_master(pb, ebml_header); @@ -736,8 +750,10 @@ static int mkv_write_header(AVFormatContext *s) ret = mkv_write_tracks(s); if (ret < 0) return ret; - ret = mkv_write_chapters(s); - if (ret < 0) return ret; + if (mkv->mode != MODE_WEBM) { + ret = mkv_write_chapters(s); + if (ret < 0) return ret; + } if (url_is_streamed(s->pb)) mkv_write_seekhead(pb, mkv->main_seekhead); @@ -974,6 +990,7 @@ static int mkv_write_trailer(AVFormatContext *s) return 0; } +#if CONFIG_MATROSKA_MUXER AVOutputFormat matroska_muxer = { "matroska", NULL_IF_CONFIG_SMALL("Matroska file format"), @@ -989,7 +1006,25 @@ AVOutputFormat matroska_muxer = { .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, .subtitle_codec = CODEC_ID_TEXT, }; +#endif +#if CONFIG_WEBM_MUXER +AVOutputFormat webm_muxer = { + "webm", + NULL_IF_CONFIG_SMALL("WebM file format"), + "video/webm", + "webm", + sizeof(MatroskaMuxContext), + CODEC_ID_VORBIS, + CODEC_ID_VP8, + mkv_write_header, + mkv_write_packet, + mkv_write_trailer, + .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, +}; +#endif + +#if CONFIG_MATROSKA_AUDIO_MUXER AVOutputFormat matroska_audio_muxer = { "matroska", NULL_IF_CONFIG_SMALL("Matroska file format"), @@ -1004,3 +1039,4 @@ AVOutputFormat matroska_audio_muxer = { .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0}, }; +#endif From 3229bf85735613dfe2370e51eb3ddbe9adc78f12 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 9 Jun 2010 15:55:02 +0000 Subject: [PATCH 097/301] librtmp may link to different ssl implementations Make sure we link using the right libs by using pkg-config backport r23511 by lu_zero Originally committed as revision 23550 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index cdec2f59a3..783e59d62d 100755 --- a/configure +++ b/configure @@ -2610,7 +2610,7 @@ enabled libnut && require libnut libnut.h nut_demuxer_init -lnut enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg -enabled librtmp && require librtmp librtmp/rtmp.h RTMP_Init -lrtmp +enabled librtmp && require librtmp librtmp/rtmp.h RTMP_Init $(pkg-config --libs librtmp) enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0) enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex From 05b4e4fe49af2db8e0308e7b451830e48be9209c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 10 Jun 2010 08:10:32 +0000 Subject: [PATCH 098/301] remove redundant changelog entry Originally committed as revision 23560 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 1 - 1 file changed, 1 deletion(-) diff --git a/Changelog b/Changelog index ef59fd7e17..1ecc118cdc 100644 --- a/Changelog +++ b/Changelog @@ -78,7 +78,6 @@ version 0.6: - faster H.264 decoding - WebM support in Matroska de/muxer - low overhead Ogg muxing -- WebM support in Matroska demuxer - VP8 de/encoding via libvpx - CODEC_CAP_EXPERIMENTAL added From 03b47bb8d7364d77a205c6aa2abadfbc6643c702 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 15 Jun 2010 12:29:19 +0000 Subject: [PATCH 099/301] add symver hacks for gnu linkers this patch restores binary compatibility for the av_*_packet symbols that have been moved from libavformat to libavcodec. This patch works for gnu toolchains only; support for ARM RCVT will be handed in for a later point release as soon as the patch is ready and approved by the ARM maintainer(s). Originally committed as revision 23610 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 8 +++++++- libavformat/utils.c | 48 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 783e59d62d..fba5a5312e 100755 --- a/configure +++ b/configure @@ -1086,6 +1086,7 @@ HAVE_LIST=" struct_sockaddr_in6 struct_sockaddr_sa_len struct_sockaddr_storage + gnu_symbol_versioning sys_mman_h sys_resource_h sys_select_h @@ -2733,7 +2734,12 @@ check_ldflags -Wl,-Bsymbolic echo "X{};" > $TMPV test_ldflags -Wl,--version-script,$TMPV && - append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' + append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' && + check_cc < Date: Tue, 15 Jun 2010 13:29:20 +0000 Subject: [PATCH 100/301] revert r23610, better patch is pending Originally committed as revision 23612 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 8 +------- libavformat/utils.c | 48 +-------------------------------------------- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/configure b/configure index fba5a5312e..783e59d62d 100755 --- a/configure +++ b/configure @@ -1086,7 +1086,6 @@ HAVE_LIST=" struct_sockaddr_in6 struct_sockaddr_sa_len struct_sockaddr_storage - gnu_symbol_versioning sys_mman_h sys_resource_h sys_select_h @@ -2734,12 +2733,7 @@ check_ldflags -Wl,-Bsymbolic echo "X{};" > $TMPV test_ldflags -Wl,--version-script,$TMPV && - append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' && - check_cc < Date: Tue, 15 Jun 2010 13:31:27 +0000 Subject: [PATCH 101/301] Add compatibility wrappers for functions moved from lavf to lavc When symbol versioning is enabled, moving symbols from one library to another breaks binary compatibility. This adds wrappers with the old version tag for the av_*packet functions recently moved to lavc. backport r23611 by mru Originally committed as revision 23613 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 16 +++++++++++++++- libavformat/utils.c | 32 +++++++++++++++++++++++++++++++- libavutil/internal.h | 11 +++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 783e59d62d..ac09f808bd 100755 --- a/configure +++ b/configure @@ -1086,6 +1086,9 @@ HAVE_LIST=" struct_sockaddr_in6 struct_sockaddr_sa_len struct_sockaddr_storage + symver + symver_gnu_asm + symver_asm_label sys_mman_h sys_resource_h sys_select_h @@ -1200,6 +1203,8 @@ fast_unaligned_if_any="armv6 ppc x86" need_memalign="altivec neon sse" inline_asm_deps="!tms470" +symver_if_any="symver_asm_label symver_gnu_asm" + # subsystems mdct_select="fft" rdft_select="fft" @@ -2732,8 +2737,17 @@ check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUI check_ldflags -Wl,-Bsymbolic echo "X{};" > $TMPV -test_ldflags -Wl,--version-script,$TMPV && +if test_ldflags -Wl,--version-script,$TMPV; then append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' + check_cc < Date: Tue, 15 Jun 2010 19:44:09 +0000 Subject: [PATCH 102/301] Fix symbol version compat wrappers on systems with export prefixes backport r23615 by mru Originally committed as revision 23617 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/internal.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index e5dd8b9549..fe8a6fa6b5 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -205,13 +205,13 @@ #endif #if HAVE_SYMVER_ASM_LABEL -# define FF_SYMVER(type, name, args, ver) \ - type ff_##name args __asm__ (#name "@" ver); \ +# define FF_SYMVER(type, name, args, ver) \ + type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \ type ff_##name args #elif HAVE_SYMVER_GNU_ASM -# define FF_SYMVER(type, name, args, ver) \ - __asm__ (".symver ff_" #name "," #name "@" ver); \ - type ff_##name args; \ +# define FF_SYMVER(type, name, args, ver) \ + __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \ + type ff_##name args; \ type ff_##name args #endif From d7e98ea6acd0e01b26ec1084eb00b9cb06e59111 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 15 Jun 2010 19:44:30 +0000 Subject: [PATCH 103/301] configure: fix symver detection with icc 10 Apparently the compiler sometimes bypasses the normal assembler, in which case the asm label variant works. If the file contains any inline asm, this bypassing is not done, and the assembler chokes on invalid syntax. Inserting a dummy asm() statement in the test when the compiler supports it makes sure no shortcuts are taken and the test fails as it should. backport r23616 by mru Originally committed as revision 23618 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index ac09f808bd..0166829f77 100755 --- a/configure +++ b/configure @@ -253,6 +253,8 @@ EOF exit 0 } +quotes='""' + log(){ echo "$@" >> $logfile } @@ -2741,7 +2743,7 @@ if test_ldflags -Wl,--version-script,$TMPV; then append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' check_cc < Date: Wed, 16 Jun 2010 06:10:30 +0000 Subject: [PATCH 104/301] remove note that libvpx was considered (L)GPL incompatible Originally committed as revision 23623 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 1 - 1 file changed, 1 deletion(-) diff --git a/RELEASE b/RELEASE index c68e42a272..29bbf771af 100644 --- a/RELEASE +++ b/RELEASE @@ -93,4 +93,3 @@ Notable license related changes - remaining GPL parts in AC-3 decoder converted to LGPL - libswscale can now be compiled in LGPL mode -- libvpx is considered (L)GPL incompatible From 55b6e09e5e68074a2fdee184ea23596ba735eeb5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 21 Jun 2010 09:17:19 +0000 Subject: [PATCH 105/301] Fix two small typos. Originally committed as revision 23678 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASE b/RELEASE index 29bbf771af..fab225d852 100644 --- a/RELEASE +++ b/RELEASE @@ -7,9 +7,9 @@ General notes ------------- This release features a lot of improvements that are relevant for HTML5 video. -The H.264 and Theora decoders are now significantly faster, the vorbis decoder +The H.264 and Theora decoders are now significantly faster, the Vorbis decoder has seen important updates and this release supports Google's newly released -libvpx library for the VP8 codec and WEBM container. +libvpx library for the VP8 codec and WebM container. Other important changes are additions of decoders including, but not limited to, Intel Indeo 5, WMA Pro, WMA Voice and HE-AAC. From b9ebd7dc7d6e22f2c2bcbc8709897fe44798146a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 24 Jun 2010 05:46:58 +0000 Subject: [PATCH 106/301] 10l: aacsbr: Fix f_master[2] calculation when k2diff == -1. backport r23660 by alexc Originally committed as revision 23747 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/aacsbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 0de81a5025..0de89c2315 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -402,7 +402,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; if (k2diff < 0) { sbr->f_master[1]--; - sbr->f_master[2]-= (k2diff < 1); + sbr->f_master[2]-= (k2diff < -1); } else if (k2diff) { sbr->f_master[sbr->n_master]++; } From 32fa7cecd7a1585094586d53f513f260a9271891 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Dupas Date: Sat, 26 Jun 2010 14:24:14 +0000 Subject: [PATCH 107/301] Some fields were incorrectly reset (to NULL) when calling avcodec_copy_context(). Patch by Jean-Daniel Dupas, devlists shadowlab org backport r23344 by cehoyos Originally committed as revision 23793 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/options.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/options.c b/libavcodec/options.c index 6835352c30..97d705ebc0 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -488,9 +488,6 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) dest->slice_offset = NULL; dest->internal_buffer = NULL; dest->hwaccel = NULL; - dest->execute = NULL; - dest->execute2 = NULL; - dest->reget_buffer = NULL; dest->thread_opaque = NULL; /* reallocate values that should be allocated separately */ From edf5072fea9955567e9143298491e08eaccde925 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 26 Jun 2010 15:32:27 +0000 Subject: [PATCH 108/301] Doxygen av_codec_get_id() and av_codec_get_tag(). backport r23102 by stefano Originally committed as revision 23801 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/avformat.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 0e93376bdb..dbd22bb80d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -869,8 +869,22 @@ void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); */ void av_register_all(void); -/** codec tag <-> codec id */ +/** + * Gets the CodecID for the given codec tag tag. + * If no codec id is found returns CODEC_ID_NONE. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + */ enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); + +/** + * Gets the codec tag for the given codec id id. + * If no codec tag is found returns 0. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + */ unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id); /* media file input */ From 9d1213912f57080b3d314b5d7ab0950d84cf930c Mon Sep 17 00:00:00 2001 From: Google <> Date: Mon, 28 Jun 2010 20:38:36 +0000 Subject: [PATCH 109/301] Add VP80 fourcc Patch by Google backport r23193 by conrad Originally committed as revision 23863 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 04b710854a..64464caa5d 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -183,6 +183,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') }, { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') }, { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') }, + { CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') }, { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') }, { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, From 61eb1655141747886fe2fc43036e0402015777f3 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 9 Jul 2010 01:16:42 +0000 Subject: [PATCH 110/301] ac3: make the value of codec_id during (E-)AC-3 parsing stay CODEC_ID_EAC3 if any E-AC-3 frames have been detected instead of switching back and forth for AC-3 core + dependent E-AC-3 substream(s). Fixes Issue 2022. backport r24103 by jbr Originally committed as revision 24136 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/ac3_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index 856f97aafb..6cd666b4fb 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -181,7 +181,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, hdr_info->samples = hdr.num_blocks * 256; if(hdr.bitstream_id>10) hdr_info->codec_id = CODEC_ID_EAC3; - else + else if (hdr_info->codec_id == CODEC_ID_NONE) hdr_info->codec_id = CODEC_ID_AC3; *need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT); From 93883b0c390c87f85e6f7bb22428d789bc842b12 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 19 Jul 2010 19:51:29 +0000 Subject: [PATCH 111/301] aviobuf: Do short seeks forward by reading and skipping data instead of a proper seek This improves performance on e.g. seekable http. backport r24280 by mstorsjo Originally committed as revision 24335 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavformat/aviobuf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 8684903464..2a2fb78169 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -27,6 +27,13 @@ #define IO_BUFFER_SIZE 32768 +/** + * Do seeks within this distance ahead of the current buffer by skipping + * data instead of calling the protocol seek function, for seekable + * protocols. + */ +#define SHORT_SEEK_THRESHOLD 4096 + static void fill_buffer(ByteIOContext *s); #if LIBAVFORMAT_VERSION_MAJOR >= 53 static int url_resetbuf(ByteIOContext *s, int flags); @@ -152,7 +159,9 @@ int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence) offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) { /* can do the seek inside the buffer */ s->buf_ptr = s->buffer + offset1; - } else if(s->is_streamed && !s->write_flag && offset1 >= 0 && + } else if ((s->is_streamed || + offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) && + !s->write_flag && offset1 >= 0 && (whence != SEEK_END || force)) { while(s->pos < offset && !s->eof_reached) fill_buffer(s); From ba90f93852a3a0f9f9edc014338d3ac381be14f3 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 28 Jul 2010 20:14:28 +0000 Subject: [PATCH 112/301] Backport AAC-HE v2 from trunk This patch has seen testing for a couple of weeks in ubuntu maverick and debian/experimental w/o negative feedback so far. Originally committed as revision 24576 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/Makefile | 2 +- libavcodec/aac.h | 13 +- libavcodec/aac_tablegen.c | 39 ++ libavcodec/aac_tablegen.h | 42 ++ libavcodec/aac_tablegen_decl.h | 34 ++ libavcodec/{aac.c => aacdec.c} | 174 +++--- libavcodec/aacenc.c | 25 +- libavcodec/aacenc.h | 2 +- libavcodec/aacps.c | 1037 ++++++++++++++++++++++++++++++++ libavcodec/aacps.h | 82 +++ libavcodec/aacps_tablegen.c | 93 +++ libavcodec/aacps_tablegen.h | 212 +++++++ libavcodec/aacpsdata.c | 163 +++++ libavcodec/aacsbr.c | 157 ++--- libavcodec/aactab.c | 127 +--- libavcodec/aactab.h | 7 +- libavcodec/sbr.h | 6 +- 17 files changed, 1908 insertions(+), 307 deletions(-) create mode 100644 libavcodec/aac_tablegen.c create mode 100644 libavcodec/aac_tablegen.h create mode 100644 libavcodec/aac_tablegen_decl.h rename libavcodec/{aac.c => aacdec.c} (92%) create mode 100644 libavcodec/aacps.c create mode 100644 libavcodec/aacps.h create mode 100644 libavcodec/aacps_tablegen.c create mode 100644 libavcodec/aacps_tablegen.h create mode 100644 libavcodec/aacpsdata.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 00e6b57fd3..4547ef60ca 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -43,7 +43,7 @@ OBJS-$(CONFIG_VAAPI) += vaapi.o OBJS-$(CONFIG_VDPAU) += vdpau.o # decoders/encoders/hardware accelerators -OBJS-$(CONFIG_AAC_DECODER) += aac.o aactab.o aacsbr.o +OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o iirfilter.o \ diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 1a8aa6c145..94f578ff38 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -38,12 +38,6 @@ #include -#define AAC_INIT_VLC_STATIC(num, size) \ - INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ - ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \ - ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \ - size); - #define MAX_CHANNELS 64 #define MAX_ELEM_ID 16 @@ -241,7 +235,7 @@ typedef struct { * main AAC context */ typedef struct { - AVCodecContext * avccontext; + AVCodecContext *avctx; MPEG4AudioConfig m4ac; @@ -255,8 +249,9 @@ typedef struct { enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the * first index as the first 4 raw data block types */ - ChannelElement * che[4][MAX_ELEM_ID]; - ChannelElement * tag_che_map[4][MAX_ELEM_ID]; + ChannelElement *che[4][MAX_ELEM_ID]; + ChannelElement *tag_che_map[4][MAX_ELEM_ID]; + uint8_t tags_seen_this_frame[4][MAX_ELEM_ID]; int tags_mapped; /** @} */ diff --git a/libavcodec/aac_tablegen.c b/libavcodec/aac_tablegen.c new file mode 100644 index 0000000000..de1c9578a7 --- /dev/null +++ b/libavcodec/aac_tablegen.c @@ -0,0 +1,39 @@ +/* + * Generate a header file for hardcoded AAC tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#include "aac_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + ff_aac_tableinit(); + + write_fileheader(); + + printf("const float ff_aac_pow2sf_tab[428] = {\n"); + write_float_array(ff_aac_pow2sf_tab, 428); + printf("};\n"); + + return 0; +} diff --git a/libavcodec/aac_tablegen.h b/libavcodec/aac_tablegen.h new file mode 100644 index 0000000000..630071dd1d --- /dev/null +++ b/libavcodec/aac_tablegen.h @@ -0,0 +1,42 @@ +/* + * Header file for hardcoded AAC tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AAC_TABLEGEN_H +#define AAC_TABLEGEN_H + +#include "aac_tablegen_decl.h" + +#if CONFIG_HARDCODED_TABLES +#include "libavcodec/aac_tables.h" +#else +#include "../libavutil/mathematics.h" +float ff_aac_pow2sf_tab[428]; + +void ff_aac_tableinit(void) +{ + int i; + for (i = 0; i < 428; i++) + ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AAC_TABLEGEN_H */ diff --git a/libavcodec/aac_tablegen_decl.h b/libavcodec/aac_tablegen_decl.h new file mode 100644 index 0000000000..7157c80461 --- /dev/null +++ b/libavcodec/aac_tablegen_decl.h @@ -0,0 +1,34 @@ +/* + * Header file for hardcoded AAC tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AAC_TABLEGEN_INIT_H +#define AAC_TABLEGEN_INIT_H + +#if CONFIG_HARDCODED_TABLES +#define ff_aac_tableinit() +extern const float ff_aac_pow2sf_tab[428]; +#else +void ff_aac_tableinit(void); +extern float ff_aac_pow2sf_tab[428]; +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AAC_TABLEGEN_INIT_H */ diff --git a/libavcodec/aac.c b/libavcodec/aacdec.c similarity index 92% rename from libavcodec/aac.c rename to libavcodec/aacdec.c index 3330e1cefe..e375d1f98b 100644 --- a/libavcodec/aac.c +++ b/libavcodec/aacdec.c @@ -67,7 +67,7 @@ * Y (not in this code) Layer-2 * Y (not in this code) Layer-3 * N SinuSoidal Coding (Transient, Sinusoid, Noise) - * N (planned) Parametric Stereo + * Y Parametric Stereo * N Direct Stream Transfer * * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. @@ -113,6 +113,22 @@ static const char overread_err[] = "Input buffer exhausted before END element fo static ChannelElement *get_che(AACContext *ac, int type, int elem_id) { + /* Some buggy encoders appear to set all elem_ids to zero and rely on + channels always occurring in the same order. This is expressly forbidden + by the spec but we will try to work around it. + */ + int err_printed = 0; + while (ac->tags_seen_this_frame[type][elem_id] && elem_id < MAX_ELEM_ID) { + if (ac->output_configured < OC_LOCKED && !err_printed) { + av_log(ac->avctx, AV_LOG_WARNING, "Duplicate channel tag found, attempting to remap.\n"); + err_printed = 1; + } + elem_id++; + } + if (elem_id == MAX_ELEM_ID) + return NULL; + ac->tags_seen_this_frame[type][elem_id] = 1; + if (ac->tag_che_map[type][elem_id]) { return ac->tag_che_map[type][elem_id]; } @@ -127,8 +143,8 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id) } case 6: /* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1] - instead of SCE[0] CPE[0] CPE[0] LFE[0]. If we seem to have - encountered such a stream, transfer the LFE[0] element to SCE[1] */ + instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have + encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */ if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { ac->tags_mapped++; return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; @@ -184,7 +200,8 @@ static av_cold int che_configure(AACContext *ac, ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr); if (type != TYPE_CCE) { ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; - if (type == TYPE_CPE) { + if (type == TYPE_CPE || + (type == TYPE_SCE && ac->m4ac.ps == 1)) { ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret; } } @@ -209,9 +226,10 @@ static av_cold int output_configure(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], int channel_config, enum OCStatus oc_type) { - AVCodecContext *avctx = ac->avccontext; + AVCodecContext *avctx = ac->avctx; int i, type, channels = 0, ret; + if (new_che_pos != che_pos) memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); if (channel_config) { @@ -292,7 +310,7 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL sampling_index = get_bits(gb, 4); if (ac->m4ac.sampling_index != sampling_index) - av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n"); + av_log(ac->avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n"); num_front = get_bits(gb, 4); num_side = get_bits(gb, 4); @@ -323,7 +341,7 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL /* comment field, first byte is length */ comment_len = get_bits(gb, 8) * 8; if (get_bits_left(gb) < comment_len) { - av_log(ac->avccontext, AV_LOG_ERROR, overread_err); + av_log(ac->avctx, AV_LOG_ERROR, overread_err); return -1; } skip_bits_long(gb, comment_len); @@ -343,7 +361,7 @@ static av_cold int set_default_channel_config(AACContext *ac, int channel_config) { if (channel_config < 1 || channel_config > 7) { - av_log(ac->avccontext, AV_LOG_ERROR, "invalid default channel configuration (%d)\n", + av_log(ac->avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n", channel_config); return -1; } @@ -388,7 +406,7 @@ static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb, int extension_flag, ret; if (get_bits1(gb)) { // frameLengthFlag - av_log_missing_feature(ac->avccontext, "960/120 MDCT window is", 1); + av_log_missing_feature(ac->avctx, "960/120 MDCT window is", 1); return -1; } @@ -452,9 +470,11 @@ static int decode_audio_specific_config(AACContext *ac, void *data, if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0) return -1; if (ac->m4ac.sampling_index > 12) { - av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); + av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); return -1; } + if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1) + ac->m4ac.ps = 1; skip_bits_long(&gb, i); @@ -465,7 +485,7 @@ static int decode_audio_specific_config(AACContext *ac, void *data, return -1; break; default: - av_log(ac->avccontext, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n", + av_log(ac->avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n", ac->m4ac.sbr == 1? "SBR+" : "", ac->m4ac.object_type); return -1; } @@ -508,20 +528,25 @@ static void reset_predictor_group(PredictorState *ps, int group_num) reset_predict_state(&ps[i]); } -static av_cold int aac_decode_init(AVCodecContext *avccontext) +#define AAC_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ + ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \ + ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \ + size); + +static av_cold int aac_decode_init(AVCodecContext *avctx) { - AACContext *ac = avccontext->priv_data; - int i; + AACContext *ac = avctx->priv_data; - ac->avccontext = avccontext; - ac->m4ac.sample_rate = avccontext->sample_rate; + ac->avctx = avctx; + ac->m4ac.sample_rate = avctx->sample_rate; - if (avccontext->extradata_size > 0) { - if (decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size)) + if (avctx->extradata_size > 0) { + if (decode_audio_specific_config(ac, avctx->extradata, avctx->extradata_size)) return -1; } - avccontext->sample_fmt = SAMPLE_FMT_S16; + avctx->sample_fmt = SAMPLE_FMT_S16; AAC_INIT_VLC_STATIC( 0, 304); AAC_INIT_VLC_STATIC( 1, 270); @@ -537,7 +562,7 @@ static av_cold int aac_decode_init(AVCodecContext *avccontext) ff_aac_sbr_init(); - dsputil_init(&ac->dsp, avccontext); + dsputil_init(&ac->dsp, avctx); ac->random_state = 0x1f2e3d4c; @@ -555,10 +580,7 @@ static av_cold int aac_decode_init(AVCodecContext *avccontext) ac->sf_offset = 60; } -#if !CONFIG_HARDCODED_TABLES - for (i = 0; i < 428; i++) - ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); -#endif /* CONFIG_HARDCODED_TABLES */ + ff_aac_tableinit(); INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]), @@ -591,7 +613,7 @@ static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) align_get_bits(gb); if (get_bits_left(gb) < 8 * count) { - av_log(ac->avccontext, AV_LOG_ERROR, overread_err); + av_log(ac->avctx, AV_LOG_ERROR, overread_err); return -1; } skip_bits_long(gb, 8 * count); @@ -605,7 +627,7 @@ static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, if (get_bits1(gb)) { ics->predictor_reset_group = get_bits(gb, 5); if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) { - av_log(ac->avccontext, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n"); return -1; } } @@ -624,7 +646,7 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, GetBitContext *gb, int common_window) { if (get_bits1(gb)) { - av_log(ac->avccontext, AV_LOG_ERROR, "Reserved bit set.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); memset(ics, 0, sizeof(IndividualChannelStream)); return -1; } @@ -665,11 +687,11 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, return -1; } } else if (ac->m4ac.object_type == AOT_AAC_LC) { - av_log(ac->avccontext, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); memset(ics, 0, sizeof(IndividualChannelStream)); return -1; } else { - av_log_missing_feature(ac->avccontext, "Predictor bit set but LTP is", 1); + av_log_missing_feature(ac->avctx, "Predictor bit set but LTP is", 1); memset(ics, 0, sizeof(IndividualChannelStream)); return -1; } @@ -677,7 +699,7 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, } if (ics->max_sfb > ics->num_swb) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Number of scalefactor bands in group (%d) exceeds limit (%d).\n", ics->max_sfb, ics->num_swb); memset(ics, 0, sizeof(IndividualChannelStream)); @@ -708,18 +730,18 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120], int sect_len_incr; int sect_band_type = get_bits(gb, 4); if (sect_band_type == 12) { - av_log(ac->avccontext, AV_LOG_ERROR, "invalid band type\n"); + av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); return -1; } while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1) sect_end += sect_len_incr; sect_end += sect_len_incr; if (get_bits_left(gb) < 0) { - av_log(ac->avccontext, AV_LOG_ERROR, overread_err); + av_log(ac->avctx, AV_LOG_ERROR, overread_err); return -1; } if (sect_end > ics->max_sfb) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Number of bands (%d) exceeds limit (%d).\n", sect_end, ics->max_sfb); return -1; @@ -764,7 +786,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, for (; i < run_end; i++, idx++) { offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (offset[2] > 255U) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "%s (%d) out of range.\n", sf_str[2], offset[2]); return -1; } @@ -777,7 +799,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, else offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (offset[1] > 255U) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "%s (%d) out of range.\n", sf_str[1], offset[1]); return -1; } @@ -787,7 +809,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, for (; i < run_end; i++, idx++) { offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (offset[0] > 255U) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "%s (%d) out of range.\n", sf_str[0], offset[0]); return -1; } @@ -844,7 +866,7 @@ static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, tns->length[w][filt] = get_bits(gb, 6 - 2 * is8); if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) { - av_log(ac->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n", + av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n", tns->order[w][filt], tns_max_order); tns->order[w][filt] = 0; return -1; @@ -1163,7 +1185,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], b = 31 - av_log2(~b); if (b > 8) { - av_log(ac->avccontext, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); + av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); return -1; } @@ -1216,7 +1238,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], return 0; err_cb_overflow: - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Read beyond end of ff_aac_codebook_vectors[%d][]. index %d >= %d\n", band_type[idx], err_idx, ff_aac_spectral_sizes[band_type[idx]]); return -1; @@ -1337,18 +1359,18 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, if (!scale_flag) { if ((pulse_present = get_bits1(gb))) { if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - av_log(ac->avccontext, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n"); return -1; } if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) { - av_log(ac->avccontext, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n"); return -1; } } if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics)) return -1; if (get_bits1(gb)) { - av_log_missing_feature(ac->avccontext, "SSR", 1); + av_log_missing_feature(ac->avctx, "SSR", 1); return -1; } } @@ -1448,7 +1470,7 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) cpe->ch[1].ics.use_kb_window[1] = i; ms_present = get_bits(gb, 2); if (ms_present == 3) { - av_log(ac->avccontext, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); return -1; } else if (ms_present) decode_mid_side_stereo(cpe, gb, ms_present); @@ -1635,16 +1657,20 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, crc_flag++; case EXT_SBR_DATA: if (!che) { - av_log(ac->avccontext, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); return res; } else if (!ac->m4ac.sbr) { - av_log(ac->avccontext, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); skip_bits_long(gb, 8 * cnt - 4); return res; } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) { - av_log(ac->avccontext, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); skip_bits_long(gb, 8 * cnt - 4); return res; + } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) { + ac->m4ac.sbr = 1; + ac->m4ac.ps = 1; + output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured); } else { ac->m4ac.sbr = 1; } @@ -1728,7 +1754,7 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float // imdct if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { if (ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) - av_log(ac->avccontext, AV_LOG_WARNING, + av_log(ac->avctx, AV_LOG_WARNING, "Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. " "If you heard an audible artifact, please submit the sample to the FFmpeg developers.\n"); for (i = 0; i < 1024; i += 128) @@ -1794,7 +1820,7 @@ static void apply_dependent_coupling(AACContext *ac, const float *src = cce->ch[0].coeffs; int g, i, group, k, idx = 0; if (ac->m4ac.object_type == AOT_AAC_LTP) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Dependent coupling is not supported together with LTP\n"); return; } @@ -1924,58 +1950,65 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) } else if (ac->output_configured != OC_LOCKED) { ac->output_configured = OC_NONE; } - if (ac->output_configured != OC_LOCKED) + if (ac->output_configured != OC_LOCKED) { ac->m4ac.sbr = -1; + ac->m4ac.ps = -1; + } ac->m4ac.sample_rate = hdr_info.sample_rate; ac->m4ac.sampling_index = hdr_info.sampling_index; ac->m4ac.object_type = hdr_info.object_type; - if (!ac->avccontext->sample_rate) - ac->avccontext->sample_rate = hdr_info.sample_rate; + if (!ac->avctx->sample_rate) + ac->avctx->sample_rate = hdr_info.sample_rate; if (hdr_info.num_aac_frames == 1) { if (!hdr_info.crc_absent) skip_bits(gb, 16); } else { - av_log_missing_feature(ac->avccontext, "More than one AAC RDB per ADTS frame is", 0); + av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS frame is", 0); return -1; } } return size; } -static int aac_decode_frame(AVCodecContext *avccontext, void *data, +static int aac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - AACContext *ac = avccontext->priv_data; + AACContext *ac = avctx->priv_data; ChannelElement *che = NULL, *che_prev = NULL; GetBitContext gb; enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; int err, elem_id, data_size_tmp; int buf_consumed; - int samples = 1024, multiplier; + int samples = 0, multiplier; int buf_offset; init_get_bits(&gb, buf, buf_size * 8); if (show_bits(&gb, 12) == 0xfff) { if (parse_adts_frame_header(ac, &gb) < 0) { - av_log(avccontext, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); + av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); return -1; } if (ac->m4ac.sampling_index > 12) { - av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); + av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); return -1; } } + memset(ac->tags_seen_this_frame, 0, sizeof(ac->tags_seen_this_frame)); // parse while ((elem_type = get_bits(&gb, 3)) != TYPE_END) { elem_id = get_bits(&gb, 4); - if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) { - av_log(ac->avccontext, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id); - return -1; + if (elem_type < TYPE_DSE) { + if (!(che=get_che(ac, elem_type, elem_id))) { + av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", + elem_type, elem_id); + return -1; + } + samples = 1024; } switch (elem_type) { @@ -2006,7 +2039,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, if ((err = decode_pce(ac, new_che_pos, &gb))) break; if (ac->output_configured > OC_TRIAL_PCE) - av_log(avccontext, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Not evaluating a further program_config_element as this construct is dubious at best.\n"); else err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE); @@ -2017,7 +2050,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, if (elem_id == 15) elem_id += get_bits(&gb, 8) - 1; if (get_bits_left(&gb) < 8 * elem_id) { - av_log(avccontext, AV_LOG_ERROR, overread_err); + av_log(avctx, AV_LOG_ERROR, overread_err); return -1; } while (elem_id > 0) @@ -2037,7 +2070,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, return err; if (get_bits_left(&gb) < 3) { - av_log(avccontext, AV_LOG_ERROR, overread_err); + av_log(avctx, AV_LOG_ERROR, overread_err); return -1; } } @@ -2047,20 +2080,21 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0; samples <<= multiplier; if (ac->output_configured < OC_LOCKED) { - avccontext->sample_rate = ac->m4ac.sample_rate << multiplier; - avccontext->frame_size = samples; + avctx->sample_rate = ac->m4ac.sample_rate << multiplier; + avctx->frame_size = samples; } - data_size_tmp = samples * avccontext->channels * sizeof(int16_t); + data_size_tmp = samples * avctx->channels * sizeof(int16_t); if (*data_size < data_size_tmp) { - av_log(avccontext, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n", *data_size, data_size_tmp); return -1; } *data_size = data_size_tmp; - ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avccontext->channels); + if (samples) + ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels); if (ac->output_configured) ac->output_configured = OC_LOCKED; @@ -2073,9 +2107,9 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, return buf_size > buf_offset ? buf_consumed : buf_size; } -static av_cold int aac_decode_close(AVCodecContext *avccontext) +static av_cold int aac_decode_close(AVCodecContext *avctx) { - AACContext *ac = avccontext->priv_data; + AACContext *ac = avctx->priv_data; int i, type; for (i = 0; i < MAX_ELEM_ID; i++) { diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 90dff15dd5..8c913e0dbc 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -201,13 +201,11 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) lengths[1] = ff_aac_num_swb_128[i]; ff_psy_init(&s->psy, avctx, 2, sizes, lengths); s->psypp = ff_psy_preprocess_init(avctx); - s->coder = &ff_aac_coders[0]; + s->coder = &ff_aac_coders[2]; s->lambda = avctx->global_quality ? avctx->global_quality : 120; -#if !CONFIG_HARDCODED_TABLES - for (i = 0; i < 428; i++) - ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); -#endif /* CONFIG_HARDCODED_TABLES */ + + ff_aac_tableinit(); if (avctx->channels > 5) av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. " @@ -234,25 +232,21 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, s->output[i] = sce->saved[i]; } if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) { - j = channel; - for (i = 0; i < 1024; i++, j += avctx->channels) { + for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) { s->output[i+1024] = audio[j] * lwindow[1024 - i - 1]; sce->saved[i] = audio[j] * lwindow[i]; } } else { - j = channel; - for (i = 0; i < 448; i++, j += avctx->channels) + for (i = 0, j = channel; i < 448; i++, j += avctx->channels) s->output[i+1024] = audio[j]; - for (i = 448; i < 576; i++, j += avctx->channels) + for (; i < 576; i++, j += avctx->channels) s->output[i+1024] = audio[j] * swindow[576 - i - 1]; memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448); - j = channel; - for (i = 0; i < 1024; i++, j += avctx->channels) + for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) sce->saved[i] = audio[j]; } ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output); } else { - j = channel; for (k = 0; k < 1024; k += 128) { for (i = 448 + k; i < 448 + k + 256; i++) s->output[i - 448 - k] = (i < 1024) @@ -262,8 +256,7 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128); ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output); } - j = channel; - for (i = 0; i < 1024; i++, j += avctx->channels) + for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) sce->saved[i] = audio[j]; } } @@ -562,6 +555,7 @@ static int aac_encode_frame(AVCodecContext *avctx, cpe = &s->cpe[i]; for (j = 0; j < chans; j++) { s->cur_channel = start_ch + j; + ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]); s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda); } cpe->common_window = 0; @@ -592,7 +586,6 @@ static int aac_encode_frame(AVCodecContext *avctx, } for (j = 0; j < chans; j++) { s->cur_channel = start_ch + j; - ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]); encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window); } start_ch += chans; diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index e99be98048..86c68d3e16 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -64,7 +64,7 @@ typedef struct AACEncContext { int cur_channel; int last_frame; float lambda; - DECLARE_ALIGNED(16, int, qcoefs)[96][2]; ///< quantized coefficients + DECLARE_ALIGNED(16, int, qcoefs)[96]; ///< quantized coefficients DECLARE_ALIGNED(16, float, scoefs)[1024]; ///< scaled coefficients } AACEncContext; diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c new file mode 100644 index 0000000000..fc124d1972 --- /dev/null +++ b/libavcodec/aacps.c @@ -0,0 +1,1037 @@ +/* + * MPEG-4 Parametric Stereo decoding functions + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#include "avcodec.h" +#include "get_bits.h" +#include "aacps.h" +#include "aacps_tablegen.h" +#include "aacpsdata.c" + +#define PS_BASELINE 0 //< Operate in Baseline PS mode + //< Baseline implies 10 or 20 stereo bands, + //< mixing mode A, and no ipd/opd + +#define numQMFSlots 32 //numTimeSlots * RATE + +static const int8_t num_env_tab[2][4] = { + { 0, 1, 2, 4, }, + { 1, 2, 3, 4, }, +}; + +static const int8_t nr_iidicc_par_tab[] = { + 10, 20, 34, 10, 20, 34, +}; + +static const int8_t nr_iidopd_par_tab[] = { + 5, 11, 17, 5, 11, 17, +}; + +enum { + huff_iid_df1, + huff_iid_dt1, + huff_iid_df0, + huff_iid_dt0, + huff_icc_df, + huff_icc_dt, + huff_ipd_df, + huff_ipd_dt, + huff_opd_df, + huff_opd_dt, +}; + +static const int huff_iid[] = { + huff_iid_df0, + huff_iid_df1, + huff_iid_dt0, + huff_iid_dt1, +}; + +static VLC vlc_ps[10]; + +/** + * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ + * Inter-channel Phase Difference/Overall Phase Difference parameters from the + * bitstream. + * + * @param avctx contains the current codec context + * @param gb pointer to the input bitstream + * @param ps pointer to the Parametric Stereo context + * @param par pointer to the parameter to be read + * @param e envelope to decode + * @param dt 1: time delta-coded, 0: frequency delta-coded + */ +#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \ +static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \ + int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ +{ \ + int b, num = ps->nr_ ## PAR ## _par; \ + VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \ + if (dt) { \ + int e_prev = e ? e - 1 : ps->num_env_old - 1; \ + e_prev = FFMAX(e_prev, 0); \ + for (b = 0; b < num; b++) { \ + int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ + if (MASK) val &= MASK; \ + PAR[e][b] = val; \ + if (ERR_CONDITION) \ + goto err; \ + } \ + } else { \ + int val = 0; \ + for (b = 0; b < num; b++) { \ + val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ + if (MASK) val &= MASK; \ + PAR[e][b] = val; \ + if (ERR_CONDITION) \ + goto err; \ + } \ + } \ + return 0; \ +err: \ + av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \ + return -1; \ +} + +READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant) +READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U) +READ_PAR_DATA(ipdopd, 0, 0x07, 0) + +static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id) +{ + int e; + int count = get_bits_count(gb); + + if (ps_extension_id) + return 0; + + ps->enable_ipdopd = get_bits1(gb); + if (ps->enable_ipdopd) { + for (e = 0; e < ps->num_env; e++) { + int dt = get_bits1(gb); + read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt); + dt = get_bits1(gb); + read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt); + } + } + skip_bits1(gb); //reserved_ps + return get_bits_count(gb) - count; +} + +static void ipdopd_reset(int8_t *opd_hist, int8_t *ipd_hist) +{ + int i; + for (i = 0; i < PS_MAX_NR_IPDOPD; i++) { + opd_hist[i] = 0; + ipd_hist[i] = 0; + } +} + +int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) +{ + int e; + int bit_count_start = get_bits_count(gb_host); + int header; + int bits_consumed; + GetBitContext gbc = *gb_host, *gb = &gbc; + + header = get_bits1(gb); + if (header) { //enable_ps_header + ps->enable_iid = get_bits1(gb); + if (ps->enable_iid) { + int iid_mode = get_bits(gb, 3); + if (iid_mode > 5) { + av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n", + iid_mode); + goto err; + } + ps->nr_iid_par = nr_iidicc_par_tab[iid_mode]; + ps->iid_quant = iid_mode > 2; + ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode]; + } + ps->enable_icc = get_bits1(gb); + if (ps->enable_icc) { + ps->icc_mode = get_bits(gb, 3); + if (ps->icc_mode > 5) { + av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n", + ps->icc_mode); + goto err; + } + ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode]; + } + ps->enable_ext = get_bits1(gb); + } + + ps->frame_class = get_bits1(gb); + ps->num_env_old = ps->num_env; + ps->num_env = num_env_tab[ps->frame_class][get_bits(gb, 2)]; + + ps->border_position[0] = -1; + if (ps->frame_class) { + for (e = 1; e <= ps->num_env; e++) + ps->border_position[e] = get_bits(gb, 5); + } else + for (e = 1; e <= ps->num_env; e++) + ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1; + + if (ps->enable_iid) { + for (e = 0; e < ps->num_env; e++) { + int dt = get_bits1(gb); + if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt)) + goto err; + } + } else + memset(ps->iid_par, 0, sizeof(ps->iid_par)); + + if (ps->enable_icc) + for (e = 0; e < ps->num_env; e++) { + int dt = get_bits1(gb); + if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt)) + goto err; + } + else + memset(ps->icc_par, 0, sizeof(ps->icc_par)); + + if (ps->enable_ext) { + int cnt = get_bits(gb, 4); + if (cnt == 15) { + cnt += get_bits(gb, 8); + } + cnt *= 8; + while (cnt > 7) { + int ps_extension_id = get_bits(gb, 2); + cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id); + } + if (cnt < 0) { + av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d", cnt); + goto err; + } + skip_bits(gb, cnt); + } + + ps->enable_ipdopd &= !PS_BASELINE; + + //Fix up envelopes + if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) { + //Create a fake envelope + int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1; + if (source >= 0 && source != ps->num_env) { + if (ps->enable_iid) { + memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0])); + } + if (ps->enable_icc) { + memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0])); + } + if (ps->enable_ipdopd) { + memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0])); + memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0])); + } + } + ps->num_env++; + ps->border_position[ps->num_env] = numQMFSlots - 1; + } + + + ps->is34bands_old = ps->is34bands; + if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc)) + ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) || + (ps->enable_icc && ps->nr_icc_par == 34); + + //Baseline + if (!ps->enable_ipdopd) { + memset(ps->ipd_par, 0, sizeof(ps->ipd_par)); + memset(ps->opd_par, 0, sizeof(ps->opd_par)); + } + + if (header) + ps->start = 1; + + bits_consumed = get_bits_count(gb) - bit_count_start; + if (bits_consumed <= bits_left) { + skip_bits_long(gb_host, bits_consumed); + return bits_consumed; + } + av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed); +err: + ps->start = 0; + skip_bits_long(gb_host, bits_left); + return bits_left; +} + +/** Split one subband into 2 subsubbands with a symmetric real filter. + * The filter must have its non-center even coefficients equal to zero. */ +static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[7], int len, int reverse) +{ + int i, j; + for (i = 0; i < len; i++, in++) { + float re_in = filter[6] * in[6][0]; //real inphase + float re_op = 0.0f; //real out of phase + float im_in = filter[6] * in[6][1]; //imag inphase + float im_op = 0.0f; //imag out of phase + for (j = 0; j < 6; j += 2) { + re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]); + im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]); + } + out[ reverse][i][0] = re_in + re_op; + out[ reverse][i][1] = im_in + im_op; + out[!reverse][i][0] = re_in - re_op; + out[!reverse][i][1] = im_in - im_op; + } +} + +/** Split one subband into 6 subsubbands with a complex filter */ +static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int len) +{ + int i, j, ssb; + int N = 8; + float temp[8][2]; + + for (i = 0; i < len; i++, in++) { + for (ssb = 0; ssb < N; ssb++) { + float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1]; + for (j = 0; j < 6; j++) { + float in0_re = in[j][0]; + float in0_im = in[j][1]; + float in1_re = in[12-j][0]; + float in1_im = in[12-j][1]; + sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im); + sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re); + } + temp[ssb][0] = sum_re; + temp[ssb][1] = sum_im; + } + out[0][i][0] = temp[6][0]; + out[0][i][1] = temp[6][1]; + out[1][i][0] = temp[7][0]; + out[1][i][1] = temp[7][1]; + out[2][i][0] = temp[0][0]; + out[2][i][1] = temp[0][1]; + out[3][i][0] = temp[1][0]; + out[3][i][1] = temp[1][1]; + out[4][i][0] = temp[2][0] + temp[5][0]; + out[4][i][1] = temp[2][1] + temp[5][1]; + out[5][i][0] = temp[3][0] + temp[4][0]; + out[5][i][1] = temp[3][1] + temp[4][1]; + } +} + +static void hybrid4_8_12_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int N, int len) +{ + int i, j, ssb; + + for (i = 0; i < len; i++, in++) { + for (ssb = 0; ssb < N; ssb++) { + float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1]; + for (j = 0; j < 6; j++) { + float in0_re = in[j][0]; + float in0_im = in[j][1]; + float in1_re = in[12-j][0]; + float in1_im = in[12-j][1]; + sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im); + sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re); + } + out[ssb][i][0] = sum_re; + out[ssb][i][1] = sum_im; + } + } +} + +static void hybrid_analysis(float out[91][32][2], float in[5][44][2], float L[2][38][64], int is34, int len) +{ + int i, j; + for (i = 0; i < 5; i++) { + for (j = 0; j < 38; j++) { + in[i][j+6][0] = L[0][j][i]; + in[i][j+6][1] = L[1][j][i]; + } + } + if (is34) { + hybrid4_8_12_cx(in[0], out, f34_0_12, 12, len); + hybrid4_8_12_cx(in[1], out+12, f34_1_8, 8, len); + hybrid4_8_12_cx(in[2], out+20, f34_2_4, 4, len); + hybrid4_8_12_cx(in[3], out+24, f34_2_4, 4, len); + hybrid4_8_12_cx(in[4], out+28, f34_2_4, 4, len); + for (i = 0; i < 59; i++) { + for (j = 0; j < len; j++) { + out[i+32][j][0] = L[0][j][i+5]; + out[i+32][j][1] = L[1][j][i+5]; + } + } + } else { + hybrid6_cx(in[0], out, f20_0_8, len); + hybrid2_re(in[1], out+6, g1_Q2, len, 1); + hybrid2_re(in[2], out+8, g1_Q2, len, 0); + for (i = 0; i < 61; i++) { + for (j = 0; j < len; j++) { + out[i+10][j][0] = L[0][j][i+3]; + out[i+10][j][1] = L[1][j][i+3]; + } + } + } + //update in_buf + for (i = 0; i < 5; i++) { + memcpy(in[i], in[i]+32, 6 * sizeof(in[i][0])); + } +} + +static void hybrid_synthesis(float out[2][38][64], float in[91][32][2], int is34, int len) +{ + int i, n; + if (is34) { + for (n = 0; n < len; n++) { + memset(out[0][n], 0, 5*sizeof(out[0][n][0])); + memset(out[1][n], 0, 5*sizeof(out[1][n][0])); + for (i = 0; i < 12; i++) { + out[0][n][0] += in[ i][n][0]; + out[1][n][0] += in[ i][n][1]; + } + for (i = 0; i < 8; i++) { + out[0][n][1] += in[12+i][n][0]; + out[1][n][1] += in[12+i][n][1]; + } + for (i = 0; i < 4; i++) { + out[0][n][2] += in[20+i][n][0]; + out[1][n][2] += in[20+i][n][1]; + out[0][n][3] += in[24+i][n][0]; + out[1][n][3] += in[24+i][n][1]; + out[0][n][4] += in[28+i][n][0]; + out[1][n][4] += in[28+i][n][1]; + } + } + for (i = 0; i < 59; i++) { + for (n = 0; n < len; n++) { + out[0][n][i+5] = in[i+32][n][0]; + out[1][n][i+5] = in[i+32][n][1]; + } + } + } else { + for (n = 0; n < len; n++) { + out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] + + in[3][n][0] + in[4][n][0] + in[5][n][0]; + out[1][n][0] = in[0][n][1] + in[1][n][1] + in[2][n][1] + + in[3][n][1] + in[4][n][1] + in[5][n][1]; + out[0][n][1] = in[6][n][0] + in[7][n][0]; + out[1][n][1] = in[6][n][1] + in[7][n][1]; + out[0][n][2] = in[8][n][0] + in[9][n][0]; + out[1][n][2] = in[8][n][1] + in[9][n][1]; + } + for (i = 0; i < 61; i++) { + for (n = 0; n < len; n++) { + out[0][n][i+3] = in[i+10][n][0]; + out[1][n][i+3] = in[i+10][n][1]; + } + } + } +} + +/// All-pass filter decay slope +#define DECAY_SLOPE 0.05f +/// Number of frequency bands that can be addressed by the parameter index, b(k) +static const int NR_PAR_BANDS[] = { 20, 34 }; +/// Number of frequency bands that can be addressed by the sub subband index, k +static const int NR_BANDS[] = { 71, 91 }; +/// Start frequency band for the all-pass filter decay slope +static const int DECAY_CUTOFF[] = { 10, 32 }; +/// Number of all-pass filer bands +static const int NR_ALLPASS_BANDS[] = { 30, 50 }; +/// First stereo band using the short one sample delay +static const int SHORT_DELAY_BAND[] = { 42, 62 }; + +/** Table 8.46 */ +static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full) +{ + int b; + if (full) + b = 9; + else { + b = 4; + par_mapped[10] = 0; + } + for (; b >= 0; b--) { + par_mapped[2*b+1] = par_mapped[2*b] = par[b]; + } +} + +static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full) +{ + par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3; + par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3; + par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3; + par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3; + par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2; + par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2; + par_mapped[ 6] = par[10]; + par_mapped[ 7] = par[11]; + par_mapped[ 8] = ( par[12] + par[13]) / 2; + par_mapped[ 9] = ( par[14] + par[15]) / 2; + par_mapped[10] = par[16]; + if (full) { + par_mapped[11] = par[17]; + par_mapped[12] = par[18]; + par_mapped[13] = par[19]; + par_mapped[14] = ( par[20] + par[21]) / 2; + par_mapped[15] = ( par[22] + par[23]) / 2; + par_mapped[16] = ( par[24] + par[25]) / 2; + par_mapped[17] = ( par[26] + par[27]) / 2; + par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4; + par_mapped[19] = ( par[32] + par[33]) / 2; + } +} + +static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC]) +{ + par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; + par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; + par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; + par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; + par[ 4] = ( par[ 6] + par[ 7]) * 0.5f; + par[ 5] = ( par[ 8] + par[ 9]) * 0.5f; + par[ 6] = par[10]; + par[ 7] = par[11]; + par[ 8] = ( par[12] + par[13]) * 0.5f; + par[ 9] = ( par[14] + par[15]) * 0.5f; + par[10] = par[16]; + par[11] = par[17]; + par[12] = par[18]; + par[13] = par[19]; + par[14] = ( par[20] + par[21]) * 0.5f; + par[15] = ( par[22] + par[23]) * 0.5f; + par[16] = ( par[24] + par[25]) * 0.5f; + par[17] = ( par[26] + par[27]) * 0.5f; + par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; + par[19] = ( par[32] + par[33]) * 0.5f; +} + +static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full) +{ + if (full) { + par_mapped[33] = par[9]; + par_mapped[32] = par[9]; + par_mapped[31] = par[9]; + par_mapped[30] = par[9]; + par_mapped[29] = par[9]; + par_mapped[28] = par[9]; + par_mapped[27] = par[8]; + par_mapped[26] = par[8]; + par_mapped[25] = par[8]; + par_mapped[24] = par[8]; + par_mapped[23] = par[7]; + par_mapped[22] = par[7]; + par_mapped[21] = par[7]; + par_mapped[20] = par[7]; + par_mapped[19] = par[6]; + par_mapped[18] = par[6]; + par_mapped[17] = par[5]; + par_mapped[16] = par[5]; + } else { + par_mapped[16] = 0; + } + par_mapped[15] = par[4]; + par_mapped[14] = par[4]; + par_mapped[13] = par[4]; + par_mapped[12] = par[4]; + par_mapped[11] = par[3]; + par_mapped[10] = par[3]; + par_mapped[ 9] = par[2]; + par_mapped[ 8] = par[2]; + par_mapped[ 7] = par[2]; + par_mapped[ 6] = par[2]; + par_mapped[ 5] = par[1]; + par_mapped[ 4] = par[1]; + par_mapped[ 3] = par[1]; + par_mapped[ 2] = par[0]; + par_mapped[ 1] = par[0]; + par_mapped[ 0] = par[0]; +} + +static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full) +{ + if (full) { + par_mapped[33] = par[19]; + par_mapped[32] = par[19]; + par_mapped[31] = par[18]; + par_mapped[30] = par[18]; + par_mapped[29] = par[18]; + par_mapped[28] = par[18]; + par_mapped[27] = par[17]; + par_mapped[26] = par[17]; + par_mapped[25] = par[16]; + par_mapped[24] = par[16]; + par_mapped[23] = par[15]; + par_mapped[22] = par[15]; + par_mapped[21] = par[14]; + par_mapped[20] = par[14]; + par_mapped[19] = par[13]; + par_mapped[18] = par[12]; + par_mapped[17] = par[11]; + } + par_mapped[16] = par[10]; + par_mapped[15] = par[ 9]; + par_mapped[14] = par[ 9]; + par_mapped[13] = par[ 8]; + par_mapped[12] = par[ 8]; + par_mapped[11] = par[ 7]; + par_mapped[10] = par[ 6]; + par_mapped[ 9] = par[ 5]; + par_mapped[ 8] = par[ 5]; + par_mapped[ 7] = par[ 4]; + par_mapped[ 6] = par[ 4]; + par_mapped[ 5] = par[ 3]; + par_mapped[ 4] = (par[ 2] + par[ 3]) / 2; + par_mapped[ 3] = par[ 2]; + par_mapped[ 2] = par[ 1]; + par_mapped[ 1] = (par[ 0] + par[ 1]) / 2; + par_mapped[ 0] = par[ 0]; +} + +static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) +{ + par[33] = par[19]; + par[32] = par[19]; + par[31] = par[18]; + par[30] = par[18]; + par[29] = par[18]; + par[28] = par[18]; + par[27] = par[17]; + par[26] = par[17]; + par[25] = par[16]; + par[24] = par[16]; + par[23] = par[15]; + par[22] = par[15]; + par[21] = par[14]; + par[20] = par[14]; + par[19] = par[13]; + par[18] = par[12]; + par[17] = par[11]; + par[16] = par[10]; + par[15] = par[ 9]; + par[14] = par[ 9]; + par[13] = par[ 8]; + par[12] = par[ 8]; + par[11] = par[ 7]; + par[10] = par[ 6]; + par[ 9] = par[ 5]; + par[ 8] = par[ 5]; + par[ 7] = par[ 4]; + par[ 6] = par[ 4]; + par[ 5] = par[ 3]; + par[ 4] = (par[ 2] + par[ 3]) * 0.5f; + par[ 3] = par[ 2]; + par[ 2] = par[ 1]; + par[ 1] = (par[ 0] + par[ 1]) * 0.5f; + par[ 0] = par[ 0]; +} + +static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34) +{ + float power[34][PS_QMF_TIME_SLOTS] = {{0}}; + float transient_gain[34][PS_QMF_TIME_SLOTS]; + float *peak_decay_nrg = ps->peak_decay_nrg; + float *power_smooth = ps->power_smooth; + float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; + float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; + float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; + const float peak_decay_factor = 0.76592833836465f; + const float transient_impact = 1.5f; + const float a_smooth = 0.25f; //< Smoothing coefficient + int i, k, m, n; + int n0 = 0, nL = 32; + static const int link_delay[] = { 3, 4, 5 }; + static const float a[] = { 0.65143905753106f, + 0.56471812200776f, + 0.48954165955695f }; + + if (is34 != ps->is34bands_old) { + memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg)); + memset(ps->power_smooth, 0, sizeof(ps->power_smooth)); + memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth)); + memset(ps->delay, 0, sizeof(ps->delay)); + memset(ps->ap_delay, 0, sizeof(ps->ap_delay)); + } + + for (n = n0; n < nL; n++) { + for (k = 0; k < NR_BANDS[is34]; k++) { + int i = k_to_i[k]; + power[i][n] += s[k][n][0] * s[k][n][0] + s[k][n][1] * s[k][n][1]; + } + } + + //Transient detection + for (i = 0; i < NR_PAR_BANDS[is34]; i++) { + for (n = n0; n < nL; n++) { + float decayed_peak = peak_decay_factor * peak_decay_nrg[i]; + float denom; + peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); + power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]); + peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]); + denom = transient_impact * peak_decay_diff_smooth[i]; + transient_gain[i][n] = (denom > power_smooth[i]) ? + power_smooth[i] / denom : 1.0f; + } + } + + //Decorrelation and transient reduction + // PS_AP_LINKS - 1 + // ----- + // | | Q_fract_allpass[k][m]*z^-link_delay[m] - a[m]*g_decay_slope[k] + //H[k][z] = z^-2 * phi_fract[k] * | | ---------------------------------------------------------------- + // | | 1 - a[m]*g_decay_slope[k]*Q_fract_allpass[k][m]*z^-link_delay[m] + // m = 0 + //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z] + for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) { + int b = k_to_i[k]; + float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); + float ag[PS_AP_LINKS]; + g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); + memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); + memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); + for (m = 0; m < PS_AP_LINKS; m++) { + memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0])); + ag[m] = a[m] * g_decay_slope; + } + for (n = n0; n < nL; n++) { + float in_re = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][0] - + delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][1]; + float in_im = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][1] + + delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][0]; + for (m = 0; m < PS_AP_LINKS; m++) { + float a_re = ag[m] * in_re; + float a_im = ag[m] * in_im; + float link_delay_re = ap_delay[k][m][n+5-link_delay[m]][0]; + float link_delay_im = ap_delay[k][m][n+5-link_delay[m]][1]; + float fractional_delay_re = Q_fract_allpass[is34][k][m][0]; + float fractional_delay_im = Q_fract_allpass[is34][k][m][1]; + ap_delay[k][m][n+5][0] = in_re; + ap_delay[k][m][n+5][1] = in_im; + in_re = link_delay_re * fractional_delay_re - link_delay_im * fractional_delay_im - a_re; + in_im = link_delay_re * fractional_delay_im + link_delay_im * fractional_delay_re - a_im; + ap_delay[k][m][n+5][0] += ag[m] * in_re; + ap_delay[k][m][n+5][1] += ag[m] * in_im; + } + out[k][n][0] = transient_gain[b][n] * in_re; + out[k][n][1] = transient_gain[b][n] * in_im; + } + } + for (; k < SHORT_DELAY_BAND[is34]; k++) { + memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); + memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); + for (n = n0; n < nL; n++) { + //H = delay 14 + out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][0]; + out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][1]; + } + } + for (; k < NR_BANDS[is34]; k++) { + memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); + memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); + for (n = n0; n < nL; n++) { + //H = delay 1 + out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][0]; + out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][1]; + } + } +} + +static void remap34(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], + int8_t (*par)[PS_MAX_NR_IIDICC], + int num_par, int num_env, int full) +{ + int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped; + int e; + if (num_par == 20 || num_par == 11) { + for (e = 0; e < num_env; e++) { + map_idx_20_to_34(par_mapped[e], par[e], full); + } + } else if (num_par == 10 || num_par == 5) { + for (e = 0; e < num_env; e++) { + map_idx_10_to_34(par_mapped[e], par[e], full); + } + } else { + *p_par_mapped = par; + } +} + +static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], + int8_t (*par)[PS_MAX_NR_IIDICC], + int num_par, int num_env, int full) +{ + int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped; + int e; + if (num_par == 34 || num_par == 17) { + for (e = 0; e < num_env; e++) { + map_idx_34_to_20(par_mapped[e], par[e], full); + } + } else if (num_par == 10 || num_par == 5) { + for (e = 0; e < num_env; e++) { + map_idx_10_to_20(par_mapped[e], par[e], full); + } + } else { + *p_par_mapped = par; + } +} + +static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) +{ + int e, b, k, n; + + float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; + float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; + float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; + float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; + int8_t *opd_hist = ps->opd_hist; + int8_t *ipd_hist = ps->ipd_hist; + int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; + int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; + int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; + int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; + const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; + + //Remapping + memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); + memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); + memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); + memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); + memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); + memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); + memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); + memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + if (is34) { + remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (!ps->is34bands_old) { + map_val_20_to_34(H11[0][0]); + map_val_20_to_34(H11[1][0]); + map_val_20_to_34(H12[0][0]); + map_val_20_to_34(H12[1][0]); + map_val_20_to_34(H21[0][0]); + map_val_20_to_34(H21[1][0]); + map_val_20_to_34(H22[0][0]); + map_val_20_to_34(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } else { + remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (ps->is34bands_old) { + map_val_34_to_20(H11[0][0]); + map_val_34_to_20(H11[1][0]); + map_val_34_to_20(H12[0][0]); + map_val_34_to_20(H12[1][0]); + map_val_34_to_20(H21[0][0]); + map_val_34_to_20(H21[1][0]); + map_val_34_to_20(H22[0][0]); + map_val_34_to_20(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } + + //Mixing + for (e = 0; e < ps->num_env; e++) { + for (b = 0; b < NR_PAR_BANDS[is34]; b++) { + float h11, h12, h21, h22; + h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; + h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; + h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; + h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; + if (!PS_BASELINE && ps->enable_ipdopd && b < ps->nr_ipdopd_par) { + //The spec say says to only run this smoother when enable_ipdopd + //is set but the reference decoder appears to run it constantly + float h11i, h12i, h21i, h22i; + float ipd_adj_re, ipd_adj_im; + int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; + int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; + float opd_re = pd_re_smooth[opd_idx]; + float opd_im = pd_im_smooth[opd_idx]; + float ipd_re = pd_re_smooth[ipd_idx]; + float ipd_im = pd_im_smooth[ipd_idx]; + opd_hist[b] = opd_idx & 0x3F; + ipd_hist[b] = ipd_idx & 0x3F; + + ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; + ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; + h11i = h11 * opd_im; + h11 = h11 * opd_re; + h12i = h12 * ipd_adj_im; + h12 = h12 * ipd_adj_re; + h21i = h21 * opd_im; + h21 = h21 * opd_re; + h22i = h22 * ipd_adj_im; + h22 = h22 * ipd_adj_re; + H11[1][e+1][b] = h11i; + H12[1][e+1][b] = h12i; + H21[1][e+1][b] = h21i; + H22[1][e+1][b] = h22i; + } + H11[0][e+1][b] = h11; + H12[0][e+1][b] = h12; + H21[0][e+1][b] = h21; + H22[0][e+1][b] = h22; + } + for (k = 0; k < NR_BANDS[is34]; k++) { + float h11r, h12r, h21r, h22r; + float h11i, h12i, h21i, h22i; + float h11r_step, h12r_step, h21r_step, h22r_step; + float h11i_step, h12i_step, h21i_step, h22i_step; + int start = ps->border_position[e]; + int stop = ps->border_position[e+1]; + float width = 1.f / (stop - start); + b = k_to_i[k]; + h11r = H11[0][e][b]; + h12r = H12[0][e][b]; + h21r = H21[0][e][b]; + h22r = H22[0][e][b]; + if (!PS_BASELINE && ps->enable_ipdopd) { + //Is this necessary? ps_04_new seems unchanged + if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { + h11i = -H11[1][e][b]; + h12i = -H12[1][e][b]; + h21i = -H21[1][e][b]; + h22i = -H22[1][e][b]; + } else { + h11i = H11[1][e][b]; + h12i = H12[1][e][b]; + h21i = H21[1][e][b]; + h22i = H22[1][e][b]; + } + } + //Interpolation + h11r_step = (H11[0][e+1][b] - h11r) * width; + h12r_step = (H12[0][e+1][b] - h12r) * width; + h21r_step = (H21[0][e+1][b] - h21r) * width; + h22r_step = (H22[0][e+1][b] - h22r) * width; + if (!PS_BASELINE && ps->enable_ipdopd) { + h11i_step = (H11[1][e+1][b] - h11i) * width; + h12i_step = (H12[1][e+1][b] - h12i) * width; + h21i_step = (H21[1][e+1][b] - h21i) * width; + h22i_step = (H22[1][e+1][b] - h22i) * width; + } + for (n = start + 1; n <= stop; n++) { + //l is s, r is d + float l_re = l[k][n][0]; + float l_im = l[k][n][1]; + float r_re = r[k][n][0]; + float r_im = r[k][n][1]; + h11r += h11r_step; + h12r += h12r_step; + h21r += h21r_step; + h22r += h22r_step; + if (!PS_BASELINE && ps->enable_ipdopd) { + h11i += h11i_step; + h12i += h12i_step; + h21i += h21i_step; + h22i += h22i_step; + + l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im; + l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re; + r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im; + r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re; + } else { + l[k][n][0] = h11r*l_re + h21r*r_re; + l[k][n][1] = h11r*l_im + h21r*r_im; + r[k][n][0] = h12r*l_re + h22r*r_re; + r[k][n][1] = h12r*l_im + h22r*r_im; + } + } + } + } +} + +int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top) +{ + float Lbuf[91][32][2]; + float Rbuf[91][32][2]; + const int len = 32; + int is34 = ps->is34bands; + + top += NR_BANDS[is34] - 64; + memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0])); + if (top < NR_ALLPASS_BANDS[is34]) + memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0])); + + hybrid_analysis(Lbuf, ps->in_buf, L, is34, len); + decorrelation(ps, Rbuf, Lbuf, is34); + stereo_processing(ps, Lbuf, Rbuf, is34); + hybrid_synthesis(L, Lbuf, is34, len); + hybrid_synthesis(R, Rbuf, is34, len); + + return 0; +} + +#define PS_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size, \ + ps_tmp[num].ps_bits, 1, 1, \ + ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \ + size); + +#define PS_VLC_ROW(name) \ + { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } + +av_cold void ff_ps_init(void) { + // Syntax initialization + static const struct { + const void *ps_codes, *ps_bits; + const unsigned int table_size, elem_size; + } ps_tmp[] = { + PS_VLC_ROW(huff_iid_df1), + PS_VLC_ROW(huff_iid_dt1), + PS_VLC_ROW(huff_iid_df0), + PS_VLC_ROW(huff_iid_dt0), + PS_VLC_ROW(huff_icc_df), + PS_VLC_ROW(huff_icc_dt), + PS_VLC_ROW(huff_ipd_df), + PS_VLC_ROW(huff_ipd_dt), + PS_VLC_ROW(huff_opd_df), + PS_VLC_ROW(huff_opd_dt), + }; + + PS_INIT_VLC_STATIC(0, 1544); + PS_INIT_VLC_STATIC(1, 832); + PS_INIT_VLC_STATIC(2, 1024); + PS_INIT_VLC_STATIC(3, 1036); + PS_INIT_VLC_STATIC(4, 544); + PS_INIT_VLC_STATIC(5, 544); + PS_INIT_VLC_STATIC(6, 512); + PS_INIT_VLC_STATIC(7, 512); + PS_INIT_VLC_STATIC(8, 512); + PS_INIT_VLC_STATIC(9, 512); + + ps_tableinit(); +} + +av_cold void ff_ps_ctx_init(PSContext *ps) +{ +} diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h new file mode 100644 index 0000000000..5fc211a986 --- /dev/null +++ b/libavcodec/aacps.h @@ -0,0 +1,82 @@ +/* + * MPEG-4 Parametric Stereo definitions and declarations + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_PS_H +#define AVCODEC_PS_H + +#include + +#include "avcodec.h" +#include "get_bits.h" + +#define PS_MAX_NUM_ENV 5 +#define PS_MAX_NR_IIDICC 34 +#define PS_MAX_NR_IPDOPD 17 +#define PS_MAX_SSB 91 +#define PS_MAX_AP_BANDS 50 +#define PS_QMF_TIME_SLOTS 32 +#define PS_MAX_DELAY 14 +#define PS_AP_LINKS 3 +#define PS_MAX_AP_DELAY 5 + +typedef struct { + int start; + int enable_iid; + int iid_quant; + int nr_iid_par; + int nr_ipdopd_par; + int enable_icc; + int icc_mode; + int nr_icc_par; + int enable_ext; + int frame_class; + int num_env_old; + int num_env; + int enable_ipdopd; + int border_position[PS_MAX_NUM_ENV+1]; + int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; // + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#include "aacps_tablegen.h" +#include "tableprint.h" + +void write_float_3d_array (const void *p, int b, int c, int d) +{ + int i; + const float *f = p; + for (i = 0; i < b; i++) { + printf("{\n"); + write_float_2d_array(f, c, d); + printf("},\n"); + f += c * d; + } +} + +void write_float_4d_array (const void *p, int a, int b, int c, int d) +{ + int i; + const float *f = p; + for (i = 0; i < a; i++) { + printf("{\n"); + write_float_3d_array(f, b, c, d); + printf("},\n"); + f += b * c * d; + } +} + +int main(void) +{ + ps_tableinit(); + + write_fileheader(); + + printf("static const float pd_re_smooth[8*8*8] = {\n"); + write_float_array(pd_re_smooth, 8*8*8); + printf("};\n"); + printf("static const float pd_im_smooth[8*8*8] = {\n"); + write_float_array(pd_im_smooth, 8*8*8); + printf("};\n"); + + printf("static const float HA[46][8][4] = {\n"); + write_float_3d_array(HA, 46, 8, 4); + printf("};\n"); + printf("static const float HB[46][8][4] = {\n"); + write_float_3d_array(HB, 46, 8, 4); + printf("};\n"); + + printf("static const float f20_0_8[8][7][2] = {\n"); + write_float_3d_array(f20_0_8, 8, 7, 2); + printf("};\n"); + printf("static const float f34_0_12[12][7][2] = {\n"); + write_float_3d_array(f34_0_12, 12, 7, 2); + printf("};\n"); + printf("static const float f34_1_8[8][7][2] = {\n"); + write_float_3d_array(f34_1_8, 8, 7, 2); + printf("};\n"); + printf("static const float f34_2_4[4][7][2] = {\n"); + write_float_3d_array(f34_2_4, 4, 7, 2); + printf("};\n"); + + printf("static const float Q_fract_allpass[2][50][3][2] = {\n"); + write_float_4d_array(Q_fract_allpass, 2, 50, 3, 2); + printf("};\n"); + printf("static const float phi_fract[2][50][2] = {\n"); + write_float_3d_array(phi_fract, 2, 50, 2); + printf("};\n"); + + return 0; +} diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h new file mode 100644 index 0000000000..3c1b27decd --- /dev/null +++ b/libavcodec/aacps_tablegen.h @@ -0,0 +1,212 @@ +/* + * Header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AACPS_TABLEGEN_H +#define AACPS_TABLEGEN_H + +#include + +#if CONFIG_HARDCODED_TABLES +#define ps_tableinit() +#include "libavcodec/aacps_tables.h" +#else +#include "../libavutil/common.h" +#include "../libavutil/mathematics.h" +#define NR_ALLPASS_BANDS20 30 +#define NR_ALLPASS_BANDS34 50 +#define PS_AP_LINKS 3 +static float pd_re_smooth[8*8*8]; +static float pd_im_smooth[8*8*8]; +static float HA[46][8][4]; +static float HB[46][8][4]; +static float f20_0_8 [ 8][7][2]; +static float f34_0_12[12][7][2]; +static float f34_1_8 [ 8][7][2]; +static float f34_2_4 [ 4][7][2]; +static float Q_fract_allpass[2][50][3][2]; +static float phi_fract[2][50][2]; + +static const float g0_Q8[] = { + 0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f, + 0.09885108575264f, 0.11793710567217f, 0.125f +}; + +static const float g0_Q12[] = { + 0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f, + 0.07428313801106f, 0.08100347892914f, 0.08333333333333f +}; + +static const float g1_Q8[] = { + 0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f, + 0.10307344158036f, 0.12222452249753f, 0.125f +}; + +static const float g2_Q4[] = { + -0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f, + 0.16486303567403f, 0.23279856662996f, 0.25f +}; + +static void make_filters_from_proto(float (*filter)[7][2], const float *proto, int bands) +{ + int q, n; + for (q = 0; q < bands; q++) { + for (n = 0; n < 7; n++) { + double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands; + filter[q][n][0] = proto[n] * cos(theta); + filter[q][n][1] = proto[n] * -sin(theta); + } + } +} + +static void ps_tableinit(void) +{ + static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 }; + static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 }; + int pd0, pd1, pd2; + + static const float iid_par_dequant[] = { + //iid_par_dequant_default + 0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684, + 0.44668359215096, 0.63095734448019, 0.79432823472428, 1, + 1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838, + 5.01187233627272, 7.94328234724282, 17.7827941003892, + //iid_par_dequant_fine + 0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039, + 0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020, + 0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350, + 0.50118723362727, 0.63095734448019, 0.79432823472428, 1, + 1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958, + 3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745, + 12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349, + 100, 177.827941003892, 316.227766016837, + }; + static const float icc_invq[] = { + 1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1 + }; + static const float acos_icc_invq[] = { + 0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI + }; + int iid, icc; + + int k, m; + static const int8_t f_center_20[] = { + -3, -1, 1, 3, 5, 7, 10, 14, 18, 22, + }; + static const int8_t f_center_34[] = { + 2, 6, 10, 14, 18, 22, 26, 30, + 34,-10, -6, -2, 51, 57, 15, 21, + 27, 33, 39, 45, 54, 66, 78, 42, + 102, 66, 78, 90,102,114,126, 90, + }; + static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f }; + const float fractional_delay_gain = 0.39f; + + for (pd0 = 0; pd0 < 8; pd0++) { + float pd0_re = ipdopd_cos[pd0]; + float pd0_im = ipdopd_sin[pd0]; + for (pd1 = 0; pd1 < 8; pd1++) { + float pd1_re = ipdopd_cos[pd1]; + float pd1_im = ipdopd_sin[pd1]; + for (pd2 = 0; pd2 < 8; pd2++) { + float pd2_re = ipdopd_cos[pd2]; + float pd2_im = ipdopd_sin[pd2]; + float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re; + float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im; + float pd_mag = 1 / sqrt(im_smooth * im_smooth + re_smooth * re_smooth); + pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag; + pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag; + } + } + } + + for (iid = 0; iid < 46; iid++) { + float c = iid_par_dequant[iid]; //icc_mode < 3)*/ { + float alpha = 0.5f * acos_icc_invq[icc]; + float beta = alpha * (c1 - c2) * (float)M_SQRT1_2; + HA[iid][icc][0] = c2 * cosf(beta + alpha); + HA[iid][icc][1] = c1 * cosf(beta - alpha); + HA[iid][icc][2] = c2 * sinf(beta + alpha); + HA[iid][icc][3] = c1 * sinf(beta - alpha); + } /* else */ { + float alpha, gamma, mu, rho; + float alpha_c, alpha_s, gamma_c, gamma_s; + rho = FFMAX(icc_invq[icc], 0.05f); + alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f); + mu = c + 1.0f / c; + mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu)); + gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu))); + if (alpha < 0) alpha += M_PI/2; + alpha_c = cosf(alpha); + alpha_s = sinf(alpha); + gamma_c = cosf(gamma); + gamma_s = sinf(gamma); + HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c; + HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c; + HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s; + HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s; + } + } + } + + for (k = 0; k < NR_ALLPASS_BANDS20; k++) { + double f_center, theta; + if (k < FF_ARRAY_ELEMS(f_center_20)) + f_center = f_center_20[k] * 0.125; + else + f_center = k - 6.5f; + for (m = 0; m < PS_AP_LINKS; m++) { + theta = -M_PI * fractional_delay_links[m] * f_center; + Q_fract_allpass[0][k][m][0] = cos(theta); + Q_fract_allpass[0][k][m][1] = sin(theta); + } + theta = -M_PI*fractional_delay_gain*f_center; + phi_fract[0][k][0] = cos(theta); + phi_fract[0][k][1] = sin(theta); + } + for (k = 0; k < NR_ALLPASS_BANDS34; k++) { + double f_center, theta; + if (k < FF_ARRAY_ELEMS(f_center_34)) + f_center = f_center_34[k] / 24.; + else + f_center = k - 26.5f; + for (m = 0; m < PS_AP_LINKS; m++) { + theta = -M_PI * fractional_delay_links[m] * f_center; + Q_fract_allpass[1][k][m][0] = cos(theta); + Q_fract_allpass[1][k][m][1] = sin(theta); + } + theta = -M_PI*fractional_delay_gain*f_center; + phi_fract[1][k][0] = cos(theta); + phi_fract[1][k][1] = sin(theta); + } + + make_filters_from_proto(f20_0_8, g0_Q8, 8); + make_filters_from_proto(f34_0_12, g0_Q12, 12); + make_filters_from_proto(f34_1_8, g1_Q8, 8); + make_filters_from_proto(f34_2_4, g2_Q4, 4); +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AACPS_TABLEGEN_H */ diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c new file mode 100644 index 0000000000..7431caebc6 --- /dev/null +++ b/libavcodec/aacpsdata.c @@ -0,0 +1,163 @@ +/* + * MPEG-4 Parametric Stereo data tables + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static const uint8_t huff_iid_df1_bits[] = { + 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 17, 17, 16, 16, 15, 14, 14, + 13, 12, 12, 11, 10, 10, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 17, 18, 18, + 18, 18, 18, 18, 18, 18, 18, +}; + +static const uint32_t huff_iid_df1_codes[] = { + 0x01FEB4, 0x01FEB5, 0x01FD76, 0x01FD77, 0x01FD74, 0x01FD75, 0x01FE8A, + 0x01FE8B, 0x01FE88, 0x00FE80, 0x01FEB6, 0x00FE82, 0x00FEB8, 0x007F42, + 0x007FAE, 0x003FAF, 0x001FD1, 0x001FE9, 0x000FE9, 0x0007EA, 0x0007FB, + 0x0003FB, 0x0001FB, 0x0001FF, 0x00007C, 0x00003C, 0x00001C, 0x00000C, + 0x000000, 0x000001, 0x000001, 0x000002, 0x000001, 0x00000D, 0x00001D, + 0x00003D, 0x00007D, 0x0000FC, 0x0001FC, 0x0003FC, 0x0003F4, 0x0007EB, + 0x000FEA, 0x001FEA, 0x001FD6, 0x003FD0, 0x007FAF, 0x007F43, 0x00FEB9, + 0x00FE83, 0x01FEB7, 0x00FE81, 0x01FE89, 0x01FE8E, 0x01FE8F, 0x01FE8C, + 0x01FE8D, 0x01FEB2, 0x01FEB3, 0x01FEB0, 0x01FEB1, +}; + +static const uint8_t huff_iid_dt1_bits[] = { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13, + 13, 13, 12, 12, 11, 10, 9, 9, 7, 6, 5, 3, 1, 2, 5, 6, 7, 8, + 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, +}; + +static const uint16_t huff_iid_dt1_codes[] = { + 0x004ED4, 0x004ED5, 0x004ECE, 0x004ECF, 0x004ECC, 0x004ED6, 0x004ED8, + 0x004F46, 0x004F60, 0x002718, 0x002719, 0x002764, 0x002765, 0x00276D, + 0x0027B1, 0x0013B7, 0x0013D6, 0x0009C7, 0x0009E9, 0x0009ED, 0x0004EE, + 0x0004F7, 0x000278, 0x000139, 0x00009A, 0x00009F, 0x000020, 0x000011, + 0x00000A, 0x000003, 0x000001, 0x000000, 0x00000B, 0x000012, 0x000021, + 0x00004C, 0x00009B, 0x00013A, 0x000279, 0x000270, 0x0004EF, 0x0004E2, + 0x0009EA, 0x0009D8, 0x0013D7, 0x0013D0, 0x0027B2, 0x0027A2, 0x00271A, + 0x00271B, 0x004F66, 0x004F67, 0x004F61, 0x004F47, 0x004ED9, 0x004ED7, + 0x004ECD, 0x004ED2, 0x004ED3, 0x004ED0, 0x004ED1, +}; + +static const uint8_t huff_iid_df0_bits[] = { + 17, 17, 17, 17, 16, 15, 13, 10, 9, 7, 6, 5, 4, 3, 1, 3, 4, 5, + 6, 6, 8, 11, 13, 14, 14, 15, 17, 18, 18, +}; + +static const uint32_t huff_iid_df0_codes[] = { + 0x01FFFB, 0x01FFFC, 0x01FFFD, 0x01FFFA, 0x00FFFC, 0x007FFC, 0x001FFD, + 0x0003FE, 0x0001FE, 0x00007E, 0x00003C, 0x00001D, 0x00000D, 0x000005, + 0x000000, 0x000004, 0x00000C, 0x00001C, 0x00003D, 0x00003E, 0x0000FE, + 0x0007FE, 0x001FFC, 0x003FFC, 0x003FFD, 0x007FFD, 0x01FFFE, 0x03FFFE, + 0x03FFFF, +}; + +static const uint8_t huff_iid_dt0_bits[] = { + 19, 19, 19, 20, 20, 20, 17, 15, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, + 9, 11, 13, 14, 17, 19, 20, 20, 20, 20, 20, +}; + +static const uint32_t huff_iid_dt0_codes[] = { + 0x07FFF9, 0x07FFFA, 0x07FFFB, 0x0FFFF8, 0x0FFFF9, 0x0FFFFA, 0x01FFFD, + 0x007FFE, 0x000FFE, 0x0003FE, 0x0000FE, 0x00003E, 0x00000E, 0x000002, + 0x000000, 0x000006, 0x00001E, 0x00007E, 0x0001FE, 0x0007FE, 0x001FFE, + 0x003FFE, 0x01FFFC, 0x07FFF8, 0x0FFFFB, 0x0FFFFC, 0x0FFFFD, 0x0FFFFE, + 0x0FFFFF, +}; + +static const uint8_t huff_icc_df_bits[] = { + 14, 14, 12, 10, 7, 5, 3, 1, 2, 4, 6, 8, 9, 11, 13, +}; + +static const uint16_t huff_icc_df_codes[] = { + 0x3FFF, 0x3FFE, 0x0FFE, 0x03FE, 0x007E, 0x001E, 0x0006, 0x0000, + 0x0002, 0x000E, 0x003E, 0x00FE, 0x01FE, 0x07FE, 0x1FFE, +}; + +static const uint8_t huff_icc_dt_bits[] = { + 14, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, +}; + +static const uint16_t huff_icc_dt_codes[] = { + 0x3FFE, 0x1FFE, 0x07FE, 0x01FE, 0x007E, 0x001E, 0x0006, 0x0000, + 0x0002, 0x000E, 0x003E, 0x00FE, 0x03FE, 0x0FFE, 0x3FFF, +}; + +static const uint8_t huff_ipd_df_bits[] = { + 1, 3, 4, 4, 4, 4, 4, 4, +}; + +static const uint8_t huff_ipd_df_codes[] = { + 0x01, 0x00, 0x06, 0x04, 0x02, 0x03, 0x05, 0x07, +}; + +static const uint8_t huff_ipd_dt_bits[] = { + 1, 3, 4, 5, 5, 4, 4, 3, +}; + +static const uint8_t huff_ipd_dt_codes[] = { + 0x01, 0x02, 0x02, 0x03, 0x02, 0x00, 0x03, 0x03, +}; + +static const uint8_t huff_opd_df_bits[] = { + 1, 3, 4, 4, 5, 5, 4, 3, +}; + +static const uint8_t huff_opd_df_codes[] = { + 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x05, 0x00, +}; + +static const uint8_t huff_opd_dt_bits[] = { + 1, 3, 4, 5, 5, 4, 4, 3, +}; + +static const uint8_t huff_opd_dt_codes[] = { + 0x01, 0x02, 0x01, 0x07, 0x06, 0x00, 0x02, 0x03, +}; + +static const int8_t huff_offset[] = { + 30, 30, + 14, 14, + 7, 7, + 0, 0, + 0, 0, +}; + +///Table 8.48 +static const int8_t k_to_i_20[] = { + 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15, + 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 +}; +///Table 8.49 +static const int8_t k_to_i_34[] = { + 0, 1, 2, 3, 4, 5, 6, 6, 7, 2, 1, 0, 10, 10, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21, + 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, + 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 +}; + +static const float g1_Q2[] = { + 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, + 0.0f, 0.30596630545168f, 0.5f +}; diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 0de89c2315..ca5c52cce3 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -31,6 +31,7 @@ #include "aacsbr.h" #include "aacsbrdata.h" #include "fft.h" +#include "aacps.h" #include #include @@ -71,9 +72,6 @@ enum { static VLC vlc_sbr[10]; static const int8_t vlc_sbr_lav[10] = { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; -static DECLARE_ALIGNED(16, float, analysis_cos_pre)[64]; -static DECLARE_ALIGNED(16, float, analysis_sin_pre)[64]; -static DECLARE_ALIGNED(16, float, analysis_cossin_post)[32][2]; static const DECLARE_ALIGNED(16, float, zero64)[64]; #define SBR_INIT_VLC_STATIC(num, size) \ @@ -87,7 +85,7 @@ static const DECLARE_ALIGNED(16, float, zero64)[64]; av_cold void ff_aac_sbr_init(void) { - int n, k; + int n; static const struct { const void *sbr_codes, *sbr_bits; const unsigned int table_size, elem_size; @@ -116,16 +114,6 @@ av_cold void ff_aac_sbr_init(void) SBR_INIT_VLC_STATIC(8, 592); SBR_INIT_VLC_STATIC(9, 512); - for (n = 0; n < 64; n++) { - float pre = M_PI * n / 64; - analysis_cos_pre[n] = cosf(pre); - analysis_sin_pre[n] = sinf(pre); - } - for (k = 0; k < 32; k++) { - float post = M_PI * (k + 0.5) / 128; - analysis_cossin_post[k][0] = 4.0 * cosf(post); - analysis_cossin_post[k][1] = -4.0 * sinf(post); - } for (n = 1; n < 320; n++) sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; @@ -133,6 +121,8 @@ av_cold void ff_aac_sbr_init(void) for (n = 0; n < 320; n++) sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; + + ff_ps_init(); } av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) @@ -142,13 +132,14 @@ av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64); - ff_rdft_init(&sbr->rdft, 6, IDFT_R2C); + ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0); + ff_ps_ctx_init(&sbr->ps); } av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) { ff_mdct_end(&sbr->mdct); - ff_rdft_end(&sbr->rdft); + ff_mdct_end(&sbr->mdct_ana); } static int qsort_comparison_function_int16(const void *a, const void *b) @@ -293,15 +284,15 @@ static void make_bands(int16_t* bands, int start, int stop, int num_bands) bands[num_bands-1] = stop - previous; } -static int check_n_master(AVCodecContext *avccontext, int n_master, int bs_xover_band) +static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) { // Requirements (14496-3 sp04 p205) if (n_master <= 0) { - av_log(avccontext, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); + av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); return -1; } if (bs_xover_band >= n_master) { - av_log(avccontext, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Invalid bitstream, crossover band index beyond array bounds: %d\n", bs_xover_band); return -1; @@ -349,7 +340,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, sbr_offset_ptr = sbr_offset[5]; break; default: - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Unsupported sample rate for SBR: %d\n", sbr->sample_rate); return -1; } @@ -367,7 +358,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, } else if (spectrum->bs_stop_freq == 15) { sbr->k[2] = 3*sbr->k[0]; } else { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); return -1; } @@ -382,18 +373,17 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, max_qmf_subbands = 32; if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); return -1; } if (!spectrum->bs_freq_scale) { - unsigned int dk; - int k2diff; + int dk, k2diff; dk = spectrum->bs_alter_scale + 1; sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; - if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) return -1; for (k = 1; k <= sbr->n_master; k++) @@ -428,7 +418,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avccontext, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); + av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); return -1; } @@ -442,7 +432,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, vk0[0] = sbr->k[0]; for (k = 1; k <= num_bands_0; k++) { if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); + av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); return -1; } vk0[k] += vk0[k-1]; @@ -472,14 +462,14 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, vk1[0] = sbr->k[1]; for (k = 1; k <= num_bands_1; k++) { if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); + av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); return -1; } vk1[k] += vk1[k-1]; } sbr->n_master = num_bands_0 + num_bands_1; - if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) return -1; memcpy(&sbr->f_master[0], vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); @@ -488,7 +478,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, } else { sbr->n_master = num_bands_0; - if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) return -1; memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); } @@ -524,7 +514,7 @@ static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) // illegal however the Coding Technologies decoder check stream has a final // count of 6 patches if (sbr->num_patches > 5) { - av_log(ac->avccontext, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); + av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); return -1; } @@ -563,12 +553,12 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) // Requirements (14496-3 sp04 p205) if (sbr->kx[1] + sbr->m[1] > 64) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); return -1; } if (sbr->kx[1] > 32) { - av_log(ac->avccontext, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); + av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); return -1; } @@ -580,7 +570,7 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 if (sbr->n_q > 5) { - av_log(ac->avccontext, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); + av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); return -1; } @@ -638,7 +628,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, ch_data->bs_amp_res = 0; if (ch_data->bs_num_env > 4) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", ch_data->bs_num_env); return -1; @@ -693,7 +683,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; if (ch_data->bs_num_env > 5) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", ch_data->bs_num_env); return -1; @@ -714,7 +704,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, } if (bs_pointer > ch_data->bs_num_env + 1) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", bs_pointer); return -1; @@ -722,7 +712,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, for (i = 1; i <= ch_data->bs_num_env; i++) { if (ch_data->t_env[i-1] > ch_data->t_env[i]) { - av_log(ac->avccontext, AV_LOG_ERROR, "Non monotone time borders\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); return -1; } } @@ -903,25 +893,24 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left) { -//TODO - implement ps_data for parametric stereo parsing switch (bs_extension_id) { case EXTENSION_ID_PS: if (!ac->m4ac.ps) { - av_log(ac->avccontext, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); + av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; } else { -#if 0 - *num_bits_left -= ff_ps_data(gb, ps); +#if 1 + *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); #else - av_log_missing_feature(ac->avccontext, "Parametric Stereo is", 0); + av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0); skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; #endif } break; default: - av_log_missing_feature(ac->avccontext, "Reserved SBR extensions are", 1); + av_log_missing_feature(ac->avctx, "Reserved SBR extensions are", 1); skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; break; @@ -1006,7 +995,7 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, return get_bits_count(gb) - cnt; } } else { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); sbr->start = 0; return get_bits_count(gb) - cnt; @@ -1021,6 +1010,11 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, num_bits_left -= 2; read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id } + if (num_bits_left < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); + } + if (num_bits_left > 0) + skip_bits(gb, num_bits_left); } return get_bits_count(gb) - cnt; @@ -1033,7 +1027,7 @@ static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) if (err >= 0) err = sbr_make_f_derived(ac, sbr); if (err < 0) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "SBR reset failed. Switching SBR to pure upsampling mode.\n"); sbr->start = 0; } @@ -1085,7 +1079,7 @@ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); if (bytes_read > cnt) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); } return cnt; @@ -1139,7 +1133,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) * @param x pointer to the beginning of the first sample window * @param W array of complex-valued samples split into subbands */ -static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in, float *x, +static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x, float z[320], float W[2][32][32][2], float scale) { @@ -1152,23 +1146,23 @@ static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in memcpy(x+288, in, 1024*sizeof(*x)); for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames // are not supported - float re, im; dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); for (k = 0; k < 64; k++) { float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; - z[k] = f * analysis_cos_pre[k]; - z[k+64] = f; + z[k] = f; } - ff_rdft_calc(rdft, z); - re = z[0] * 0.5f; - im = 0.5f * dsp->scalarproduct_float(z+64, analysis_sin_pre, 64); - W[1][i][0][0] = re * analysis_cossin_post[0][0] - im * analysis_cossin_post[0][1]; - W[1][i][0][1] = re * analysis_cossin_post[0][1] + im * analysis_cossin_post[0][0]; + //Shuffle to IMDCT + z[64] = z[0]; for (k = 1; k < 32; k++) { - re = z[2*k ] - re; - im = z[2*k+1] - im; - W[1][i][k][0] = re * analysis_cossin_post[k][0] - im * analysis_cossin_post[k][1]; - W[1][i][k][1] = re * analysis_cossin_post[k][1] + im * analysis_cossin_post[k][0]; + z[64+2*k-1] = z[ k]; + z[64+2*k ] = -z[64-k]; + } + z[64+63] = z[32]; + + ff_imdct_half(mdct, z, z+64); + for (k = 0; k < 32; k++) { + W[1][i][k][0] = -z[63-k]; + W[1][i][k][1] = z[k]; } x += 32; } @@ -1179,7 +1173,7 @@ static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in * (14496-3 sp04 p206) */ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, - float *out, float X[2][32][64], + float *out, float X[2][38][64], float mdct_buf[2][64], float *v0, int *v_off, const unsigned int div, float bias, float scale) @@ -1197,21 +1191,22 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, *v_off -= 128 >> div; } v = v0 + *v_off; - for (n = 1; n < 64 >> div; n+=2) { - X[1][i][n] = -X[1][i][n]; - } - if (div) { - memset(X[0][i]+32, 0, 32*sizeof(float)); - memset(X[1][i]+32, 0, 32*sizeof(float)); - } - ff_imdct_half(mdct, mdct_buf[0], X[0][i]); - ff_imdct_half(mdct, mdct_buf[1], X[1][i]); if (div) { for (n = 0; n < 32; n++) { - v[ n] = -mdct_buf[0][63 - 2*n] + mdct_buf[1][2*n ]; - v[ 63 - n] = mdct_buf[0][62 - 2*n] + mdct_buf[1][2*n + 1]; + X[0][i][ n] = -X[0][i][n]; + X[0][i][32+n] = X[1][i][31-n]; + } + ff_imdct_half(mdct, mdct_buf[0], X[0][i]); + for (n = 0; n < 32; n++) { + v[ n] = mdct_buf[0][63 - 2*n]; + v[63 - n] = -mdct_buf[0][62 - 2*n]; } } else { + for (n = 1; n < 64; n+=2) { + X[1][i][n] = -X[1][i][n]; + } + ff_imdct_half(mdct, mdct_buf[0], X[0][i]); + ff_imdct_half(mdct, mdct_buf[1], X[1][i]); for (n = 0; n < 64; n++) { v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; @@ -1380,7 +1375,7 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, g--; if (g < 0) { - av_log(ac->avccontext, AV_LOG_ERROR, + av_log(ac->avctx, AV_LOG_ERROR, "ERROR : no subband found for frequency %d\n", k); return -1; } @@ -1414,7 +1409,7 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, } /// Generate the subband filtered lowband -static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], +static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], const float X_low[32][40][2], const float Y[2][38][64][2], int ch) { @@ -1436,7 +1431,7 @@ static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], } for (k = 0; k < sbr->kx[1]; k++) { - for (i = i_Temp; i < i_f; i++) { + for (i = i_Temp; i < 38; i++) { X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; } @@ -1730,7 +1725,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, } for (ch = 0; ch < nch; ch++) { /* decode channel */ - sbr_qmf_analysis(&ac->dsp, &sbr->rdft, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, + sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, (float*)sbr->qmf_filter_scratch, sbr->data[ch].W, 1/(-1024 * ac->sf_scale)); sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W); @@ -1752,6 +1747,16 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, /* synthesis */ sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch); } + + if (ac->m4ac.ps == 1) { + if (sbr->ps.start) { + ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); + } else { + memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); + } + nch = 2; + } + sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch, sbr->data[0].synthesis_filterbank_samples, &sbr->data[0].synthesis_filterbank_samples_offset, diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index eaa5486822..17102a66f5 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -29,6 +29,7 @@ #include "libavutil/mem.h" #include "aac.h" +#include "aac_tablegen.h" #include @@ -1204,129 +1205,3 @@ const uint8_t ff_tns_max_bands_128[] = { 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }; // @} - - -#if CONFIG_HARDCODED_TABLES - -/** - * Table of pow(2, (i - 200)/4.) used for different purposes depending on the - * range of indices to the table: - * [ 0, 255] scale factor decoding when using C dsp.float_to_int16 - * [60, 315] scale factor decoding when using SIMD dsp.float_to_int16 - * [45, 300] intensity stereo position decoding mapped in reverse order i.e. 0->300, 1->299, ..., 254->46, 255->45 - */ -const float ff_aac_pow2sf_tab[428] = { - 8.88178420e-16, 1.05622810e-15, 1.25607397e-15, 1.49373210e-15, - 1.77635684e-15, 2.11245619e-15, 2.51214793e-15, 2.98746420e-15, - 3.55271368e-15, 4.22491238e-15, 5.02429587e-15, 5.97492839e-15, - 7.10542736e-15, 8.44982477e-15, 1.00485917e-14, 1.19498568e-14, - 1.42108547e-14, 1.68996495e-14, 2.00971835e-14, 2.38997136e-14, - 2.84217094e-14, 3.37992991e-14, 4.01943669e-14, 4.77994272e-14, - 5.68434189e-14, 6.75985982e-14, 8.03887339e-14, 9.55988543e-14, - 1.13686838e-13, 1.35197196e-13, 1.60777468e-13, 1.91197709e-13, - 2.27373675e-13, 2.70394393e-13, 3.21554936e-13, 3.82395417e-13, - 4.54747351e-13, 5.40788785e-13, 6.43109871e-13, 7.64790834e-13, - 9.09494702e-13, 1.08157757e-12, 1.28621974e-12, 1.52958167e-12, - 1.81898940e-12, 2.16315514e-12, 2.57243948e-12, 3.05916334e-12, - 3.63797881e-12, 4.32631028e-12, 5.14487897e-12, 6.11832668e-12, - 7.27595761e-12, 8.65262056e-12, 1.02897579e-11, 1.22366534e-11, - 1.45519152e-11, 1.73052411e-11, 2.05795159e-11, 2.44733067e-11, - 2.91038305e-11, 3.46104823e-11, 4.11590317e-11, 4.89466134e-11, - 5.82076609e-11, 6.92209645e-11, 8.23180635e-11, 9.78932268e-11, - 1.16415322e-10, 1.38441929e-10, 1.64636127e-10, 1.95786454e-10, - 2.32830644e-10, 2.76883858e-10, 3.29272254e-10, 3.91572907e-10, - 4.65661287e-10, 5.53767716e-10, 6.58544508e-10, 7.83145814e-10, - 9.31322575e-10, 1.10753543e-09, 1.31708902e-09, 1.56629163e-09, - 1.86264515e-09, 2.21507086e-09, 2.63417803e-09, 3.13258326e-09, - 3.72529030e-09, 4.43014173e-09, 5.26835606e-09, 6.26516652e-09, - 7.45058060e-09, 8.86028346e-09, 1.05367121e-08, 1.25303330e-08, - 1.49011612e-08, 1.77205669e-08, 2.10734243e-08, 2.50606661e-08, - 2.98023224e-08, 3.54411338e-08, 4.21468485e-08, 5.01213321e-08, - 5.96046448e-08, 7.08822677e-08, 8.42936970e-08, 1.00242664e-07, - 1.19209290e-07, 1.41764535e-07, 1.68587394e-07, 2.00485328e-07, - 2.38418579e-07, 2.83529071e-07, 3.37174788e-07, 4.00970657e-07, - 4.76837158e-07, 5.67058141e-07, 6.74349576e-07, 8.01941314e-07, - 9.53674316e-07, 1.13411628e-06, 1.34869915e-06, 1.60388263e-06, - 1.90734863e-06, 2.26823256e-06, 2.69739830e-06, 3.20776526e-06, - 3.81469727e-06, 4.53646513e-06, 5.39479661e-06, 6.41553051e-06, - 7.62939453e-06, 9.07293026e-06, 1.07895932e-05, 1.28310610e-05, - 1.52587891e-05, 1.81458605e-05, 2.15791864e-05, 2.56621220e-05, - 3.05175781e-05, 3.62917210e-05, 4.31583729e-05, 5.13242441e-05, - 6.10351562e-05, 7.25834421e-05, 8.63167458e-05, 1.02648488e-04, - 1.22070312e-04, 1.45166884e-04, 1.72633492e-04, 2.05296976e-04, - 2.44140625e-04, 2.90333768e-04, 3.45266983e-04, 4.10593953e-04, - 4.88281250e-04, 5.80667537e-04, 6.90533966e-04, 8.21187906e-04, - 9.76562500e-04, 1.16133507e-03, 1.38106793e-03, 1.64237581e-03, - 1.95312500e-03, 2.32267015e-03, 2.76213586e-03, 3.28475162e-03, - 3.90625000e-03, 4.64534029e-03, 5.52427173e-03, 6.56950324e-03, - 7.81250000e-03, 9.29068059e-03, 1.10485435e-02, 1.31390065e-02, - 1.56250000e-02, 1.85813612e-02, 2.20970869e-02, 2.62780130e-02, - 3.12500000e-02, 3.71627223e-02, 4.41941738e-02, 5.25560260e-02, - 6.25000000e-02, 7.43254447e-02, 8.83883476e-02, 1.05112052e-01, - 1.25000000e-01, 1.48650889e-01, 1.76776695e-01, 2.10224104e-01, - 2.50000000e-01, 2.97301779e-01, 3.53553391e-01, 4.20448208e-01, - 5.00000000e-01, 5.94603558e-01, 7.07106781e-01, 8.40896415e-01, - 1.00000000e+00, 1.18920712e+00, 1.41421356e+00, 1.68179283e+00, - 2.00000000e+00, 2.37841423e+00, 2.82842712e+00, 3.36358566e+00, - 4.00000000e+00, 4.75682846e+00, 5.65685425e+00, 6.72717132e+00, - 8.00000000e+00, 9.51365692e+00, 1.13137085e+01, 1.34543426e+01, - 1.60000000e+01, 1.90273138e+01, 2.26274170e+01, 2.69086853e+01, - 3.20000000e+01, 3.80546277e+01, 4.52548340e+01, 5.38173706e+01, - 6.40000000e+01, 7.61092554e+01, 9.05096680e+01, 1.07634741e+02, - 1.28000000e+02, 1.52218511e+02, 1.81019336e+02, 2.15269482e+02, - 2.56000000e+02, 3.04437021e+02, 3.62038672e+02, 4.30538965e+02, - 5.12000000e+02, 6.08874043e+02, 7.24077344e+02, 8.61077929e+02, - 1.02400000e+03, 1.21774809e+03, 1.44815469e+03, 1.72215586e+03, - 2.04800000e+03, 2.43549617e+03, 2.89630938e+03, 3.44431172e+03, - 4.09600000e+03, 4.87099234e+03, 5.79261875e+03, 6.88862343e+03, - 8.19200000e+03, 9.74198469e+03, 1.15852375e+04, 1.37772469e+04, - 1.63840000e+04, 1.94839694e+04, 2.31704750e+04, 2.75544937e+04, - 3.27680000e+04, 3.89679387e+04, 4.63409500e+04, 5.51089875e+04, - 6.55360000e+04, 7.79358775e+04, 9.26819000e+04, 1.10217975e+05, - 1.31072000e+05, 1.55871755e+05, 1.85363800e+05, 2.20435950e+05, - 2.62144000e+05, 3.11743510e+05, 3.70727600e+05, 4.40871900e+05, - 5.24288000e+05, 6.23487020e+05, 7.41455200e+05, 8.81743800e+05, - 1.04857600e+06, 1.24697404e+06, 1.48291040e+06, 1.76348760e+06, - 2.09715200e+06, 2.49394808e+06, 2.96582080e+06, 3.52697520e+06, - 4.19430400e+06, 4.98789616e+06, 5.93164160e+06, 7.05395040e+06, - 8.38860800e+06, 9.97579232e+06, 1.18632832e+07, 1.41079008e+07, - 1.67772160e+07, 1.99515846e+07, 2.37265664e+07, 2.82158016e+07, - 3.35544320e+07, 3.99031693e+07, 4.74531328e+07, 5.64316032e+07, - 6.71088640e+07, 7.98063385e+07, 9.49062656e+07, 1.12863206e+08, - 1.34217728e+08, 1.59612677e+08, 1.89812531e+08, 2.25726413e+08, - 2.68435456e+08, 3.19225354e+08, 3.79625062e+08, 4.51452825e+08, - 5.36870912e+08, 6.38450708e+08, 7.59250125e+08, 9.02905651e+08, - 1.07374182e+09, 1.27690142e+09, 1.51850025e+09, 1.80581130e+09, - 2.14748365e+09, 2.55380283e+09, 3.03700050e+09, 3.61162260e+09, - 4.29496730e+09, 5.10760567e+09, 6.07400100e+09, 7.22324521e+09, - 8.58993459e+09, 1.02152113e+10, 1.21480020e+10, 1.44464904e+10, - 1.71798692e+10, 2.04304227e+10, 2.42960040e+10, 2.88929808e+10, - 3.43597384e+10, 4.08608453e+10, 4.85920080e+10, 5.77859616e+10, - 6.87194767e+10, 8.17216907e+10, 9.71840160e+10, 1.15571923e+11, - 1.37438953e+11, 1.63443381e+11, 1.94368032e+11, 2.31143847e+11, - 2.74877907e+11, 3.26886763e+11, 3.88736064e+11, 4.62287693e+11, - 5.49755814e+11, 6.53773525e+11, 7.77472128e+11, 9.24575386e+11, - 1.09951163e+12, 1.30754705e+12, 1.55494426e+12, 1.84915077e+12, - 2.19902326e+12, 2.61509410e+12, 3.10988851e+12, 3.69830155e+12, - 4.39804651e+12, 5.23018820e+12, 6.21977702e+12, 7.39660309e+12, - 8.79609302e+12, 1.04603764e+13, 1.24395540e+13, 1.47932062e+13, - 1.75921860e+13, 2.09207528e+13, 2.48791081e+13, 2.95864124e+13, - 3.51843721e+13, 4.18415056e+13, 4.97582162e+13, 5.91728247e+13, - 7.03687442e+13, 8.36830112e+13, 9.95164324e+13, 1.18345649e+14, - 1.40737488e+14, 1.67366022e+14, 1.99032865e+14, 2.36691299e+14, - 2.81474977e+14, 3.34732045e+14, 3.98065730e+14, 4.73382598e+14, - 5.62949953e+14, 6.69464090e+14, 7.96131459e+14, 9.46765196e+14, - 1.12589991e+15, 1.33892818e+15, 1.59226292e+15, 1.89353039e+15, - 2.25179981e+15, 2.67785636e+15, 3.18452584e+15, 3.78706078e+15, - 4.50359963e+15, 5.35571272e+15, 6.36905167e+15, 7.57412156e+15, - 9.00719925e+15, 1.07114254e+16, 1.27381033e+16, 1.51482431e+16, - 1.80143985e+16, 2.14228509e+16, 2.54762067e+16, 3.02964863e+16, - 3.60287970e+16, 4.28457018e+16, 5.09524134e+16, 6.05929725e+16, - 7.20575940e+16, 8.56914035e+16, 1.01904827e+17, 1.21185945e+17, -}; - -#else - -float ff_aac_pow2sf_tab[428]; - -#endif /* CONFIG_HARDCODED_TABLES */ diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index 283d6c3a2d..c6213999b5 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -32,6 +32,7 @@ #include "libavutil/mem.h" #include "aac.h" +#include "aac_tablegen_decl.h" #include @@ -73,10 +74,4 @@ extern const uint16_t * const ff_swb_offset_128 [13]; extern const uint8_t ff_tns_max_bands_1024[13]; extern const uint8_t ff_tns_max_bands_128 [13]; -#if CONFIG_HARDCODED_TABLES -extern const float ff_aac_pow2sf_tab[428]; -#else -extern float ff_aac_pow2sf_tab[428]; -#endif /* CONFIG_HARDCODED_TABLES */ - #endif /* AVCODEC_AACTAB_H */ diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index 2d9f4a519d..1c87a2e564 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -31,6 +31,7 @@ #include #include "fft.h" +#include "aacps.h" /** * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header. @@ -133,6 +134,7 @@ typedef struct { ///The number of frequency bands in f_master unsigned n_master; SBRData data[2]; + PSContext ps; ///N_Low and N_High respectively, the number of frequency bands for low and high resolution unsigned n[2]; ///Number of noise floor bands @@ -157,7 +159,7 @@ typedef struct { ///QMF output of the HF generator float X_high[64][40][2]; ///QMF values of the reconstructed signal - DECLARE_ALIGNED(16, float, X)[2][2][32][64]; + DECLARE_ALIGNED(16, float, X)[2][2][38][64]; ///Zeroth coefficient used to filter the subband signals float alpha0[64][2]; ///First coefficient used to filter the subband signals @@ -176,7 +178,7 @@ typedef struct { float s_m[7][48]; float gain[7][48]; DECLARE_ALIGNED(16, float, qmf_filter_scratch)[5][64]; - RDFTContext rdft; + FFTContext mdct_ana; FFTContext mdct; } SpectralBandReplication; From 094e849f32ca15c42b2e4793fc9b51b414aa55b3 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 31 Jul 2010 21:13:20 +0000 Subject: [PATCH 113/301] update changelog for upcoming 0.6.1 point release Originally committed as revision 24633 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Changelog b/Changelog index 1ecc118cdc..a7b88e38eb 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,15 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.1: + +- fix autodetection of E-AC-3 substream samples +- performance fix for seekable http +- Backport AAC-HE v2 from trunk +- Ad VP80 fourcc +- smaller documentation fixes + + version 0.6: - PB-frame decoding for H.263 From d41187cb9e04404877d10b32a41e86cad95b5eaa Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 31 Jul 2010 21:55:38 +0000 Subject: [PATCH 114/301] update release notes for the upcoming 0.6.1 point release Originally committed as revision 24635 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/RELEASE b/RELEASE index fab225d852..0929e1d846 100644 --- a/RELEASE +++ b/RELEASE @@ -93,3 +93,31 @@ Notable license related changes - remaining GPL parts in AC-3 decoder converted to LGPL - libswscale can now be compiled in LGPL mode + + + +* 0.6.1 + +General notes +------------- + +This point release includes some minor updates to make the 0.6 release series +usable for users that need to retain the existing behavior as closely as +possible. The changes follow below: + +General Bugfixes +---------------- + +Included are some general, minor bugfixes: + +- fix autodetection of E-AC-3 substream samples +- performance fix for seekable http +- Add missing VP80 fourcc code for the VP8 codec +- smaller documentation fixes + + +HE-AAC v2 backport +------------------ + +This release includes a backport of the AAC decoder from trunk. This +enables proper playback of HE-AAC v2 media. From 84149812a64219da25a5bf514c5369036f134cca Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 31 Jul 2010 21:56:15 +0000 Subject: [PATCH 115/301] clarify addition of VP80 fourcc code Originally committed as revision 24636 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index a7b88e38eb..13f15ab568 100644 --- a/Changelog +++ b/Changelog @@ -6,7 +6,7 @@ version 0.6.1: - fix autodetection of E-AC-3 substream samples - performance fix for seekable http - Backport AAC-HE v2 from trunk -- Ad VP80 fourcc +- Add missing VP80 fourcc code for the VP8 codec - smaller documentation fixes From 9ad774ff3339634ed9c1727d6af151dbb4731f94 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 2 Oct 2010 07:35:56 +0000 Subject: [PATCH 116/301] property changes from the AAC backport Originally committed as revision 25306 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 From 79a16f0cac9a7251c7849923a25ddb048b5ce5f6 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 2 Oct 2010 07:42:42 +0000 Subject: [PATCH 117/301] Fix several security issues in flicvideo.c This fixes CVE-2010-3429 backport r25223 by michael Originally committed as revision 25307 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavcodec/flicvideo.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index 429ded53b2..b63d7d4498 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -159,7 +159,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, int pixel_skip; int pixel_countdown; unsigned char *pixels; - int pixel_limit; + unsigned int pixel_limit; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; @@ -253,10 +253,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets); } else if ((line_packets & 0xC000) == 0x8000) { // "last byte" opcode - pixels[y_ptr + s->frame.linesize[0] - 1] = line_packets & 0xff; + pixel_ptr= y_ptr + s->frame.linesize[0] - 1; + CHECK_PIXEL_PTR(0); + pixels[pixel_ptr] = line_packets & 0xff; } else { compressed_lines--; pixel_ptr = y_ptr; + CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { /* account for the skip bytes */ @@ -268,7 +271,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, byte_run = -byte_run; palette_idx1 = buf[stream_ptr++]; palette_idx2 = buf[stream_ptr++]; - CHECK_PIXEL_PTR(byte_run); + CHECK_PIXEL_PTR(byte_run * 2); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { pixels[pixel_ptr++] = palette_idx1; pixels[pixel_ptr++] = palette_idx2; @@ -298,6 +301,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, stream_ptr += 2; while (compressed_lines > 0) { pixel_ptr = y_ptr; + CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; line_packets = buf[stream_ptr++]; if (line_packets > 0) { @@ -453,7 +457,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, int pixel_countdown; unsigned char *pixels; int pixel; - int pixel_limit; + unsigned int pixel_limit; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; @@ -503,6 +507,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, } else { compressed_lines--; pixel_ptr = y_ptr; + CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { /* account for the skip bytes */ @@ -514,13 +519,13 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, byte_run = -byte_run; pixel = AV_RL16(&buf[stream_ptr]); stream_ptr += 2; - CHECK_PIXEL_PTR(byte_run); + CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; } } else { - CHECK_PIXEL_PTR(byte_run); + CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++, pixel_countdown--) { *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]); stream_ptr += 2; @@ -611,7 +616,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, if (byte_run > 0) { pixel = AV_RL16(&buf[stream_ptr]); stream_ptr += 2; - CHECK_PIXEL_PTR(byte_run); + CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; @@ -622,7 +627,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, } } else { /* copy pixels if byte_run < 0 */ byte_run = -byte_run; - CHECK_PIXEL_PTR(byte_run); + CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]); stream_ptr += 2; From 08f5b2464d25df89a8326d2df74ec1b20890c18f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 13 Oct 2010 12:42:38 +0000 Subject: [PATCH 118/301] add note about flic fix (CVE-2010-3429) Originally committed as revision 25467 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 13f15ab568..dd7483e6f1 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,8 @@ version 0.6.1: - Backport AAC-HE v2 from trunk - Add missing VP80 fourcc code for the VP8 codec - smaller documentation fixes +- fix several potentially exploitable issues in the FLIC decoder + (addresses CVE-2010-3429) version 0.6: From 540c6cca6e482268b9f90eef0c243802e078122c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 13 Oct 2010 12:43:18 +0000 Subject: [PATCH 119/301] add note about flic fix (CVE-2010-3429) to RELEASE notes Originally committed as revision 25468 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE b/RELEASE index 0929e1d846..16ac51abf5 100644 --- a/RELEASE +++ b/RELEASE @@ -114,6 +114,8 @@ Included are some general, minor bugfixes: - performance fix for seekable http - Add missing VP80 fourcc code for the VP8 codec - smaller documentation fixes +- fix several potentially exploitable issues in the FLIC decoder + (addresses CVE-2010-3429) HE-AAC v2 backport From e33f58af5a1a630c440eae51a69c35f014d0fa04 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 13 Oct 2010 12:44:47 +0000 Subject: [PATCH 120/301] update version for 0.6.1 Originally committed as revision 25469 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5a2a5806df..ee6cdce3c2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6 +0.6.1 From 32b0876fb57f0a9edf237fe692a0a88e0ac6f250 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 18 Oct 2010 10:52:44 +0000 Subject: [PATCH 121/301] small spelling fixes Originally committed as revision 25513 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- Changelog | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index dd7483e6f1..999a9e0f41 100644 --- a/Changelog +++ b/Changelog @@ -4,10 +4,10 @@ releases are sorted from youngest to oldest. version 0.6.1: - fix autodetection of E-AC-3 substream samples -- performance fix for seekable http -- Backport AAC-HE v2 from trunk -- Add missing VP80 fourcc code for the VP8 codec -- smaller documentation fixes +- performance fix for seekable HTTP +- backport AAC-HE v2 from trunk +- add missing VP80 fourcc code for the VP8 codec +- small documentation fixes - fix several potentially exploitable issues in the FLIC decoder (addresses CVE-2010-3429) @@ -18,7 +18,7 @@ version 0.6: - deprecated vhook subsystem removed - deprecated old scaler removed - VQF demuxer -- Alpha channel scaler +- alpha channel scaler - PCX encoder - RTP packetization of H.263 - RTP packetization of AMR From a5200fac2c8c560d0ee6c00b9d796137ea64fae8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 18 Oct 2010 11:28:24 +0000 Subject: [PATCH 122/301] Rewording for the 0.6.1 release notes. Originally committed as revision 25514 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/RELEASE b/RELEASE index 16ac51abf5..bb0e92c709 100644 --- a/RELEASE +++ b/RELEASE @@ -101,19 +101,17 @@ Notable license related changes General notes ------------- -This point release includes some minor updates to make the 0.6 release series -usable for users that need to retain the existing behavior as closely as -possible. The changes follow below: +This point release includes some updates to make the 0.6 release series usable +for users that need to retain the existing behavior as closely as possible. +The changes follow below: -General Bugfixes ----------------- - -Included are some general, minor bugfixes: +Bugfixes +-------- - fix autodetection of E-AC-3 substream samples -- performance fix for seekable http -- Add missing VP80 fourcc code for the VP8 codec -- smaller documentation fixes +- performance fix for seekable HTTP +- add missing VP80 fourcc code for the VP8 codec +- small documentation fixes - fix several potentially exploitable issues in the FLIC decoder (addresses CVE-2010-3429) @@ -121,5 +119,5 @@ Included are some general, minor bugfixes: HE-AAC v2 backport ------------------ -This release includes a backport of the AAC decoder from trunk. This +This release includes a backport of the AAC decoder from trunk, which enables proper playback of HE-AAC v2 media. From a38489c0d8ed0b37135a0e8c86efde06dd2a17c4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 18 Oct 2010 19:46:51 +0000 Subject: [PATCH 123/301] slight rewording for the release focus description Originally committed as revision 25524 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index bb0e92c709..a8919cdf56 100644 --- a/RELEASE +++ b/RELEASE @@ -6,7 +6,7 @@ Release Notes General notes ------------- -This release features a lot of improvements that are relevant for HTML5 video. +This release focuses on improvements for the new multimedia elements in HTML5. The H.264 and Theora decoders are now significantly faster, the Vorbis decoder has seen important updates and this release supports Google's newly released libvpx library for the VP8 codec and WebM container. From 4ac56bf7dc2c617c9fe6dce9167d499dbb8a9b76 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 27 Oct 2010 16:30:01 +0000 Subject: [PATCH 124/301] Fix crashes in vorbis decoding found by zzuf Fixes issue 2322. Originally committed as revision 25591 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit 3dde66752d59dfdd0f3727efd66e7202b3c75078) Signed-off-by: Janne Grunau --- libavcodec/vorbis_dec.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index 8c56400c77..a0f2342d7c 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -61,8 +61,8 @@ typedef struct vorbis_floor0_s vorbis_floor0; typedef struct vorbis_floor1_s vorbis_floor1; struct vorbis_context_s; typedef -uint_fast8_t (* vorbis_floor_decode_func) - (struct vorbis_context_s *, vorbis_floor_data *, float *); +int (* vorbis_floor_decode_func) + (struct vorbis_context_s *, vorbis_floor_data *, float *); typedef struct { uint_fast8_t floor_type; vorbis_floor_decode_func decode; @@ -453,11 +453,11 @@ static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc) // Process floors part -static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, - vorbis_floor_data *vfu, float *vec); +static int vorbis_floor0_decode(vorbis_context *vc, + vorbis_floor_data *vfu, float *vec); static void create_map(vorbis_context *vc, uint_fast8_t floor_number); -static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, - vorbis_floor_data *vfu, float *vec); +static int vorbis_floor1_decode(vorbis_context *vc, + vorbis_floor_data *vfu, float *vec); static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) { GetBitContext *gb = &vc->gb; @@ -1002,8 +1002,8 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) // Read and decode floor -static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, - vorbis_floor_data *vfu, float *vec) +static int vorbis_floor0_decode(vorbis_context *vc, + vorbis_floor_data *vfu, float *vec) { vorbis_floor0 *vf = &vfu->t0; float *lsp = vf->lsp; @@ -1027,6 +1027,9 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, } AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx); codebook = vc->codebooks[vf->book_list[book_idx]]; + /* Invalid codebook! */ + if (!codebook.codevectors) + return -1; while (lsp_lenorder) { int vec_off; @@ -1112,8 +1115,8 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, return 0; } -static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, - vorbis_floor_data *vfu, float *vec) +static int vorbis_floor1_decode(vorbis_context *vc, + vorbis_floor_data *vfu, float *vec) { vorbis_floor1 *vf = &vfu->t1; GetBitContext *gb = &vc->gb; @@ -1490,13 +1493,20 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) for (i = 0; i < vc->audio_channels; ++i) { vorbis_floor *floor; + int ret; if (mapping->submaps > 1) { floor = &vc->floors[mapping->submap_floor[mapping->mux[i]]]; } else { floor = &vc->floors[mapping->submap_floor[0]]; } - no_residue[i] = floor->decode(vc, &floor->data, ch_floor_ptr); + ret = floor->decode(vc, &floor->data, ch_floor_ptr); + + if (ret < 0) { + av_log(vc->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n"); + return -1; + } + no_residue[i] = ret; ch_floor_ptr += blocksize / 2; } From 5e3d023702587c137ac0a725d601d26a8978a125 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Sat, 15 Jan 2011 16:19:06 +0000 Subject: [PATCH 125/301] Check rangebits to avoid a possible crash. Fixes issue 2548 (and Chrome issue 68115 and unknown CERT issues). Patch by Frank Barchard, fbarchard at google Originally committed as revision 26365 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit 13184036a6b1b1d4b61c91118c0896e9ad4634c3) Signed-off-by: Janne Grunau --- libavcodec/vorbis_dec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index a0f2342d7c..f8067db41c 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -477,6 +477,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) if (floor_setup->floor_type == 1) { uint_fast8_t maximum_class = 0; uint_fast8_t rangebits; + uint_fast32_t rangemax; uint_fast16_t floor1_values = 2; floor_setup->decode = vorbis_floor1_decode; @@ -530,8 +531,15 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) rangebits = get_bits(gb, 4); + rangemax = (1 << rangebits); + if (rangemax > vc->blocksize[1] / 2) { + av_log(vc->avccontext, AV_LOG_ERROR, + "Floor value is too large for blocksize: %d (%d)\n", + rangemax, vc->blocksize[1] / 2); + return -1; + } floor_setup->data.t1.list[0].x = 0; - floor_setup->data.t1.list[1].x = (1 << rangebits); + floor_setup->data.t1.list[1].x = rangemax; for (j = 0; j < floor_setup->data.t1.partitions; ++j) { for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) { From 2d782b964624fd454151e3f8ac9b6718f665466c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 18 Mar 2011 16:59:07 +0100 Subject: [PATCH 126/301] Bump version number for 0.6.2 release. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ee6cdce3c2..b616048743 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.1 +0.6.2 From cf69619141a5742c4e4156177335d553c5bab7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 19 Feb 2011 11:33:01 +0100 Subject: [PATCH 127/301] Fix invalid reads in VC1 decoder Patch discussed and taken from https://roundup.ffmpeg.org/issue2584 (cherry picked from commit 2bbec1eda46d907605772a8b6e8263caa4bc4c82) Change related to CVE-2011-0723 --- libavcodec/vc1dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 52392c3f76..abcc5ecda8 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -1365,7 +1365,7 @@ static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, if (index != vc1_ac_sizes[codingset] - 1) { run = vc1_index_decode_table[codingset][index][0]; level = vc1_index_decode_table[codingset][index][1]; - lst = index >= vc1_last_decode_table[codingset]; + lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0; if(get_bits1(gb)) level = -level; } else { From f9bf2a4ab10a0718a11d43fecba75bb40aac6628 Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 15 Mar 2011 09:19:43 +0000 Subject: [PATCH 128/301] Do not attempt to decode APE file with no frames This fixes invalid reads/writes with this sample: http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt (cherry picked from commit 8312e3fc9041027a33c8bc667bb99740fdf41dd5) --- libavformat/ape.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/ape.c b/libavformat/ape.c index 91acf7240d..0ebc307668 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -242,6 +242,10 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) url_fskip(pb, ape->wavheaderlength); } + if(!ape->totalframes){ + av_log(s, AV_LOG_ERROR, "No frames in the file!\n"); + return AVERROR(EINVAL); + } if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){ av_log(s, AV_LOG_ERROR, "Too many frames: %d\n", ape->totalframes); return -1; From 5d01cd842962850756d29dda5ddd1ac2b68607c1 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Mon, 17 Jan 2011 15:49:11 +0100 Subject: [PATCH 129/301] convert svn:ignore properties to .gitignore files Signed-off-by: Janne Grunau (cherry picked from commit 348b8218f7a59374355c966dbe3b851a7275f952) --- .gitignore | 15 +++++++++++++++ doc/.gitignore | 3 +++ ffpresets/.gitignore | 1 + libavcodec/.gitignore | 8 ++++++++ libavcodec/alpha/.gitignore | 3 +++ libavcodec/arm/.gitignore | 3 +++ libavcodec/avr32/.gitignore | 3 +++ libavcodec/bfin/.gitignore | 3 +++ libavcodec/mips/.gitignore | 3 +++ libavcodec/mlib/.gitignore | 3 +++ libavcodec/ppc/.gitignore | 3 +++ libavcodec/ps2/.gitignore | 3 +++ libavcodec/sh4/.gitignore | 3 +++ libavcodec/sparc/.gitignore | 3 +++ libavcodec/x86/.gitignore | 5 +++++ libavcore/.gitignore | 5 +++++ libavdevice/.gitignore | 8 ++++++++ libavfilter/.gitignore | 8 ++++++++ libavfilter/x86/.gitignore | 1 + libavformat/.gitignore | 8 ++++++++ libavutil/.gitignore | 9 +++++++++ libavutil/arm/.gitignore | 3 +++ libavutil/avr32/.gitignore | 2 ++ libavutil/bfin/.gitignore | 3 +++ libavutil/mips/.gitignore | 2 ++ libavutil/ppc/.gitignore | 3 +++ libavutil/sh4/.gitignore | 3 +++ libavutil/tomi/.gitignore | 3 +++ libavutil/x86/.gitignore | 3 +++ libpostproc/.gitignore | 6 ++++++ libswscale/.gitignore | 7 +++++++ libswscale/bfin/.gitignore | 2 ++ libswscale/mlib/.gitignore | 2 ++ libswscale/ppc/.gitignore | 2 ++ libswscale/sparc/.gitignore | 2 ++ libswscale/x86/.gitignore | 2 ++ tests/.gitignore | 12 ++++++++++++ tools/.gitignore | 18 ++++++++++++++++++ 38 files changed, 176 insertions(+) create mode 100644 .gitignore create mode 100644 doc/.gitignore create mode 100644 ffpresets/.gitignore create mode 100644 libavcodec/.gitignore create mode 100644 libavcodec/alpha/.gitignore create mode 100644 libavcodec/arm/.gitignore create mode 100644 libavcodec/avr32/.gitignore create mode 100644 libavcodec/bfin/.gitignore create mode 100644 libavcodec/mips/.gitignore create mode 100644 libavcodec/mlib/.gitignore create mode 100644 libavcodec/ppc/.gitignore create mode 100644 libavcodec/ps2/.gitignore create mode 100644 libavcodec/sh4/.gitignore create mode 100644 libavcodec/sparc/.gitignore create mode 100644 libavcodec/x86/.gitignore create mode 100644 libavcore/.gitignore create mode 100644 libavdevice/.gitignore create mode 100644 libavfilter/.gitignore create mode 100644 libavfilter/x86/.gitignore create mode 100644 libavformat/.gitignore create mode 100644 libavutil/.gitignore create mode 100644 libavutil/arm/.gitignore create mode 100644 libavutil/avr32/.gitignore create mode 100644 libavutil/bfin/.gitignore create mode 100644 libavutil/mips/.gitignore create mode 100644 libavutil/ppc/.gitignore create mode 100644 libavutil/sh4/.gitignore create mode 100644 libavutil/tomi/.gitignore create mode 100644 libavutil/x86/.gitignore create mode 100644 libpostproc/.gitignore create mode 100644 libswscale/.gitignore create mode 100644 libswscale/bfin/.gitignore create mode 100644 libswscale/mlib/.gitignore create mode 100644 libswscale/ppc/.gitignore create mode 100644 libswscale/sparc/.gitignore create mode 100644 libswscale/x86/.gitignore create mode 100644 tests/.gitignore create mode 100644 tools/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..64dc57bec0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +.config +.version +*.o +*.d +*.exe +*.ho +*-test +*_g +config.* +doxy +ffmpeg +ffplay +ffprobe +ffserver +version.h diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000000..aeaee91f95 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,3 @@ +*.1 +*.html +*.pod diff --git a/ffpresets/.gitignore b/ffpresets/.gitignore new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/ffpresets/.gitignore @@ -0,0 +1 @@ + diff --git a/libavcodec/.gitignore b/libavcodec/.gitignore new file mode 100644 index 0000000000..40a1c87eec --- /dev/null +++ b/libavcodec/.gitignore @@ -0,0 +1,8 @@ +*.o +*.d +*.exe +*.ho +*-example +*-test +libavcodec* + diff --git a/libavcodec/alpha/.gitignore b/libavcodec/alpha/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/alpha/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/arm/.gitignore b/libavcodec/arm/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/arm/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/avr32/.gitignore b/libavcodec/avr32/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/avr32/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/bfin/.gitignore b/libavcodec/bfin/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/bfin/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/mips/.gitignore b/libavcodec/mips/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/mips/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/mlib/.gitignore b/libavcodec/mlib/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/mlib/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/ppc/.gitignore b/libavcodec/ppc/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/ppc/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/ps2/.gitignore b/libavcodec/ps2/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/ps2/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/sh4/.gitignore b/libavcodec/sh4/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/sh4/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/sparc/.gitignore b/libavcodec/sparc/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavcodec/sparc/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavcodec/x86/.gitignore b/libavcodec/x86/.gitignore new file mode 100644 index 0000000000..eb249fb180 --- /dev/null +++ b/libavcodec/x86/.gitignore @@ -0,0 +1,5 @@ +*.d +*.exe +*.ho +*-test + diff --git a/libavcore/.gitignore b/libavcore/.gitignore new file mode 100644 index 0000000000..81b575239e --- /dev/null +++ b/libavcore/.gitignore @@ -0,0 +1,5 @@ +*.o +*.d +*.ho +libavcore* + diff --git a/libavdevice/.gitignore b/libavdevice/.gitignore new file mode 100644 index 0000000000..5d53ca790f --- /dev/null +++ b/libavdevice/.gitignore @@ -0,0 +1,8 @@ +*.o +*.d +*.exe +*.ho +*-example +*-test +libavdevice* + diff --git a/libavfilter/.gitignore b/libavfilter/.gitignore new file mode 100644 index 0000000000..f6d3cd0c1a --- /dev/null +++ b/libavfilter/.gitignore @@ -0,0 +1,8 @@ +*.o +*.d +*.exe +*.ho +*-example +*-test +libavfilter* + diff --git a/libavfilter/x86/.gitignore b/libavfilter/x86/.gitignore new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/libavfilter/x86/.gitignore @@ -0,0 +1 @@ + diff --git a/libavformat/.gitignore b/libavformat/.gitignore new file mode 100644 index 0000000000..50e4684f77 --- /dev/null +++ b/libavformat/.gitignore @@ -0,0 +1,8 @@ +*.o +*.d +*.exe +*.ho +*-example +*-test +libavformat* + diff --git a/libavutil/.gitignore b/libavutil/.gitignore new file mode 100644 index 0000000000..3e21b95006 --- /dev/null +++ b/libavutil/.gitignore @@ -0,0 +1,9 @@ +*.d +*.o +*.exe +*.ho +*-example +*-test +libavutil* +avconfig.h + diff --git a/libavutil/arm/.gitignore b/libavutil/arm/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavutil/arm/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavutil/avr32/.gitignore b/libavutil/avr32/.gitignore new file mode 100644 index 0000000000..2a6b22b026 --- /dev/null +++ b/libavutil/avr32/.gitignore @@ -0,0 +1,2 @@ +*.ho + diff --git a/libavutil/bfin/.gitignore b/libavutil/bfin/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavutil/bfin/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavutil/mips/.gitignore b/libavutil/mips/.gitignore new file mode 100644 index 0000000000..2a6b22b026 --- /dev/null +++ b/libavutil/mips/.gitignore @@ -0,0 +1,2 @@ +*.ho + diff --git a/libavutil/ppc/.gitignore b/libavutil/ppc/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavutil/ppc/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavutil/sh4/.gitignore b/libavutil/sh4/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavutil/sh4/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavutil/tomi/.gitignore b/libavutil/tomi/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavutil/tomi/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libavutil/x86/.gitignore b/libavutil/x86/.gitignore new file mode 100644 index 0000000000..854570fa24 --- /dev/null +++ b/libavutil/x86/.gitignore @@ -0,0 +1,3 @@ +*.d +*.ho + diff --git a/libpostproc/.gitignore b/libpostproc/.gitignore new file mode 100644 index 0000000000..f0eb9a0fac --- /dev/null +++ b/libpostproc/.gitignore @@ -0,0 +1,6 @@ +*.d +*.exe +*.ho +*-example +*-test +libpostproc* diff --git a/libswscale/.gitignore b/libswscale/.gitignore new file mode 100644 index 0000000000..fd91a1c6e3 --- /dev/null +++ b/libswscale/.gitignore @@ -0,0 +1,7 @@ +*.d +*.exe +*.ho +*-example +*-test +libswscale* +*.o diff --git a/libswscale/bfin/.gitignore b/libswscale/bfin/.gitignore new file mode 100644 index 0000000000..d57a7d62c6 --- /dev/null +++ b/libswscale/bfin/.gitignore @@ -0,0 +1,2 @@ +*.d +*.ho diff --git a/libswscale/mlib/.gitignore b/libswscale/mlib/.gitignore new file mode 100644 index 0000000000..d57a7d62c6 --- /dev/null +++ b/libswscale/mlib/.gitignore @@ -0,0 +1,2 @@ +*.d +*.ho diff --git a/libswscale/ppc/.gitignore b/libswscale/ppc/.gitignore new file mode 100644 index 0000000000..d57a7d62c6 --- /dev/null +++ b/libswscale/ppc/.gitignore @@ -0,0 +1,2 @@ +*.d +*.ho diff --git a/libswscale/sparc/.gitignore b/libswscale/sparc/.gitignore new file mode 100644 index 0000000000..d57a7d62c6 --- /dev/null +++ b/libswscale/sparc/.gitignore @@ -0,0 +1,2 @@ +*.d +*.ho diff --git a/libswscale/x86/.gitignore b/libswscale/x86/.gitignore new file mode 100644 index 0000000000..d57a7d62c6 --- /dev/null +++ b/libswscale/x86/.gitignore @@ -0,0 +1,2 @@ +*.d +*.ho diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000000..ae7b4eacba --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,12 @@ +*.o +*.d +*.exe +audiogen +base64 +data +rotozoom +seek_test +tiny_psnr +videogen +vsynth1 +vsynth2 diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000000..535660960d --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1,18 @@ +*.o +*.d +*.exe +cws2fws +graph2dot +lavfi-showfiltfmts +pktdumper +probetest +qt-faststart +trasher*.d +*.exe +cws2fws +graph2dot +lavfi-showfiltfmts +pktdumper +probetest +qt-faststart +trasher From dda2062c316091ff12e6e35e6c2f24149310d0d1 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Tue, 18 Jan 2011 20:44:24 +0100 Subject: [PATCH 130/301] consolidate .gitignore patters into a single file Signed-off-by: Janne Grunau (cherry picked from commit 2c3589bfda036c7827ded0bf38b16dfe7630bae1) Signed-off-by: Reinhard Tartler --- .gitignore | 30 ++++++++++++++++++++++++++++++ doc/.gitignore | 3 --- ffpresets/.gitignore | 1 - libavcodec/.gitignore | 8 -------- libavcodec/alpha/.gitignore | 3 --- libavcodec/arm/.gitignore | 3 --- libavcodec/avr32/.gitignore | 3 --- libavcodec/bfin/.gitignore | 3 --- libavcodec/mips/.gitignore | 3 --- libavcodec/mlib/.gitignore | 3 --- libavcodec/ppc/.gitignore | 3 --- libavcodec/ps2/.gitignore | 3 --- libavcodec/sh4/.gitignore | 3 --- libavcodec/sparc/.gitignore | 3 --- libavcodec/x86/.gitignore | 5 ----- libavcore/.gitignore | 5 ----- libavdevice/.gitignore | 8 -------- libavfilter/.gitignore | 8 -------- libavfilter/x86/.gitignore | 1 - libavformat/.gitignore | 8 -------- libavutil/.gitignore | 9 --------- libavutil/arm/.gitignore | 3 --- libavutil/avr32/.gitignore | 2 -- libavutil/bfin/.gitignore | 3 --- libavutil/mips/.gitignore | 2 -- libavutil/ppc/.gitignore | 3 --- libavutil/sh4/.gitignore | 3 --- libavutil/tomi/.gitignore | 3 --- libavutil/x86/.gitignore | 3 --- libpostproc/.gitignore | 6 ------ libswscale/.gitignore | 7 ------- libswscale/bfin/.gitignore | 2 -- libswscale/mlib/.gitignore | 2 -- libswscale/ppc/.gitignore | 2 -- libswscale/sparc/.gitignore | 2 -- libswscale/x86/.gitignore | 2 -- tests/.gitignore | 12 ------------ tools/.gitignore | 18 ------------------ 38 files changed, 30 insertions(+), 161 deletions(-) delete mode 100644 doc/.gitignore delete mode 100644 ffpresets/.gitignore delete mode 100644 libavcodec/.gitignore delete mode 100644 libavcodec/alpha/.gitignore delete mode 100644 libavcodec/arm/.gitignore delete mode 100644 libavcodec/avr32/.gitignore delete mode 100644 libavcodec/bfin/.gitignore delete mode 100644 libavcodec/mips/.gitignore delete mode 100644 libavcodec/mlib/.gitignore delete mode 100644 libavcodec/ppc/.gitignore delete mode 100644 libavcodec/ps2/.gitignore delete mode 100644 libavcodec/sh4/.gitignore delete mode 100644 libavcodec/sparc/.gitignore delete mode 100644 libavcodec/x86/.gitignore delete mode 100644 libavcore/.gitignore delete mode 100644 libavdevice/.gitignore delete mode 100644 libavfilter/.gitignore delete mode 100644 libavfilter/x86/.gitignore delete mode 100644 libavformat/.gitignore delete mode 100644 libavutil/.gitignore delete mode 100644 libavutil/arm/.gitignore delete mode 100644 libavutil/avr32/.gitignore delete mode 100644 libavutil/bfin/.gitignore delete mode 100644 libavutil/mips/.gitignore delete mode 100644 libavutil/ppc/.gitignore delete mode 100644 libavutil/sh4/.gitignore delete mode 100644 libavutil/tomi/.gitignore delete mode 100644 libavutil/x86/.gitignore delete mode 100644 libpostproc/.gitignore delete mode 100644 libswscale/.gitignore delete mode 100644 libswscale/bfin/.gitignore delete mode 100644 libswscale/mlib/.gitignore delete mode 100644 libswscale/ppc/.gitignore delete mode 100644 libswscale/sparc/.gitignore delete mode 100644 libswscale/x86/.gitignore delete mode 100644 tests/.gitignore delete mode 100644 tools/.gitignore diff --git a/.gitignore b/.gitignore index 64dc57bec0..eac1758ed9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,12 +4,42 @@ *.d *.exe *.ho +*-example *-test *_g config.* +doc/*.1 +doc/*.html +doc/*.pod doxy ffmpeg ffplay ffprobe ffserver +libavcodec/libavcodec* +libavcore/libavcore* +libavdevice/libavdevice* +libavfilter/libavfilter* +libavformat/libavformat* +libavutil/avconfig.h +libavutil/libavutil* +libpostproc/libpostproc* +libswscale/libswscale* +tests/audiogen +tests/base64 +tests/data +tests/rotozoom +tests/seek_test +tests/tiny_psnr +tests/videogen +tests/vsynth1 +tests/vsynth2 +tools/cws2fws +tools/graph2dot +tools/lavfi-showfiltfmts +tools/pktdumper +tools/probetest +tools/qt-faststart +tools/trasher +tools/trasher*.d version.h diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index aeaee91f95..0000000000 --- a/doc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.1 -*.html -*.pod diff --git a/ffpresets/.gitignore b/ffpresets/.gitignore deleted file mode 100644 index 8b13789179..0000000000 --- a/ffpresets/.gitignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libavcodec/.gitignore b/libavcodec/.gitignore deleted file mode 100644 index 40a1c87eec..0000000000 --- a/libavcodec/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.o -*.d -*.exe -*.ho -*-example -*-test -libavcodec* - diff --git a/libavcodec/alpha/.gitignore b/libavcodec/alpha/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/alpha/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/arm/.gitignore b/libavcodec/arm/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/arm/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/avr32/.gitignore b/libavcodec/avr32/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/avr32/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/bfin/.gitignore b/libavcodec/bfin/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/bfin/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/mips/.gitignore b/libavcodec/mips/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/mips/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/mlib/.gitignore b/libavcodec/mlib/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/mlib/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/ppc/.gitignore b/libavcodec/ppc/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/ppc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/ps2/.gitignore b/libavcodec/ps2/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/ps2/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/sh4/.gitignore b/libavcodec/sh4/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/sh4/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/sparc/.gitignore b/libavcodec/sparc/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavcodec/sparc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavcodec/x86/.gitignore b/libavcodec/x86/.gitignore deleted file mode 100644 index eb249fb180..0000000000 --- a/libavcodec/x86/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.d -*.exe -*.ho -*-test - diff --git a/libavcore/.gitignore b/libavcore/.gitignore deleted file mode 100644 index 81b575239e..0000000000 --- a/libavcore/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.o -*.d -*.ho -libavcore* - diff --git a/libavdevice/.gitignore b/libavdevice/.gitignore deleted file mode 100644 index 5d53ca790f..0000000000 --- a/libavdevice/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.o -*.d -*.exe -*.ho -*-example -*-test -libavdevice* - diff --git a/libavfilter/.gitignore b/libavfilter/.gitignore deleted file mode 100644 index f6d3cd0c1a..0000000000 --- a/libavfilter/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.o -*.d -*.exe -*.ho -*-example -*-test -libavfilter* - diff --git a/libavfilter/x86/.gitignore b/libavfilter/x86/.gitignore deleted file mode 100644 index 8b13789179..0000000000 --- a/libavfilter/x86/.gitignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libavformat/.gitignore b/libavformat/.gitignore deleted file mode 100644 index 50e4684f77..0000000000 --- a/libavformat/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.o -*.d -*.exe -*.ho -*-example -*-test -libavformat* - diff --git a/libavutil/.gitignore b/libavutil/.gitignore deleted file mode 100644 index 3e21b95006..0000000000 --- a/libavutil/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.d -*.o -*.exe -*.ho -*-example -*-test -libavutil* -avconfig.h - diff --git a/libavutil/arm/.gitignore b/libavutil/arm/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavutil/arm/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavutil/avr32/.gitignore b/libavutil/avr32/.gitignore deleted file mode 100644 index 2a6b22b026..0000000000 --- a/libavutil/avr32/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.ho - diff --git a/libavutil/bfin/.gitignore b/libavutil/bfin/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavutil/bfin/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavutil/mips/.gitignore b/libavutil/mips/.gitignore deleted file mode 100644 index 2a6b22b026..0000000000 --- a/libavutil/mips/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.ho - diff --git a/libavutil/ppc/.gitignore b/libavutil/ppc/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavutil/ppc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavutil/sh4/.gitignore b/libavutil/sh4/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavutil/sh4/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavutil/tomi/.gitignore b/libavutil/tomi/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavutil/tomi/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libavutil/x86/.gitignore b/libavutil/x86/.gitignore deleted file mode 100644 index 854570fa24..0000000000 --- a/libavutil/x86/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.ho - diff --git a/libpostproc/.gitignore b/libpostproc/.gitignore deleted file mode 100644 index f0eb9a0fac..0000000000 --- a/libpostproc/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -*.d -*.exe -*.ho -*-example -*-test -libpostproc* diff --git a/libswscale/.gitignore b/libswscale/.gitignore deleted file mode 100644 index fd91a1c6e3..0000000000 --- a/libswscale/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.d -*.exe -*.ho -*-example -*-test -libswscale* -*.o diff --git a/libswscale/bfin/.gitignore b/libswscale/bfin/.gitignore deleted file mode 100644 index d57a7d62c6..0000000000 --- a/libswscale/bfin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.d -*.ho diff --git a/libswscale/mlib/.gitignore b/libswscale/mlib/.gitignore deleted file mode 100644 index d57a7d62c6..0000000000 --- a/libswscale/mlib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.d -*.ho diff --git a/libswscale/ppc/.gitignore b/libswscale/ppc/.gitignore deleted file mode 100644 index d57a7d62c6..0000000000 --- a/libswscale/ppc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.d -*.ho diff --git a/libswscale/sparc/.gitignore b/libswscale/sparc/.gitignore deleted file mode 100644 index d57a7d62c6..0000000000 --- a/libswscale/sparc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.d -*.ho diff --git a/libswscale/x86/.gitignore b/libswscale/x86/.gitignore deleted file mode 100644 index d57a7d62c6..0000000000 --- a/libswscale/x86/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.d -*.ho diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index ae7b4eacba..0000000000 --- a/tests/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -*.o -*.d -*.exe -audiogen -base64 -data -rotozoom -seek_test -tiny_psnr -videogen -vsynth1 -vsynth2 diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 535660960d..0000000000 --- a/tools/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -*.o -*.d -*.exe -cws2fws -graph2dot -lavfi-showfiltfmts -pktdumper -probetest -qt-faststart -trasher*.d -*.exe -cws2fws -graph2dot -lavfi-showfiltfmts -pktdumper -probetest -qt-faststart -trasher From ba1927dda9a96476f3b0f56278349a596a1f8558 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 18 Mar 2011 18:10:32 +0100 Subject: [PATCH 131/301] partially rename FFmpeg to Libav update mailing list references and irc channels in configure (cherry picked from commit 070c5d0f3530c16c92b81f3f0de2943410367c00) --- CREDITS | 6 ++++-- Doxyfile | 2 +- INSTALL | 6 +++--- LICENSE | 20 ++++++++++---------- README | 2 +- cmdutils.c | 2 +- configure | 28 ++++++++++++++-------------- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/CREDITS b/CREDITS index 404cf38d44..4a537786f0 100644 --- a/CREDITS +++ b/CREDITS @@ -1,5 +1,7 @@ -This file contains the name of the people who have contributed to -FFmpeg. The names are sorted alphabetically by last name. +This file contains the names of some of the people who have contributed to +Libav/FFmpeg. The names are sorted alphabetically by last name. As this file is +currently quite outdated and git serves as a much better tool for determining +authorship, it remains here for historical reasons only. Dénes Balatoni Michel Bardiaux diff --git a/Doxyfile b/Doxyfile index ee233b9d00..5e1a4055a3 100644 --- a/Doxyfile +++ b/Doxyfile @@ -17,7 +17,7 @@ # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = FFmpeg +PROJECT_NAME = Libav # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or diff --git a/INSTALL b/INSTALL index 8cd22bd441..2ed04ef2b9 100644 --- a/INSTALL +++ b/INSTALL @@ -2,10 +2,10 @@ 1) Type './configure' to create the configuration. A list of configure options is printed by running 'configure --help'. -'configure' can be launched from a directory different from the FFmpeg +'configure' can be launched from a directory different from the Libav sources to build the objects out of tree. To do this, use an absolute -path when launching 'configure', e.g. '/ffmpegdir/ffmpeg/configure'. +path when launching 'configure', e.g. '/libavdir/libav/configure'. -2) Then type 'make' to build FFmpeg. GNU Make 3.81 or later is required. +2) Then type 'make' to build Libav. GNU Make 3.81 or later is required. 3) Type 'make install' to install all binaries and libraries you built. diff --git a/LICENSE b/LICENSE index 668350b185..c6bcbe8efb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,17 +1,17 @@ -FFmpeg: +Libav: ------- -Most files in FFmpeg are under the GNU Lesser General Public License version 2.1 +Most files in Libav are under the GNU Lesser General Public License version 2.1 or later (LGPL v2.1+). Read the file COPYING.LGPLv2.1 for details. Some other files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to -FFmpeg. +Libav. -Some optional parts of FFmpeg are licensed under the GNU General Public License +Some optional parts of Libav are licensed under the GNU General Public License version 2 or later (GPL v2+). See the file COPYING.GPLv2 for details. None of these parts are used by default, you have to explicitly pass --enable-gpl to -configure to activate them. In this case, FFmpeg's license changes to GPL v2+. +configure to activate them. In this case, Libav's license changes to GPL v2+. -Specifically, the GPL parts of FFmpeg are +Specifically, the GPL parts of Libav are - libpostproc - optional MMX optimizations for YUV to RGB colorspace conversion in @@ -37,14 +37,14 @@ external libraries: ------------------- Some external libraries, e.g. libx264, are under GPL and can be used in -conjunction with FFmpeg. They require --enable-gpl to be passed to configure +conjunction with Libav. They require --enable-gpl to be passed to configure as well. The OpenCORE external libraries are under the Apache License 2.0. That license is incompatible with the LGPL v2.1 and the GPL v2, but not with version 3 of -those licenses. So to combine the OpenCORE libraries with FFmpeg, the license +those licenses. So to combine the OpenCORE libraries with Libav, the license version needs to be upgraded by passing --enable-version3 to configure. -The nonfree external library libfaac can be hooked up in FFmpeg. You need to +The nonfree external library libfaac can be hooked up in Libav. You need to pass --enable-nonfree to configure to enable it. Employ this option with care -as FFmpeg then becomes nonfree and unredistributable. +as Libav then becomes nonfree and unredistributable. diff --git a/README b/README index e907e90223..6346cff926 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -FFmpeg README +Libav README ------------- 1) Documentation diff --git a/cmdutils.c b/cmdutils.c index 2349b7052e..23f0efeed6 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -341,7 +341,7 @@ static void maybe_print_config(const char *lib, const char *cfg) void show_banner(void) { - fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", + fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the Libav developers\n", program_name, program_birth_year, this_year); fprintf(stderr, " built on %s %s with %s %s\n", __DATE__, __TIME__, CC_TYPE, CC_VERSION); diff --git a/configure b/configure index 0166829f77..3f5176ea39 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #!/bin/sh # -# FFmpeg configure script +# Libav configure script # # Copyright (c) 2000-2002 Fabrice Bellard # Copyright (c) 2005-2008 Diego Biurrun @@ -44,9 +44,9 @@ if test "$E1" != 0 || test "$E2" = 0; then echo "No compatible shell script interpreter found." echo "This configure script requires a POSIX-compatible shell" echo "such as bash or ksh." - echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH." + echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH." echo "Instead, install a working POSIX-compatible shell." - echo "Disabling this configure test will create a broken FFmpeg." + echo "Disabling this configure test will create a broken Libav." if test "$BASH_VERSION" = '2.04.0(1)-release'; then echo "This bash version ($BASH_VERSION) is broken on your platform." echo "Upgrade to a later version if available." @@ -239,7 +239,7 @@ Advanced options (experts only): --malloc-prefix=PFX prefix malloc and related names with PFX --enable-sram allow use of on-chip SRAM -Developer options (useful when working on FFmpeg itself): +Developer options (useful when working on Libav itself): --disable-debug disable debugging symbols --enable-debug=LEVEL set the debug level [$debuglevel] --enable-gprof enable profiling with gprof [$gprof] @@ -275,8 +275,8 @@ die(){ cat < Date: Fri, 18 Mar 2011 18:01:41 +0100 Subject: [PATCH 132/301] release notes and changelog for 0.6.2 --- Changelog | 7 +++++++ RELEASE | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Changelog b/Changelog index 999a9e0f41..2e0a99c378 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,13 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.2: + +- Fix invalid reads in VC-1 decoding (related to CVE-2011-0723) +- Do not attempt to decode APE file with no frames + (adresses http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt) + + version 0.6.1: - fix autodetection of E-AC-3 substream samples diff --git a/RELEASE b/RELEASE index a8919cdf56..ddd02e03d1 100644 --- a/RELEASE +++ b/RELEASE @@ -121,3 +121,26 @@ HE-AAC v2 backport This release includes a backport of the AAC decoder from trunk, which enables proper playback of HE-AAC v2 media. + + +* 0.6.2 + +General notes +------------- + +This is a maintenance-only release that addresses a small number of security +and portability issues. Distributors and system integrators are encouraged +to update and share their patches against this branch. + +Security fixes +-------------- + +Programming errors in container and codec implementations may lead to +denial of service or the execution of arbitrary code if the user is +tricked into opening a malformed media file or stream. + +Affected and updated have been the implementations of the following +codecs and container formats: + + - VC1 decoder (Change related to CVE-2011-0723) + - APE decoder (cf. http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt) From 4940d1c0aec9223d92aeead551492c81c18d8c60 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 18 Mar 2011 18:01:41 +0100 Subject: [PATCH 133/301] release notes and changelog for 0.6.2 (cherry picked from commit b0f8fdc411c6380ca9279c8660915f35f5df1a3c) Signed-off-by: Michael Niedermayer --- Changelog | 7 +++++++ RELEASE | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Changelog b/Changelog index 999a9e0f41..2e0a99c378 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,13 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.2: + +- Fix invalid reads in VC-1 decoding (related to CVE-2011-0723) +- Do not attempt to decode APE file with no frames + (adresses http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt) + + version 0.6.1: - fix autodetection of E-AC-3 substream samples diff --git a/RELEASE b/RELEASE index a8919cdf56..ddd02e03d1 100644 --- a/RELEASE +++ b/RELEASE @@ -121,3 +121,26 @@ HE-AAC v2 backport This release includes a backport of the AAC decoder from trunk, which enables proper playback of HE-AAC v2 media. + + +* 0.6.2 + +General notes +------------- + +This is a maintenance-only release that addresses a small number of security +and portability issues. Distributors and system integrators are encouraged +to update and share their patches against this branch. + +Security fixes +-------------- + +Programming errors in container and codec implementations may lead to +denial of service or the execution of arbitrary code if the user is +tricked into opening a malformed media file or stream. + +Affected and updated have been the implementations of the following +codecs and container formats: + + - VC1 decoder (Change related to CVE-2011-0723) + - APE decoder (cf. http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt) From 7fc5bffb542ed8c8bbb98f70e863be8b00326bd0 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 17 Mar 2011 02:54:12 +0100 Subject: [PATCH 134/301] configure: use dlltools instead of lib.exe This way building ffmpeg on mingw won't require windows specific tools (cherry picked from commit ec10a9ab461b26b96eff7bbbb8623f42d8ee04ad) Signed-off-by: Reinhard Tartler --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 3f5176ea39..14f00bce8e 100755 --- a/configure +++ b/configure @@ -2216,7 +2216,7 @@ case $target_os in SLIBSUF=".dll" SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' - SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)' + SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)' SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \ install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \ install -d "$(LIBDIR)"; \ @@ -2224,6 +2224,7 @@ case $target_os in SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"' SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base' objformat="win32" + dlltool="${cross_prefix}dlltool" enable dos_paths check_cflags -fno-common if ! enabled x86_64; then @@ -3002,6 +3003,7 @@ CPPFLAGS=$CPPFLAGS CFLAGS=$CFLAGS ASFLAGS=$ASFLAGS CC_O=$CC_O +DLLTOOL=$dlltool LDFLAGS=$LDFLAGS FFSERVERLDFLAGS=$FFSERVERLDFLAGS SHFLAGS=$SHFLAGS From 79e0cbae33350437c30c65a1e2c2c8b41ef92c62 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 21 Mar 2011 20:22:51 +0100 Subject: [PATCH 135/301] Set the correct target for mingw64 dlltool That fixes .lib creation for the win64 target. (cherry picked from commit 417516f63f8a9ee214ee9fa6fcb483962ea0f096) Signed-off-by: Reinhard Tartler --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 14f00bce8e..a1afb0d0c1 100755 --- a/configure +++ b/configure @@ -2206,7 +2206,7 @@ case $target_os in LIBTARGET=i386 if enabled x86_64; then enable malloc_aligned - LIBTARGET=x64 + LIBTARGET="i386:x86-64" elif enabled arm; then LIBTARGET=arm fi From 52f9b632b57a64ff058018c9b886ce6e918bbda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 21 Mar 2011 22:41:38 +0200 Subject: [PATCH 136/301] configure: Add the -D parameter to the dlltool command This is required for the generated .lib file to actually be usable by MSVC. Signed-off-by: Luca Barbato (cherry picked from commit 77e41e047dc487e318a0a47e02cfa99d25459b8a) Signed-off-by: Reinhard Tartler --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index a1afb0d0c1..eb66ec4c0f 100755 --- a/configure +++ b/configure @@ -2216,7 +2216,7 @@ case $target_os in SLIBSUF=".dll" SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' - SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)' + SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \ install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \ install -d "$(LIBDIR)"; \ From 2b2856bac2012fe505ffd80f441db28c7fc31787 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 22 Mar 2011 20:57:36 +0100 Subject: [PATCH 137/301] Add missing dependencies for the AAC-HE backport for hardcoded tables Unbreaks compilation with --enable-hardcoded-tables --- Changelog | 5 +++++ libavcodec/Makefile | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 2e0a99c378..bcf6428ce9 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,11 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.3: + +- fix compilation with --enable-hardcoded-tables + + version 0.6.2: - Fix invalid reads in VC-1 decoding (related to CVE-2011-0723) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4547ef60ca..3dd24e7e12 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -645,7 +645,9 @@ $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) $(M)./$< > $@ ifdef CONFIG_HARDCODED_TABLES -$(SUBDIR)aac.o: $(SUBDIR)cbrt_tables.h +$(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h +$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h +$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h $(SUBDIR)dv.o: $(SUBDIR)dv_tables.h $(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h $(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h From b4eafa8b04802f45a710e712f2ec2676e0a77024 Mon Sep 17 00:00:00 2001 From: Michael Kostylev Date: Thu, 13 May 2010 10:02:04 +0000 Subject: [PATCH 138/301] Support writing 2d float arrays. Patch by Michael Kostylev, michael D kostylev A gmail Originally committed as revision 23105 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit 56b37cd1c7f3b5e5a3ece043c7ffccf70874cfb1) Unbreaks compilation since the HE-AAC v2 backport Signed-off-by: Reinhard Tartler --- libavcodec/tableprint.c | 1 + libavcodec/tableprint.h | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/tableprint.c b/libavcodec/tableprint.c index e39606bb15..0f422eb888 100644 --- a/libavcodec/tableprint.c +++ b/libavcodec/tableprint.c @@ -33,6 +33,7 @@ WRITE_1D_FUNC(float, float, "%.18e", 3) WRITE_2D_FUNC(int8, int8_t) WRITE_2D_FUNC(uint8, uint8_t) WRITE_2D_FUNC(uint32, uint32_t) +WRITE_2D_FUNC(float, float) void write_fileheader(void) { printf("/* This file was generated by libavcodec/tableprint */\n"); diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index d81af97e95..76ab8028b5 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -66,6 +66,7 @@ void write_float_array (const float *, int); void write_int8_2d_array (const void *, int, int); void write_uint8_2d_array (const void *, int, int); void write_uint32_2d_array(const void *, int, int); +void write_float_2d_array (const void *, int, int); /** \} */ // end of printfuncs group /** Write a standard file header */ From 99d3772ef464b276d50faa2dde6dd14fda40b237 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 24 Mar 2011 02:22:39 +0100 Subject: [PATCH 139/301] Update changelog to match our (late) 0.6.2 release --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index bcf6428ce9..f3dcb97865 100644 --- a/Changelog +++ b/Changelog @@ -3,11 +3,11 @@ releases are sorted from youngest to oldest. version 0.6.3: -- fix compilation with --enable-hardcoded-tables version 0.6.2: +- fix compilation with --enable-hardcoded-tables - Fix invalid reads in VC-1 decoding (related to CVE-2011-0723) - Do not attempt to decode APE file with no frames (adresses http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt) From 9b919571e506fbb72b81a35ca1e7c1bd6efc4209 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 21 Apr 2011 22:04:21 +0200 Subject: [PATCH 140/301] AMV: Fix possibly exploitable crash. Reported-at: Thu, 21 Apr 2011 14:38:25 +0000 Reported-by: Dominic Chell Signed-off-by: Michael Niedermayer (cherry picked from commit 89f903b3d5ec38c9c5d90fba7e626fa0eda61a32) --- libavcodec/sp5xdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 754926a4ce..0899902d5d 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -90,7 +90,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx, recoded[j++] = 0xFF; recoded[j++] = 0xD9; - avctx->flags &= ~CODEC_FLAG_EMU_EDGE; av_init_packet(&avpkt_recoded); avpkt_recoded.data = recoded; avpkt_recoded.size = j; @@ -216,6 +215,6 @@ AVCodec amv_decoder = { NULL, ff_mjpeg_decode_end, sp5x_decode_frame, - CODEC_CAP_DR1, + 0, .long_name = NULL_IF_CONFIG_SMALL("AMV Video"), }; From 553ae88b2eae53336c859e482d15a0b9a4a11ed0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 26 Apr 2011 11:59:25 +0200 Subject: [PATCH 141/301] uodate changelog with AMV fix Signed-off-by: Michael Niedermayer --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index f3dcb97865..4d6b01edfd 100644 --- a/Changelog +++ b/Changelog @@ -2,7 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version 0.6.3: - +- AMV: Fix possibly exploitable crash. version 0.6.2: From 36f3244ec86f27950ef3ca6ac238442c49eaaa75 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 25 Mar 2011 02:24:32 +0100 Subject: [PATCH 142/301] Fix apparently exploitable race condition. Signed-off-by: Michael Niedermayer --- libavutil/log.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/log.c b/libavutil/log.c index 9a8b66ee4d..b08072cd7b 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -59,7 +59,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) { static int print_prefix=1; static int count; - static char line[1024], prev[1024]; + static char prev[1024]; + char line[1024]; static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; AVClass* avc= ptr ? *(AVClass**)ptr : NULL; if(level>av_log_level) From f8969f8ea910e07947cbef2758c0c0fe45b3fcfb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 26 Apr 2011 12:29:34 +0200 Subject: [PATCH 143/301] update changelog Signed-off-by: Michael Niedermayer --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index 4d6b01edfd..491b97a782 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest. version 0.6.3: - AMV: Fix possibly exploitable crash. +- Fix apparently exploitable race condition. version 0.6.2: From ace432f62cdcedf812e7c4d77fc5b03322170fa8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 26 Apr 2011 12:44:19 +0200 Subject: [PATCH 144/301] Update VERSION for 0.6.3 Signed-off-by: Michael Niedermayer --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b616048743..844f6a91ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.2 +0.6.3 From 19166566418e48d13652a6c20468873108cfe955 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 21 Apr 2011 22:03:24 +0200 Subject: [PATCH 145/301] mjpeg: Detect overreads in mjpeg_decode_scan() and error out. Signed-off-by: Michael Niedermayer Signed-off-by: Ronald S. Bultje Signed-off-by: Reinhard Tartler (cherry picked from commit 0d9cba562b88899f0769e686d19b7953f589069b) --- libavcodec/mjpegdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 7f57af905c..9f2f88b5de 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -792,6 +792,10 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i if (s->restart_interval && !s->restart_count) s->restart_count = s->restart_interval; + if(get_bits_count(&s->gb)>s->gb.size_in_bits){ + av_log(s->avctx, AV_LOG_ERROR, "overread %d\n", get_bits_count(&s->gb) - s->gb.size_in_bits); + return -1; + } for(i=0;i Date: Sat, 23 Apr 2011 10:44:21 +0200 Subject: [PATCH 146/301] aac: add headers needed for log2f() Allows compilation of aaccoder.c under cygwin Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler (cherry picked from commit 30fe9719344f01a147628e07a8e79a9ccc7e0835) --- libavcodec/aaccoder.c | 1 + libavcodec/aacsbr.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 0957469957..08c4801821 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -35,6 +35,7 @@ #include "aac.h" #include "aacenc.h" #include "aactab.h" +#include "libavutil/libm.h" /** bits needed to code codebook run value for long windows */ static const uint8_t run_value_bits_long[64] = { diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index ca5c52cce3..cac34bb085 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -32,6 +32,7 @@ #include "aacsbrdata.h" #include "fft.h" #include "aacps.h" +#include "libavutil/libm.h" #include #include From 66ebf37c735158e060c5acf8df62391b8b6182ef Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 30 Apr 2011 08:11:13 +0200 Subject: [PATCH 147/301] Fix races in default av_log handler Prevent competing threads from overwriting (shared) buffers. Original patch by: Michael Niedermayer (cherry picked from commit 0247bdee2581a6857a24c5ff297f01d3a3112b11) --- libavutil/log.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavutil/log.c b/libavutil/log.c index 9a8b66ee4d..9319dcdbe7 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -59,7 +59,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) { static int print_prefix=1; static int count; - static char line[1024], prev[1024]; + static char prev[1024]; + char line[1024]; static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; AVClass* avc= ptr ? *(AVClass**)ptr : NULL; if(level>av_log_level) @@ -73,7 +74,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); print_prefix= line[strlen(line)-1] == '\n'; - if(print_prefix && !strcmp(line, prev)){ + if(print_prefix && !strncmp(line, prev, sizeof line)){ count++; return; } @@ -82,7 +83,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) count=0; } colored_fputs(color[av_clip(level>>3, 0, 6)], line); - strcpy(prev, line); + strncpy(prev, line, sizeof line); } static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; From 9848e1be2d288747b7f39743ed81481780a7ca47 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 30 Apr 2011 08:18:32 +0200 Subject: [PATCH 148/301] lavf: inspect more frames for fps when container time base is coarse As per issue2629, most 23.976fps matroska H.264 files are incorrectly detected as 24fps, as the matroska timestamps usually have only millisecond precision. Fix that by doubling the amount of timestamps inspected for frame rate for streams that have coarse time base. This also fixes 29.970 detection in matroska. Signed-off-by: Michael Niedermayer (cherry picked from commit 78431098f9e306ebe27e7698d0ae539e3df2afe9) Tested with mplayer based on this report http://thread.gmane.org/gmane.comp.video.mplayer.user/66043/focus=66063 Signed-off-by: Reinhard Tartler (cherry picked from commit 7c152a458d3fb0a2fb1aef1f05bfee90fe70697e) --- libavformat/utils.c | 10 +- tests/ref/fate/cscd | 414 ++++++++++++++++++++++---------------------- 2 files changed, 216 insertions(+), 208 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 6224a35d4d..b73d98473f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2205,12 +2205,20 @@ int av_find_stream_info(AVFormatContext *ic) /* check if one codec still needs to be handled */ for(i=0;inb_streams;i++) { + int fps_analyze_framecount = 20; + st = ic->streams[i]; if (!has_codec_parameters(st->codec)) break; + /* if the timebase is coarse (like the usual millisecond precision + of mkv), we need to analyze more frames to reliably arrive at + the correct fps */ + if (av_q2d(st->time_base) > 0.0005) + fps_analyze_framecount *= 2; /* variable fps and no guess at the real fps */ if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num) - && duration_count[i]<20 && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) + && duration_count[i] < fps_analyze_framecount + && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) break; if(st->parser && st->parser->parser->split && !st->codec->extradata) break; diff --git a/tests/ref/fate/cscd b/tests/ref/fate/cscd index 75a7725c18..8b89e80a10 100644 --- a/tests/ref/fate/cscd +++ b/tests/ref/fate/cscd @@ -1,208 +1,208 @@ 0, 0, 270000, 0xf90015d8 -0, 2880, 270000, 0xf90015d8 -0, 5760, 270000, 0xf90015d8 -0, 8640, 270000, 0xf90015d8 -0, 11520, 270000, 0xf90015d8 -0, 14400, 270000, 0xf90015d8 -0, 17280, 270000, 0xf90015d8 -0, 20160, 270000, 0xf90015d8 -0, 23040, 270000, 0xf90015d8 -0, 25920, 270000, 0xf90015d8 -0, 28800, 270000, 0xf90015d8 -0, 31680, 270000, 0xf90015d8 -0, 34560, 270000, 0xf90015d8 -0, 37440, 270000, 0xf90015d8 -0, 40320, 270000, 0xf90015d8 -0, 43200, 270000, 0xf90015d8 -0, 46080, 270000, 0xf90015d8 -0, 48960, 270000, 0xf90015d8 -0, 51840, 270000, 0xf90015d8 -0, 54720, 270000, 0xf90015d8 -0, 57600, 270000, 0xf90015d8 -0, 60480, 270000, 0xf90015d8 -0, 63360, 270000, 0xf90015d8 -0, 66240, 270000, 0xf90015d8 -0, 69120, 270000, 0xf90015d8 -0, 72000, 270000, 0xf90015d8 -0, 74880, 270000, 0xf90015d8 -0, 77760, 270000, 0xf90015d8 -0, 80640, 270000, 0xf90015d8 -0, 83520, 270000, 0xf90015d8 -0, 86400, 270000, 0xf90015d8 -0, 89280, 270000, 0xf90015d8 -0, 92160, 270000, 0xf90015d8 -0, 95040, 270000, 0xf90015d8 -0, 97920, 270000, 0xf90015d8 -0, 100800, 270000, 0xf90015d8 -0, 103680, 270000, 0xf90015d8 -0, 106560, 270000, 0xf90015d8 -0, 109440, 270000, 0xf90015d8 -0, 112320, 270000, 0x1f9c15d8 -0, 115200, 270000, 0x436f15d8 -0, 118080, 270000, 0xe90115d8 -0, 120960, 270000, 0xe90115d8 -0, 123840, 270000, 0x8ea215d8 -0, 126720, 270000, 0x424015d8 -0, 129600, 270000, 0x0ce315d8 -0, 132480, 270000, 0x14bc15d8 -0, 135360, 270000, 0x2a9215d8 -0, 138240, 270000, 0x233f15d8 -0, 141120, 270000, 0x764b15d8 -0, 144000, 270000, 0xf76115d8 -0, 146880, 270000, 0xbbe015d8 -0, 149760, 270000, 0x95af15d8 -0, 152640, 270000, 0x324815d8 -0, 155520, 270000, 0x311915d8 -0, 158400, 270000, 0x090ef191 -0, 161280, 270000, 0xd88974dc -0, 164160, 270000, 0xfa7f58df -0, 167040, 270000, 0x78f849c3 -0, 169920, 270000, 0xae174892 -0, 172800, 270000, 0x9d4e2332 -0, 175680, 270000, 0x874b09b4 -0, 178560, 270000, 0x4069fed6 -0, 181440, 270000, 0x4069fed6 -0, 184320, 270000, 0x4069fed6 -0, 187200, 270000, 0x4069fed6 -0, 190080, 270000, 0x4069fed6 -0, 192960, 270000, 0x4069fed6 -0, 195840, 270000, 0x4069fed6 -0, 198720, 270000, 0x4069fed6 -0, 201600, 270000, 0x4069fed6 -0, 204480, 270000, 0x4069fed6 -0, 207360, 270000, 0x4069fed6 -0, 210240, 270000, 0x773db046 -0, 213120, 270000, 0x773db046 -0, 216000, 270000, 0x773db046 -0, 218880, 270000, 0x773db046 -0, 221760, 270000, 0x773db046 -0, 224640, 270000, 0x773db046 -0, 227520, 270000, 0x773db046 -0, 230400, 270000, 0x773db046 -0, 233280, 270000, 0x773db046 -0, 236160, 270000, 0x773db046 -0, 239040, 270000, 0x773db046 -0, 241920, 270000, 0x773db046 -0, 244800, 270000, 0x773db046 -0, 247680, 270000, 0x773db046 -0, 250560, 270000, 0x773db046 -0, 253440, 270000, 0x773db046 -0, 256320, 270000, 0x773db046 -0, 259200, 270000, 0x17b9aec9 -0, 262080, 270000, 0x622fad4c -0, 264960, 270000, 0xdaea3aef -0, 267840, 270000, 0x61bb10e3 -0, 270720, 270000, 0xfc37ee0c -0, 273600, 270000, 0x50dbd01e -0, 276480, 270000, 0xcd66c27c -0, 279360, 270000, 0xd13f1e4f -0, 282240, 270000, 0xa4a2dbf5 -0, 285120, 270000, 0xf302c9ab -0, 288000, 270000, 0x4479f7fe -0, 290880, 270000, 0x1afe92c8 -0, 293760, 270000, 0x3007f4c3 -0, 296640, 270000, 0x5834c096 -0, 299520, 270000, 0x40109126 -0, 302400, 270000, 0x0a7b8882 -0, 305280, 270000, 0x15b8635d -0, 308160, 270000, 0xeaa5598e -0, 311040, 270000, 0x0b7b5489 -0, 313920, 270000, 0x0b7b5489 -0, 316800, 270000, 0x0b7b5489 -0, 319680, 270000, 0x0b7b5489 -0, 322560, 270000, 0x8f0e6eaa -0, 325440, 270000, 0xc46fc0f2 -0, 328320, 270000, 0xadd7e605 -0, 331200, 270000, 0x9d23a056 -0, 334080, 270000, 0x365afa63 -0, 336960, 270000, 0x6ac3bda2 -0, 339840, 270000, 0x14f5daf2 -0, 342720, 270000, 0x4b3afb6a -0, 345600, 270000, 0x1a3302e3 -0, 348480, 270000, 0x1a3302e3 -0, 351360, 270000, 0x1a3302e3 -0, 354240, 270000, 0x1a3302e3 -0, 357120, 270000, 0xc15526e2 -0, 360000, 270000, 0x3dd73006 -0, 362880, 270000, 0x60abb5bc -0, 365760, 270000, 0xb960c27c -0, 368640, 270000, 0x8fa4c01c -0, 371520, 270000, 0x8fa4c01c -0, 374400, 270000, 0x8fa4c01c -0, 377280, 270000, 0xb20dcc38 -0, 380160, 270000, 0x03c6ad3c -0, 383040, 270000, 0xe550b194 -0, 385920, 270000, 0xe550b194 -0, 388800, 270000, 0xe550b194 -0, 391680, 270000, 0xe550b194 -0, 394560, 270000, 0xe550b194 -0, 397440, 270000, 0xe550b194 -0, 400320, 270000, 0xe550b194 -0, 403200, 270000, 0xe550b194 -0, 406080, 270000, 0xe550b194 -0, 408960, 270000, 0xe550b194 -0, 411840, 270000, 0xe550b194 -0, 414720, 270000, 0xe550b194 -0, 417600, 270000, 0xe550b194 -0, 420480, 270000, 0xe550b194 -0, 423360, 270000, 0x4550a014 -0, 426240, 270000, 0xaf639da8 -0, 429120, 270000, 0xe4229da8 -0, 432000, 270000, 0x315d9da8 -0, 434880, 270000, 0x7e899da8 -0, 437760, 270000, 0x99b9a8a0 -0, 440640, 270000, 0x4588ac2a -0, 443520, 270000, 0x1e79ae6e -0, 446400, 270000, 0xa003cb14 -0, 449280, 270000, 0x03ef1bb8 -0, 452160, 270000, 0x3b3f30fc -0, 455040, 270000, 0x4dad3525 -0, 457920, 270000, 0x5b600c12 -0, 460800, 270000, 0x75a1fab3 -0, 463680, 270000, 0xc9f7d9ad -0, 466560, 270000, 0x9eaec58d -0, 469440, 270000, 0xb91bc3e8 -0, 472320, 270000, 0x77bdbbfb -0, 475200, 270000, 0x77bdbbfb -0, 478080, 270000, 0x77bdbbfb -0, 480960, 270000, 0x77bdbbfb -0, 483840, 270000, 0x77bdbbfb -0, 486720, 270000, 0x77bdbbfb -0, 489600, 270000, 0x3d54eac2 -0, 492480, 270000, 0x3d54eac2 -0, 495360, 270000, 0x3d54eac2 -0, 498240, 270000, 0x3d54eac2 -0, 501120, 270000, 0x3d54eac2 -0, 504000, 270000, 0x3d54eac2 -0, 506880, 270000, 0x3d54eac2 -0, 509760, 270000, 0x3d54eac2 -0, 512640, 270000, 0x3d54eac2 -0, 515520, 270000, 0x3d54eac2 -0, 518400, 270000, 0x3d54eac2 -0, 521280, 270000, 0x3d54eac2 -0, 524160, 270000, 0x3d54eac2 -0, 527040, 270000, 0x3d54eac2 -0, 529920, 270000, 0x3d54eac2 -0, 532800, 270000, 0x3d54eac2 -0, 535680, 270000, 0x3d54eac2 -0, 538560, 270000, 0x3d54eac2 -0, 541440, 270000, 0x3d54eac2 -0, 544320, 270000, 0x5f3609ba -0, 547200, 270000, 0x80921b0c -0, 550080, 270000, 0x80921b0c -0, 552960, 270000, 0x80921b0c -0, 555840, 270000, 0x80921b0c -0, 558720, 270000, 0x80921b0c -0, 561600, 270000, 0x80921b0c -0, 564480, 270000, 0x80921b0c -0, 567360, 270000, 0x80921b0c -0, 570240, 270000, 0x80921b0c -0, 573120, 270000, 0x80921b0c -0, 576000, 270000, 0x80921b0c -0, 578880, 270000, 0x80921b0c -0, 581760, 270000, 0x80921b0c -0, 584640, 270000, 0x80921b0c -0, 587520, 270000, 0x80921b0c -0, 590400, 270000, 0x80921b0c -0, 593280, 270000, 0xf0e626a8 -0, 596160, 270000, 0xf0e626a8 +0, 2865, 270000, 0xf90015d8 +0, 5729, 270000, 0xf90015d8 +0, 8594, 270000, 0xf90015d8 +0, 11459, 270000, 0xf90015d8 +0, 14324, 270000, 0xf90015d8 +0, 17188, 270000, 0xf90015d8 +0, 20053, 270000, 0xf90015d8 +0, 22918, 270000, 0xf90015d8 +0, 25782, 270000, 0xf90015d8 +0, 28647, 270000, 0xf90015d8 +0, 31512, 270000, 0xf90015d8 +0, 34377, 270000, 0xf90015d8 +0, 37241, 270000, 0xf90015d8 +0, 40106, 270000, 0xf90015d8 +0, 42971, 270000, 0xf90015d8 +0, 45836, 270000, 0xf90015d8 +0, 48700, 270000, 0xf90015d8 +0, 51565, 270000, 0xf90015d8 +0, 54430, 270000, 0xf90015d8 +0, 57294, 270000, 0xf90015d8 +0, 60159, 270000, 0xf90015d8 +0, 63024, 270000, 0xf90015d8 +0, 65889, 270000, 0xf90015d8 +0, 68753, 270000, 0xf90015d8 +0, 71618, 270000, 0xf90015d8 +0, 74483, 270000, 0xf90015d8 +0, 77347, 270000, 0xf90015d8 +0, 80212, 270000, 0xf90015d8 +0, 83077, 270000, 0xf90015d8 +0, 85942, 270000, 0xf90015d8 +0, 88806, 270000, 0xf90015d8 +0, 91671, 270000, 0xf90015d8 +0, 94536, 270000, 0xf90015d8 +0, 97401, 270000, 0xf90015d8 +0, 100265, 270000, 0xf90015d8 +0, 103130, 270000, 0xf90015d8 +0, 105995, 270000, 0xf90015d8 +0, 108859, 270000, 0xf90015d8 +0, 111724, 270000, 0x1f9c15d8 +0, 114589, 270000, 0x436f15d8 +0, 117454, 270000, 0xe90115d8 +0, 120318, 270000, 0xe90115d8 +0, 123183, 270000, 0x8ea215d8 +0, 126048, 270000, 0x424015d8 +0, 128912, 270000, 0x0ce315d8 +0, 131777, 270000, 0x14bc15d8 +0, 134642, 270000, 0x2a9215d8 +0, 137507, 270000, 0x233f15d8 +0, 140371, 270000, 0x764b15d8 +0, 143236, 270000, 0xf76115d8 +0, 146101, 270000, 0xbbe015d8 +0, 148966, 270000, 0x95af15d8 +0, 151830, 270000, 0x324815d8 +0, 154695, 270000, 0x311915d8 +0, 157560, 270000, 0x090ef191 +0, 160424, 270000, 0xd88974dc +0, 163289, 270000, 0xfa7f58df +0, 166154, 270000, 0x78f849c3 +0, 169019, 270000, 0xae174892 +0, 171883, 270000, 0x9d4e2332 +0, 174748, 270000, 0x874b09b4 +0, 177613, 270000, 0x4069fed6 +0, 180477, 270000, 0x4069fed6 +0, 183342, 270000, 0x4069fed6 +0, 186207, 270000, 0x4069fed6 +0, 189072, 270000, 0x4069fed6 +0, 191936, 270000, 0x4069fed6 +0, 194801, 270000, 0x4069fed6 +0, 197666, 270000, 0x4069fed6 +0, 200531, 270000, 0x4069fed6 +0, 203395, 270000, 0x4069fed6 +0, 206260, 270000, 0x4069fed6 +0, 209125, 270000, 0x773db046 +0, 211989, 270000, 0x773db046 +0, 214854, 270000, 0x773db046 +0, 217719, 270000, 0x773db046 +0, 220584, 270000, 0x773db046 +0, 223448, 270000, 0x773db046 +0, 226313, 270000, 0x773db046 +0, 229178, 270000, 0x773db046 +0, 232042, 270000, 0x773db046 +0, 234907, 270000, 0x773db046 +0, 237772, 270000, 0x773db046 +0, 240637, 270000, 0x773db046 +0, 243501, 270000, 0x773db046 +0, 246366, 270000, 0x773db046 +0, 249231, 270000, 0x773db046 +0, 252095, 270000, 0x773db046 +0, 254960, 270000, 0x773db046 +0, 257825, 270000, 0x17b9aec9 +0, 260690, 270000, 0x622fad4c +0, 263554, 270000, 0xdaea3aef +0, 266419, 270000, 0x61bb10e3 +0, 269284, 270000, 0xfc37ee0c +0, 272149, 270000, 0x50dbd01e +0, 275013, 270000, 0xcd66c27c +0, 277878, 270000, 0xd13f1e4f +0, 280743, 270000, 0xa4a2dbf5 +0, 283607, 270000, 0xf302c9ab +0, 286472, 270000, 0x4479f7fe +0, 289337, 270000, 0x1afe92c8 +0, 292202, 270000, 0x3007f4c3 +0, 295066, 270000, 0x5834c096 +0, 297931, 270000, 0x40109126 +0, 300796, 270000, 0x0a7b8882 +0, 303660, 270000, 0x15b8635d +0, 306525, 270000, 0xeaa5598e +0, 309390, 270000, 0x0b7b5489 +0, 312255, 270000, 0x0b7b5489 +0, 315119, 270000, 0x0b7b5489 +0, 317984, 270000, 0x0b7b5489 +0, 320849, 270000, 0x8f0e6eaa +0, 323714, 270000, 0xc46fc0f2 +0, 326578, 270000, 0xadd7e605 +0, 329443, 270000, 0x9d23a056 +0, 332308, 270000, 0x365afa63 +0, 335172, 270000, 0x6ac3bda2 +0, 338037, 270000, 0x14f5daf2 +0, 340902, 270000, 0x4b3afb6a +0, 343767, 270000, 0x1a3302e3 +0, 346631, 270000, 0x1a3302e3 +0, 349496, 270000, 0x1a3302e3 +0, 352361, 270000, 0x1a3302e3 +0, 355225, 270000, 0xc15526e2 +0, 358090, 270000, 0x3dd73006 +0, 360955, 270000, 0x60abb5bc +0, 363820, 270000, 0xb960c27c +0, 366684, 270000, 0x8fa4c01c +0, 369549, 270000, 0x8fa4c01c +0, 372414, 270000, 0x8fa4c01c +0, 375279, 270000, 0xb20dcc38 +0, 378143, 270000, 0x03c6ad3c +0, 381008, 270000, 0xe550b194 +0, 383873, 270000, 0xe550b194 +0, 386737, 270000, 0xe550b194 +0, 389602, 270000, 0xe550b194 +0, 392467, 270000, 0xe550b194 +0, 395332, 270000, 0xe550b194 +0, 398196, 270000, 0xe550b194 +0, 401061, 270000, 0xe550b194 +0, 403926, 270000, 0xe550b194 +0, 406790, 270000, 0xe550b194 +0, 409655, 270000, 0xe550b194 +0, 412520, 270000, 0xe550b194 +0, 415385, 270000, 0xe550b194 +0, 418249, 270000, 0xe550b194 +0, 421114, 270000, 0x4550a014 +0, 423979, 270000, 0xaf639da8 +0, 426844, 270000, 0xe4229da8 +0, 429708, 270000, 0x315d9da8 +0, 432573, 270000, 0x7e899da8 +0, 435438, 270000, 0x99b9a8a0 +0, 438302, 270000, 0x4588ac2a +0, 441167, 270000, 0x1e79ae6e +0, 444032, 270000, 0xa003cb14 +0, 446897, 270000, 0x03ef1bb8 +0, 449761, 270000, 0x3b3f30fc +0, 452626, 270000, 0x4dad3525 +0, 455491, 270000, 0x5b600c12 +0, 458355, 270000, 0x75a1fab3 +0, 461220, 270000, 0xc9f7d9ad +0, 464085, 270000, 0x9eaec58d +0, 466950, 270000, 0xb91bc3e8 +0, 469814, 270000, 0x77bdbbfb +0, 472679, 270000, 0x77bdbbfb +0, 475544, 270000, 0x77bdbbfb +0, 478408, 270000, 0x77bdbbfb +0, 481273, 270000, 0x77bdbbfb +0, 484138, 270000, 0x77bdbbfb +0, 487003, 270000, 0x3d54eac2 +0, 489867, 270000, 0x3d54eac2 +0, 492732, 270000, 0x3d54eac2 +0, 495597, 270000, 0x3d54eac2 +0, 498462, 270000, 0x3d54eac2 +0, 501326, 270000, 0x3d54eac2 +0, 504191, 270000, 0x3d54eac2 +0, 507056, 270000, 0x3d54eac2 +0, 509920, 270000, 0x3d54eac2 +0, 512785, 270000, 0x3d54eac2 +0, 515650, 270000, 0x3d54eac2 +0, 518515, 270000, 0x3d54eac2 +0, 521379, 270000, 0x3d54eac2 +0, 524244, 270000, 0x3d54eac2 +0, 527109, 270000, 0x3d54eac2 +0, 529973, 270000, 0x3d54eac2 +0, 532838, 270000, 0x3d54eac2 +0, 535703, 270000, 0x3d54eac2 +0, 538568, 270000, 0x3d54eac2 +0, 541432, 270000, 0x5f3609ba +0, 544297, 270000, 0x80921b0c +0, 547162, 270000, 0x80921b0c +0, 550027, 270000, 0x80921b0c +0, 552891, 270000, 0x80921b0c +0, 555756, 270000, 0x80921b0c +0, 558621, 270000, 0x80921b0c +0, 561485, 270000, 0x80921b0c +0, 564350, 270000, 0x80921b0c +0, 567215, 270000, 0x80921b0c +0, 570080, 270000, 0x80921b0c +0, 572944, 270000, 0x80921b0c +0, 575809, 270000, 0x80921b0c +0, 578674, 270000, 0x80921b0c +0, 581538, 270000, 0x80921b0c +0, 584403, 270000, 0x80921b0c +0, 587268, 270000, 0x80921b0c +0, 590133, 270000, 0xf0e626a8 +0, 592997, 270000, 0xf0e626a8 From 8539ea3265010c7b79cf52519da6e068847875f9 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 28 Apr 2011 21:10:04 +0200 Subject: [PATCH 149/301] AMV: disable DR1 and don't override EMU_EDGE This works around a possibly exploitable crash. Appearently, vlc can be exploited with a malicous file. This should get reverted as soon as a proper fix is found. Reported-at: Thu, 21 Apr 2011 14:38:25 +0000 Reported-by: Dominic Chell Signed-off-by: Michael Niedermayer (cherry picked from commit 89f903b3d5ec38c9c5d90fba7e626fa0eda61a32) (cherry picked from commit 9b919571e506fbb72b81a35ca1e7c1bd6efc4209) (cherry picked from commit 7089265756a84bf884a7c2290c6cda38d4dfd60f) Signed-off-by: Reinhard Tartler --- libavcodec/sp5xdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 754926a4ce..0899902d5d 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -90,7 +90,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx, recoded[j++] = 0xFF; recoded[j++] = 0xD9; - avctx->flags &= ~CODEC_FLAG_EMU_EDGE; av_init_packet(&avpkt_recoded); avpkt_recoded.data = recoded; avpkt_recoded.size = j; @@ -216,6 +215,6 @@ AVCodec amv_decoder = { NULL, ff_mjpeg_decode_end, sp5x_decode_frame, - CODEC_CAP_DR1, + 0, .long_name = NULL_IF_CONFIG_SMALL("AMV Video"), }; From b5c3b18bfc8a7439dde535ade1cb090000ed06ea Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 30 Apr 2011 08:44:07 +0200 Subject: [PATCH 150/301] update Changelog --- Changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Changelog b/Changelog index bcf6428ce9..b6e6aa2307 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,12 @@ releases are sorted from youngest to oldest. version 0.6.3: - fix compilation with --enable-hardcoded-tables +- mjpeg: Detect overreads in mjpeg_decode_scan() and error out. +- aac: add headers needed for log2f() +- Fix races in default av_log handler (possibly exploitable) +- lavf: inspect more frames for fps when container time base is coarse +- AMV: disable DR1 and don't override EMU_EDGE + (addresses http://seclists.org/bugtraq/2011/Apr/257) version 0.6.2: From f5d14a92cb6aebd0bac3599847d6302842115e3f Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 30 Apr 2011 09:00:46 +0200 Subject: [PATCH 151/301] Release notes for 0.6.3 --- RELEASE | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RELEASE b/RELEASE index ddd02e03d1..5dbdf03b08 100644 --- a/RELEASE +++ b/RELEASE @@ -144,3 +144,16 @@ codecs and container formats: - VC1 decoder (Change related to CVE-2011-0723) - APE decoder (cf. http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt) + + +* 0.6.3 + +General notes +------------- + +This is another maintenance-only release that addresses a small number +of bugs such as security and compilation issues. Distributors and system +integrators are encouraged to update and share their patches against +this branch. + +For a full list of changes please see the Changelog file. From 39c8434bced9a860388628e624170665ddff0e44 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 2 May 2011 03:22:11 +0200 Subject: [PATCH 152/301] Update VERSION for 0.6.4 Signed-off-by: Michael Niedermayer --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 844f6a91ac..d2b13eb644 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.3 +0.6.4 From 2ad6e144573f5ac2c8d4d0e9a2772a1bb45487cb Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 13 May 2011 12:43:40 +0200 Subject: [PATCH 153/301] backport libvo-aacenc wrapper for aac encoding --- Changelog | 1 + configure | 6 ++ doc/general.texi | 2 +- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libvo-aacenc.c | 128 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libvo-aacenc.c diff --git a/Changelog b/Changelog index b6e6aa2307..765a7102a4 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,7 @@ version 0.6.3: - lavf: inspect more frames for fps when container time base is coarse - AMV: disable DR1 and don't override EMU_EDGE (addresses http://seclists.org/bugtraq/2011/Apr/257) +- AAC encoding via libvo-aacenc version 0.6.2: diff --git a/configure b/configure index eb66ec4c0f..b3e2fe1489 100755 --- a/configure +++ b/configure @@ -181,6 +181,7 @@ External library support: --enable-libschroedinger enable Dirac support via libschroedinger [no] --enable-libspeex enable Speex decoding via libspeex [no] --enable-libtheora enable Theora encoding via libtheora [no] + --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no] --enable-libvorbis enable Vorbis encoding via libvorbis, native implementation exists [no] --enable-libvpx enable VP8 support via libvpx [no] @@ -929,6 +930,7 @@ CONFIG_LIST=" libschroedinger libspeex libtheora + libvo_aacenc libvorbis libvpx libx264 @@ -1357,6 +1359,7 @@ libschroedinger_decoder_deps="libschroedinger" libschroedinger_encoder_deps="libschroedinger" libspeex_decoder_deps="libspeex" libtheora_encoder_deps="libtheora" +libvo_aacenc_encoder_deps="libvo_aacenc" libvorbis_encoder_deps="libvorbis" libvpx_decoder_deps="libvpx" libvpx_encoder_deps="libvpx" @@ -2347,6 +2350,7 @@ die_license_disabled nonfree libfaac die_license_disabled version3 libopencore_amrnb die_license_disabled version3 libopencore_amrwb +die_license_disabled version3 libvo_aacenc enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; } @@ -2623,6 +2627,7 @@ enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0) enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg +enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg enabled libvpx && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx && require2 libvpx "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver" -lvpx @@ -2903,6 +2908,7 @@ echo "librtmp enabled ${librtmp-no}" echo "libschroedinger enabled ${libschroedinger-no}" echo "libspeex enabled ${libspeex-no}" echo "libtheora enabled ${libtheora-no}" +echo "libvo-aacenc support ${libvo_aacenc-no}" echo "libvorbis enabled ${libvorbis-no}" echo "libvpx enabled ${libvpx-no}" echo "libx264 enabled ${libx264-no}" diff --git a/doc/general.texi b/doc/general.texi index dfa5b07e18..843d4f681c 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -511,7 +511,7 @@ following image formats are supported: @item Name @tab Encoding @tab Decoding @tab Comments @item 8SVX audio @tab @tab X @item AAC @tab E @tab X - @tab encoding supported through external library libfaac + @tab encoding supported through external library libfaac and libvo-aacenc @item AC-3 @tab IX @tab X @item ADPCM 4X Movie @tab @tab X @item ADPCM CDROM XA @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3dd24e7e12..4afce9a243 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -527,6 +527,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o +OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index aa3001c546..245a77be78 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -343,6 +343,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (LIBSCHROEDINGER, libschroedinger); REGISTER_DECODER (LIBSPEEX, libspeex); REGISTER_ENCODER (LIBTHEORA, libtheora); + REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc); REGISTER_ENCODER (LIBVORBIS, libvorbis); REGISTER_ENCDEC (LIBVPX, libvpx); REGISTER_ENCODER (LIBX264, libx264); diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c new file mode 100644 index 0000000000..65c2745695 --- /dev/null +++ b/libavcodec/libvo-aacenc.c @@ -0,0 +1,128 @@ +/* + * AAC encoder wrapper + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "avcodec.h" +#include "mpeg4audio.h" + +typedef struct AACContext { + VO_AUDIO_CODECAPI codec_api; + VO_HANDLE handle; + VO_MEM_OPERATOR mem_operator; + VO_CODEC_INIT_USERDATA user_data; +} AACContext; + +static av_cold int aac_encode_init(AVCodecContext *avctx) +{ + AACContext *s = avctx->priv_data; + AACENC_PARAM params = { 0 }; + int index; + + avctx->coded_frame = avcodec_alloc_frame(); + avctx->frame_size = 1024; + + voGetAACEncAPI(&s->codec_api); + + s->mem_operator.Alloc = cmnMemAlloc; + s->mem_operator.Copy = cmnMemCopy; + s->mem_operator.Free = cmnMemFree; + s->mem_operator.Set = cmnMemSet; + s->mem_operator.Check = cmnMemCheck; + s->user_data.memflag = VO_IMF_USERMEMOPERATOR; + s->user_data.memData = &s->mem_operator; + s->codec_api.Init(&s->handle, VO_AUDIO_CodingAAC, &s->user_data); + + params.sampleRate = avctx->sample_rate; + params.bitRate = avctx->bit_rate; + params.nChannels = avctx->channels; + params.adtsUsed = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); + if (s->codec_api.SetParam(s->handle, VO_PID_AAC_ENCPARAM, ¶ms) + != VO_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Unable to set encoding parameters\n"); + return AVERROR_UNKNOWN; + } + + avctx->extradata_size = 2; + avctx->extradata = av_mallocz(avctx->extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + + for (index = 0; index < 16; index++) + if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) + break; + if (index == 16) { + av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", + avctx->sample_rate); + return AVERROR_NOTSUPP; + } + avctx->extradata[0] = 0x02 << 3 | index >> 1; + avctx->extradata[1] = (index & 0x01) << 7 | avctx->channels << 3; + return 0; +} + +static int aac_encode_close(AVCodecContext *avctx) +{ + AACContext *s = avctx->priv_data; + + s->codec_api.Uninit(s->handle); + av_freep(&avctx->coded_frame); + + return 0; +} + +static int aac_encode_frame(AVCodecContext *avctx, + unsigned char *frame/*out*/, + int buf_size, void *data/*in*/) +{ + AACContext *s = avctx->priv_data; + VO_CODECBUFFER input = { 0 }, output = { 0 }; + VO_AUDIO_OUTPUTINFO output_info = { { 0 } }; + + input.Buffer = data; + input.Length = 2 * avctx->channels * avctx->frame_size; + output.Buffer = frame; + output.Length = buf_size; + + s->codec_api.SetInputData(s->handle, &input); + if (s->codec_api.GetOutputData(s->handle, &output, &output_info) + != VO_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Unable to encode frame\n"); + return AVERROR_UNKNOWN; + } + return output.Length; +} + +AVCodec ff_libvo_aacenc_encoder = { + "libvo_aacenc", + CODEC_TYPE_AUDIO, + CODEC_ID_AAC, + sizeof(AACContext), + aac_encode_init, + aac_encode_frame, + aac_encode_close, + NULL, + .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("libvo-aacenc AAC"), +}; + From 03ef9828b551fa9e91898d0f3c156d7c3fa11c92 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 25 Jul 2011 09:38:48 +0200 Subject: [PATCH 154/301] Fix ff_imdct_calc_sse() on gcc-4.6 Gcc 4.6 only preserves the first value when using an array with an "m" constraint. Signed-off-by: Mans Rullgard (cherry picked from commit 770c410fbb8e1b87ce8ad7f3d7eddaa55e2b8295) References: http://bugs.debian.org/635324 Conflicts: libavcodec/x86/fft_sse.c --- libavcodec/x86/fft_sse.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/fft_sse.c b/libavcodec/x86/fft_sse.c index a4cce69db1..eaca44a34f 100644 --- a/libavcodec/x86/fft_sse.c +++ b/libavcodec/x86/fft_sse.c @@ -23,7 +23,7 @@ #include "libavcodec/dsputil.h" #include "fft.h" -DECLARE_ALIGNED(16, static const int, m1m1m1m1)[4] = +DECLARE_ASM_CONST(16, int, ff_m1m1m1m1)[4] = { 1 << 31, 1 << 31, 1 << 31, 1 << 31 }; void ff_fft_dispatch_sse(FFTComplex *z, int nbits); @@ -183,7 +183,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input) j = -n; k = n-16; __asm__ volatile( - "movaps %4, %%xmm7 \n" + "movaps "MANGLE(ff_m1m1m1m1)", %%xmm7 \n" "1: \n" "movaps (%2,%1), %%xmm0 \n" "movaps (%3,%0), %%xmm1 \n" @@ -196,8 +196,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input) "add $16, %0 \n" "jl 1b \n" :"+r"(j), "+r"(k) - :"r"(output+n4), "r"(output+n4*3), - "m"(*m1m1m1m1) + :"r"(output+n4), "r"(output+n4*3) ); } From 88ea7ca6279720de9c8db0a4c9a2928e6c7f6061 Mon Sep 17 00:00:00 2001 From: Chris Evans Date: Thu, 4 Aug 2011 22:00:29 +0200 Subject: [PATCH 155/301] oggdec: prevent heap corruption. Specifically crafted samples can reinit ogg->streams[] while reading samples, and thus we should not cache old pointers since these may no longer be valid. Signed-off-by: Ronald S. Bultje (cherry-picked from commit 4cc3467e7abfea7e8d03b6af511f7719038a5a98) --- libavformat/oggdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 3161e68c6c..76b28ab212 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -577,20 +577,19 @@ ogg_read_close (AVFormatContext * s) } -static int64_t -ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg, - int64_t pos_limit) +static int64_t ogg_read_timestamp (AVFormatContext * s, int stream_index, + int64_t * pos_arg, int64_t pos_limit) { struct ogg *ogg = s->priv_data; - struct ogg_stream *os = ogg->streams + stream_index; ByteIOContext *bc = s->pb; int64_t pts = AV_NOPTS_VALUE; - int i; + int i = -1; url_fseek(bc, *pos_arg, SEEK_SET); ogg_reset(ogg); while (url_ftell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) { if (i == stream_index) { + struct ogg_stream *os = ogg->streams + stream_index; pts = ogg_calc_pts(s, i, NULL); if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY)) pts = AV_NOPTS_VALUE; @@ -615,6 +614,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp os->keyframe_seek = 1; ret = av_seek_frame_binary(s, stream_index, timestamp, flags); + os = ogg->streams + stream_index; if (ret < 0) os->keyframe_seek = 0; return ret; From fe4a355805ea465737aea79956983ba5276b0be1 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 13 Feb 2011 00:19:06 +0000 Subject: [PATCH 156/301] Fix MMX rgb24 to yuv conversion with gcc 4.6 When built with gcc 4.6, the MMX rgb24 to yuv conversion gives wrong output. The compiler produces this warning: libswscale/swscale_template.c:1885:5: warning: use of memory input without lvalue in asm operand 4 is deprecated Changing the memory operand to a register makes it work. Signed-off-by: Mans Rullgard (cherry picked from commit f344903ca5ce28a833fdd656bc1ed5b16d97e7e9) Signed-off-by: Reinhard Tartler --- libswscale/swscale_template.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 0d259ed1a0..b1a28b5bc3 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -1882,7 +1882,7 @@ static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, long w static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, long width, enum PixelFormat srcFormat) { __asm__ volatile( - "movq 24+%4, %%mm6 \n\t" + "movq 24(%4), %%mm6 \n\t" "mov %3, %%"REG_a" \n\t" "pxor %%mm7, %%mm7 \n\t" "1: \n\t" @@ -1893,9 +1893,9 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uin "punpcklbw %%mm7, %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" - "pmaddwd %4, %%mm0 \n\t" - "pmaddwd 8+%4, %%mm1 \n\t" - "pmaddwd 16+%4, %%mm2 \n\t" + "pmaddwd (%4), %%mm0 \n\t" + "pmaddwd 8(%4), %%mm1 \n\t" + "pmaddwd 16(%4), %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" "paddd %%mm1, %%mm0 \n\t" "paddd %%mm3, %%mm2 \n\t" @@ -1907,9 +1907,9 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uin "punpcklbw %%mm7, %%mm3 \n\t" "movq %%mm1, %%mm4 \n\t" "movq %%mm3, %%mm5 \n\t" - "pmaddwd %4, %%mm1 \n\t" - "pmaddwd 8+%4, %%mm3 \n\t" - "pmaddwd 16+%4, %%mm4 \n\t" + "pmaddwd (%4), %%mm1 \n\t" + "pmaddwd 8(%4), %%mm3 \n\t" + "pmaddwd 16(%4), %%mm4 \n\t" "pmaddwd %%mm6, %%mm5 \n\t" "paddd %%mm3, %%mm1 \n\t" "paddd %%mm5, %%mm4 \n\t" @@ -1932,7 +1932,7 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uin "add $4, %%"REG_a" \n\t" " js 1b \n\t" : "+r" (src) - : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "m"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24][0]) + : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "r"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24]) : "%"REG_a ); } From 9f95d7aab3ced729f3e931ef11006881e0735738 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 5 Nov 2011 12:19:43 +0100 Subject: [PATCH 157/301] libvo-aacenc: Sync up with 0.7.2 This version was checked out from the 0.7.2 release and has some bits reverted to compile in the release/0.6 branch Signed-off-by: Reinhard Tartler --- libavcodec/libvo-aacenc.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index 65c2745695..da4a7bf07d 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -59,25 +59,27 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) if (s->codec_api.SetParam(s->handle, VO_PID_AAC_ENCPARAM, ¶ms) != VO_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Unable to set encoding parameters\n"); - return AVERROR_UNKNOWN; + return AVERROR(EINVAL); } - avctx->extradata_size = 2; - avctx->extradata = av_mallocz(avctx->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) - return AVERROR(ENOMEM); - for (index = 0; index < 16; index++) if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) break; if (index == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); - return AVERROR_NOTSUPP; + return AVERROR(ENOSYS); + } + if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + avctx->extradata_size = 2; + avctx->extradata = av_mallocz(avctx->extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + + avctx->extradata[0] = 0x02 << 3 | index >> 1; + avctx->extradata[1] = (index & 0x01) << 7 | avctx->channels << 3; } - avctx->extradata[0] = 0x02 << 3 | index >> 1; - avctx->extradata[1] = (index & 0x01) << 7 | avctx->channels << 3; return 0; } @@ -108,12 +110,12 @@ static int aac_encode_frame(AVCodecContext *avctx, if (s->codec_api.GetOutputData(s->handle, &output, &output_info) != VO_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Unable to encode frame\n"); - return AVERROR_UNKNOWN; + return AVERROR(EINVAL); } return output.Length; } -AVCodec ff_libvo_aacenc_encoder = { +AVCodec libvo_aacenc_encoder = { "libvo_aacenc", CODEC_TYPE_AUDIO, CODEC_ID_AAC, @@ -122,7 +124,7 @@ AVCodec ff_libvo_aacenc_encoder = { aac_encode_frame, aac_encode_close, NULL, - .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("libvo-aacenc AAC"), + .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Android VisualOn AAC"), }; From 7a6bba627d643ba9e9cc083f21475a0035b0f06f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 10 Aug 2011 18:52:11 +0100 Subject: [PATCH 158/301] cavs: fix some crashes with invalid bitstreams This removes all valgrind-reported invalid writes with one specific test file. Fixes http://www.ocert.org/advisories/ocert-2011-002.html Signed-off-by: Mans Rullgard (cherry picked from commit 4a71da0f3ab7f5542decd11c81994f849d5b2c78) Fixes CVE-2011-3362, CVE-2011-3973, CVE-2011-3974 Signed-off-by: Reinhard Tartler --- libavcodec/cavsdec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 9d6307c217..626f33a4a2 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -130,12 +130,14 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb, r++; mask = -(level_code & 1); level = (level^mask) - mask; - } else { + } else if (level_code >= 0) { level = r->rltab[level_code][0]; if(!level) //end of block signal break; run = r->rltab[level_code][1]; r += r->rltab[level_code][2]; + } else { + break; } level_buf[i] = level; run_buf[i] = run; @@ -189,7 +191,8 @@ static inline int decode_residual_inter(AVSContext *h) { static int decode_mb_i(AVSContext *h, int cbp_code) { GetBitContext *gb = &h->s.gb; - int block, pred_mode_uv; + unsigned pred_mode_uv; + int block; uint8_t top[18]; uint8_t *left = NULL; uint8_t *d; @@ -445,6 +448,8 @@ static inline int check_for_slice(AVSContext *h) { if((show_bits_long(gb,24+align) & 0xFFFFFF) == 0x000001) { skip_bits_long(gb,24+align); h->stc = get_bits(gb,8); + if (h->stc >= h->mb_height) + return 0; decode_slice_header(h,gb); return 1; } @@ -659,7 +664,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, buf_end = buf + buf_size; for(;;) { buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc); - if(stc & 0xFFFFFE00) + if((stc & 0xFFFFFE00) || buf_ptr == buf_end) return FFMAX(0, buf_ptr - buf - s->parse_context.last_index); input_size = (buf_end - buf_ptr)*8; switch(stc) { From 222d18ab20f4209eec7ee52b11034cca2f67cc89 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 28 Jul 2011 14:59:54 +0200 Subject: [PATCH 159/301] Fix memory (re)allocation in matroskadec.c, related to MSVR-11-0080. Whitespace of the patch cleaned up by Aurel Some of the issues have been reported by Steve Manzuik / Microsoft Vulnerability Research (MSVR) Signed-off-by: Michael Niedermayer (cherry picked from commit 956c901c68eff78288f40e3c8f41ee2fa081d4a8) Further suggestions from Kostya have been implemented by Reinhard Tartler Signed-off-by: Reinhard Tartler (cherry picked from commit 77d2ef13a8fa630e5081f14bde3fd20f84c90aec) NB: MSVR-11-0080 doesn't seem to exist. This issue seems to be known as MSVR11-011 instead. Fixes: CVE-2011-3504 Signed-off-by: Reinhard Tartler --- libavformat/matroskadec.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index e254a31416..9745585ca5 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -759,11 +759,15 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, uint32_t id = syntax->id; uint64_t length; int res; + void *newelem; data = (char *)data + syntax->data_offset; if (syntax->list_elem_size) { EbmlList *list = data; - list->elem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size); + newelem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size); + if (!newelem) + return AVERROR(ENOMEM); + list->elem = newelem; data = (char*)list->elem + list->nb_elem*syntax->list_elem_size; memset(data, 0, syntax->list_elem_size); list->nb_elem++; @@ -883,6 +887,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, uint8_t* data = *buf; int isize = *buf_size; uint8_t* pkt_data = NULL; + uint8_t* newpktdata; int pkt_size = isize; int result = 0; int olen; @@ -909,7 +914,12 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, zstream.avail_in = isize; do { pkt_size *= 3; - pkt_data = av_realloc(pkt_data, pkt_size); + newpktdata = av_realloc(pkt_data, pkt_size); + if (!newpktdata) { + inflateEnd(&zstream); + goto failed; + } + pkt_data = newpktdata; zstream.avail_out = pkt_size - zstream.total_out; zstream.next_out = pkt_data + zstream.total_out; result = inflate(&zstream, Z_NO_FLUSH); @@ -930,7 +940,12 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, bzstream.avail_in = isize; do { pkt_size *= 3; - pkt_data = av_realloc(pkt_data, pkt_size); + newpktdata = av_realloc(pkt_data, pkt_size); + if (!newpktdata) { + BZ2_bzDecompressEnd(&bzstream); + goto failed; + } + pkt_data = newpktdata; bzstream.avail_out = pkt_size - bzstream.total_out_lo32; bzstream.next_out = pkt_data + bzstream.total_out_lo32; result = BZ2_bzDecompress(&bzstream); @@ -985,13 +1000,17 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska, } } -static void matroska_merge_packets(AVPacket *out, AVPacket *in) +static int matroska_merge_packets(AVPacket *out, AVPacket *in) { - out->data = av_realloc(out->data, out->size+in->size); + void *newdata = av_realloc(out->data, out->size+in->size); + if (!newdata) + return AVERROR(ENOMEM); + out->data = newdata; memcpy(out->data+out->size, in->data, in->size); out->size += in->size; av_destruct_packet(in); av_free(in); + return 0; } static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, @@ -1494,11 +1513,13 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); av_free(matroska->packets[0]); if (matroska->num_packets > 1) { + void *newpackets; memmove(&matroska->packets[0], &matroska->packets[1], (matroska->num_packets - 1) * sizeof(AVPacket *)); - matroska->packets = - av_realloc(matroska->packets, (matroska->num_packets - 1) * - sizeof(AVPacket *)); + newpackets = av_realloc(matroska->packets, + (matroska->num_packets - 1) * sizeof(AVPacket *)); + if (newpackets) + matroska->packets = newpackets; } else { av_freep(&matroska->packets); } From 3cc3f351a68706a11118a1af0aa1625f16a970e7 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 5 Nov 2011 12:46:18 +0100 Subject: [PATCH 160/301] Release notes and changelog for 0.6.3 --- Changelog | 7 ++++++- RELEASE | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 765a7102a4..f0d163bb36 100644 --- a/Changelog +++ b/Changelog @@ -10,7 +10,12 @@ version 0.6.3: - lavf: inspect more frames for fps when container time base is coarse - AMV: disable DR1 and don't override EMU_EDGE (addresses http://seclists.org/bugtraq/2011/Apr/257) -- AAC encoding via libvo-aacenc +- Fix memory (re)allocation in matroskadec.c (MSVR11-011/CVE-2011-3504) +- Fix some crashes with invalid bitstreams in the CAVS decoder + (CVE-2011-3362, CVE-2011-3973, CVE-2011-3974) +- Compilation fixes for gcc-4.6, testsuite now passes again +- Fix a heap corruption issue in the OGG decoder +- Backported the Android VisualOn AAC encoder wrapper from 0.7.2 version 0.6.2: diff --git a/RELEASE b/RELEASE index 5dbdf03b08..97f04d6ae6 100644 --- a/RELEASE +++ b/RELEASE @@ -151,9 +151,10 @@ codecs and container formats: General notes ------------- -This is another maintenance-only release that addresses a small number -of bugs such as security and compilation issues. Distributors and system +This is a mostly maintenance-only release that addresses a small number +of bugs such as security and compilation issues. Moreover, this release +has been updated to work with gcc-4.6 and the VisualOn AAC encoder has +been backported from the Libav 0.7.2 release. Distributors and system integrators are encouraged to update and share their patches against this branch. - For a full list of changes please see the Changelog file. From 973d752dfbfb3286c6494f99744f386b98fda4d7 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 5 Nov 2011 13:01:01 +0100 Subject: [PATCH 161/301] update version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b616048743..844f6a91ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.2 +0.6.3 From 2fc39af1dec9cae61df35dd9dcc5200021aa5f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Mon, 7 Jun 2010 11:27:26 +0000 Subject: [PATCH 162/301] Added M701 codec_tag for mpeg2video Originally committed as revision 23513 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit 77d3f1f792c2a0bd455c75b0aa8e356b3a470ea7) Signed-off-by: Reinhard Tartler --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 64464caa5d..0e925f25cc 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -123,6 +123,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') }, /* Lead MPEG2 in avi */ { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') }, { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') }, + { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') }, /* Matrox MPEG2 intra-only */ { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') }, { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') }, { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') }, From 394c3e78d533ce5169a3700e4dc326c2d75368af Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 22 Jul 2011 10:13:22 -0700 Subject: [PATCH 163/301] riff: Add mpgv MPEG-2 fourcc Supported by mplayer and seen in the wild. (cherry picked from commit 505345ed5d180093a44da8d70ac541898c31c22f) Signed-off-by: Reinhard Tartler --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 0e925f25cc..86899805fa 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -124,6 +124,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') }, { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') }, { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') }, /* Matrox MPEG2 intra-only */ + { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', 'v') }, { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') }, { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') }, { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') }, From feca20021cc2be02261fcd0077add8d0b6a5fc6b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 9 Jun 2011 03:35:50 +0200 Subject: [PATCH 164/301] jpegdec: actually search for and parse RSTn Fixes decoding of MJPEG files produced by some UVC Logitec web cameras, such as "Notebook Pro" and "HD C910". References: http://trac.videolan.org/vlc/ticket/4215 http://ffmpeg.org/trac/ffmpeg/ticket/267 Signed-off-by: Michael Niedermayer Reviewed-by: Kostya (cherry picked from commit 8c0fa61a9713a1306fca7997dd04d72ea1f060ea) Signed-off-by: Reinhard Tartler --- libavcodec/mjpegdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 9f2f88b5de..edfdd56057 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -839,9 +839,12 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i } } - if (s->restart_interval && !--s->restart_count) { + if (s->restart_interval && show_bits(&s->gb, 8) == 0xFF){ /* skip RSTn */ + --s->restart_count; align_get_bits(&s->gb); - skip_bits(&s->gb, 16); /* skip RSTn */ + while(show_bits(&s->gb, 8) == 0xFF) + skip_bits(&s->gb, 8); + skip_bits(&s->gb, 8); for (i=0; ilast_dc[i] = 1024; } From 21ad6e08e45952586441e5fb7b0cf670ba021718 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 3 May 2011 11:19:31 -0700 Subject: [PATCH 165/301] Replace strncpy() with av_strlcpy() in libpostproc. (cherry picked from commit 1a5e4fd8c5b99478b4e08a69261930bb12aa948b) Conflicts: ffmpeg.c libavcodec/ac3enc.c libavcodec/ass.c libavformat/movenc.c libavformat/mp3enc.c libavutil/log.c --- libpostproc/postprocess.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 92c822b772..4810353085 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -86,6 +86,7 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks //#define DEBUG_BRIGHTNESS #include "postprocess.h" #include "postprocess_internal.h" +#include "libavutil/avstring.h" unsigned postproc_version(void) { @@ -766,7 +767,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) ppMode->maxClippedThreshold= 0.01; ppMode->error=0; - strncpy(temp, name, GET_MODE_BUFFER_SIZE); + av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE); av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name); From 7487d53d0144043a462a5d54d766478ce64f0daa Mon Sep 17 00:00:00 2001 From: Piotr Kaczuba Date: Mon, 30 May 2011 13:19:35 +0200 Subject: [PATCH 166/301] postprocess.c: filter name needs to be double 0 terminated Signed-off-by: Reinhard Tartler (cherry picked from commit f4f3300c09bb13eb7922e60888b55e3e0fb325e7) (cherry picked from commit 20ca827019a72bfacb38e73d0b8590e651818272) Signed-off-by: Reinhard Tartler --- libpostproc/postprocess.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 4810353085..d2dc6bcae1 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -767,7 +767,8 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) ppMode->maxClippedThreshold= 0.01; ppMode->error=0; - av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE); + memset(temp, 0, GET_MODE_BUFFER_SIZE); + av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE - 1); av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name); @@ -823,7 +824,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) plen= strlen(p); spaceLeft= p - temp + plen; - if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE){ + if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE - 1){ ppMode->error++; break; } From 572e94bc513353e31a58e40cbb043f6b0a58e415 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 4 Jul 2011 06:05:34 -0700 Subject: [PATCH 167/301] H.264: fix overreads of qscale_table filter_mb_fast assumed that qscale_table was padded like many of the other tables. (cherry picked from commit 5029a406334ad0eaf92130e23d596e405a8a5aa0) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/mpegvideo.c | 5 +++-- libavcodec/mpegvideo.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index e11fee8ffc..695290abc2 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -282,9 +282,10 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){ } FF_ALLOCZ_OR_GOTO(s->avctx, pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2, fail) //the +2 is for the slice end check - FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table , mb_array_size * sizeof(uint8_t) , fail) + FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base , (big_mb_num + s->mb_stride) * sizeof(uint8_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t), fail) pic->mb_type= pic->mb_type_base + 2*s->mb_stride+1; + pic->qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1; if(s->out_format == FMT_H264){ for(i=0; i<2; i++){ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t), fail) @@ -335,7 +336,7 @@ static void free_picture(MpegEncContext *s, Picture *pic){ av_freep(&pic->mc_mb_var); av_freep(&pic->mb_mean); av_freep(&pic->mbskip_table); - av_freep(&pic->qscale_table); + av_freep(&pic->qscale_table_base); av_freep(&pic->mb_type_base); av_freep(&pic->dct_coeff); av_freep(&pic->pan_scan); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 8cd20b7036..9a4912cc40 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -86,6 +86,7 @@ typedef struct Picture{ * halfpel luma planes. */ uint8_t *interpolated[3]; + int8_t *qscale_table_base; int16_t (*motion_val_base[2])[2]; uint32_t *mb_type_base; #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type From 84fce203bdfa39bfaa55571ac6627aa2320e646d Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Mon, 4 Jul 2011 09:55:19 -0700 Subject: [PATCH 168/301] dca: set AVCodecContext frame_size for DTS audio Set the frame size when decoding DTS audio. This has the side effect of fixing the computation of timestamps for DTS-HD in compute_pkt_fields. Since frame_size is not currently set, the duration of a frame is being guessed based on the streams bitrate. But for DTS-HD, the bitrate currently used is the rate of the DTS core which is much different than the whole DTS-HD stream and leads to a wildly inaccurate frame duration estimate. Signed-off-by: Ronald S. Bultje (cherry picked from commit 49c7006c7e815d4330247624a9e6ba30e288cd02) Signed-off-by: Anton Khirnov (cherry picked from commit 06318968853ff8c628bbc75fb126483c08f22fd9) Signed-off-by: Reinhard Tartler --- libavcodec/dca.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 10bc956e98..493971384f 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1224,6 +1224,7 @@ static int dca_decode_frame(AVCodecContext * avctx, //set AVCodec values with parsed data avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; + avctx->frame_size = s->sample_blocks * 32; channels = s->prim_channels + !!s->lfe; From 86849f097696cf5f54ab9ddf2ec170ad0cdf9b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 4 Jul 2011 10:19:46 +0200 Subject: [PATCH 169/301] mxfenc: fix ignored drop flag in binary timecode representation. Signed-off-by: Ronald S. Bultje (cherry picked from commit 4d5e7ab5c48451404038706ef3113c9925a83087) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavformat/mxfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index ab381189c9..ab11df692e 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1536,7 +1536,7 @@ static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0 static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps) { return (0 << 31) | // color frame flag - (0 << 30) | // drop frame flag + (drop << 30) | // drop frame flag ( ((frame % fps) / 10) << 28) | // tens of frames ( ((frame % fps) % 10) << 24) | // units of frames (0 << 23) | // field phase (NTSC), b0 (PAL) From 81d5ceff04985c71a5bc84f7c88a6487c0afaf61 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 22 Jun 2011 15:33:56 -0400 Subject: [PATCH 170/301] alsa: fallback to buffer_size/4 for period_size. buffer_size/4 is the value used by aplay. This fixes output to null devices, e.g. writing ALSA output to a file. (cherry picked from commit 8bfd7f6a475225a0595bf657f8b99a8fffb461e4) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavdevice/alsa-audio-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 38cb0de0ef..12195de93e 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -129,6 +129,8 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, } snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL); + if (!period_size) + period_size = buffer_size / 4; res = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL); if (res < 0) { av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n", From 002e6d185c3febb60131be23907210f35fdf0cb8 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Thu, 30 Jun 2011 09:03:15 +0000 Subject: [PATCH 171/301] mpegts: fix Continuity Counter error detection According to MPEG-TS specs, the continuity_counter shall not be incremented when the adaptation_field_control of the packet equals '00' or '10'. Signed-off-by: Jindrich Makovicka Signed-off-by: Anton Khirnov (cherry picked from commit 8923cfa328e8eb565aebcfe8672b276fd1c19bf7) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavformat/mpegts.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 59603384d2..93bb47d837 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1140,7 +1140,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) { AVFormatContext *s = ts->stream; MpegTSFilter *tss; - int len, pid, cc, cc_ok, afc, is_start; + int len, pid, cc, expected_cc, cc_ok, afc, is_start; const uint8_t *p, *p_end; int64_t pos; @@ -1158,7 +1158,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) /* continuity check (currently not used) */ cc = (packet[3] & 0xf); - cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc)); + expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : tss->last_cc; + cc_ok = (tss->last_cc < 0) || (expected_cc == cc); tss->last_cc = cc; /* skip adaptation field */ From 5ed9457260cadfcf350ae9aece476e2a5fbc490c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 15 Jul 2011 22:38:10 +0100 Subject: [PATCH 172/301] aacps: skip some memcpy() if src and dst would be equal Signed-off-by: Mans Rullgard (cherry picked from commit e5902d60ce8f7cf10b6e87a57eec536b316261a3) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/aacps.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index fc124d1972..3cfd18d959 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -813,14 +813,17 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; //Remapping - memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); - memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); - memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); - memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); - memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); - memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); - memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); - memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + if (ps->num_env_old) { + memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); + memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); + memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); + memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); + memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); + memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); + memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); + memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + } + if (is34) { remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); From 0facc63ff6176a8d70280e8f7da26f77be81ee36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sat, 16 Jul 2011 11:41:08 -0400 Subject: [PATCH 173/301] Do not decode RV30 files if the extradata is too small Signed-off-by: Diego Biurrun (cherry picked from commit 289c60001fb0a9a1d7a97c876d8a42b84c6874ac) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/rv30.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 22a5dd5b64..215ef35414 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -256,6 +256,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){ av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n", 6 + r->rpr * 2, avctx->extradata_size); + return EINVAL; } r->parse_slice_header = rv30_parse_slice_header; r->decode_intra_types = rv30_decode_intra_types; From d2411412f15142bdf51e4677ef69a372cc6a10d4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 21 Jul 2011 14:25:01 +0200 Subject: [PATCH 174/301] rv30: return AVERROR(EINVAL) instead of EINVAL On some platforms EINVAL could be positive, ensure we return negative values. (cherry picked from commit e5985185d2eda942333ebbb72bd7d043ffe40be7) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/rv30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 215ef35414..ada3b2aeaf 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -256,7 +256,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){ av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n", 6 + r->rpr * 2, avctx->extradata_size); - return EINVAL; + return AVERROR(EINVAL); } r->parse_slice_header = rv30_parse_slice_header; r->decode_intra_types = rv30_decode_intra_types; From e07086d8aed011544ee2fc71ebab867a38a6d6e7 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 29 Jul 2011 15:27:36 -0700 Subject: [PATCH 175/301] mxfdec: Include FF_INPUT_BUFFER_PADDING_SIZE when allocating extradata. This prevents out of bounds reads when extradata is being decoded. (cherry picked from commit 1f6f58d5855288492fc2640a9f1035c01c75d356) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavformat/mxfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 168fd8d69f..a601007aec 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -592,7 +592,7 @@ static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext default: /* Private uid used by SONY C0023S01.mxf */ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { - descriptor->extradata = av_malloc(size); + descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!descriptor->extradata) return -1; descriptor->extradata_size = size; From 7b733e4b7fd052170199ae29fa14e1e71ba95077 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sat, 29 Jan 2011 17:05:42 -0800 Subject: [PATCH 176/301] libx264: do not set pic quality if no frame is output Avoids uninitialized reads. Signed-off-by: Anton Khirnov (cherry picked from commit 5caa2de19ece830e32c95731bc92a423d55cff0c) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/libx264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index df7b2e806b..e247255ce5 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -127,7 +127,8 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf, } x4->out_pic.key_frame = pic_out.b_keyframe; - x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; + if (bufsize) + x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; return bufsize; } From 36c196bca4be68f8ebf04bf2ac9b972d4f084b9f Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Thu, 11 Aug 2011 08:57:58 -0400 Subject: [PATCH 177/301] h264: notice memory allocation failure Signed-off-by: Ronald S. Bultje (cherry picked from commit bac3ab13ea6a9dd8853e79ef3eacf51d234c8774) Signed-off-by: Anton Khirnov (cherry picked from commit 59a22afa0b50b9037133a7bc26bdc5023e7e1df9) Conflicts: libavcodec/h264.c Signed-off-by: Reinhard Tartler --- libavcodec/h264.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index e4654f0435..1f045a8be7 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1840,7 +1840,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ h->prev_interlaced_frame = 1; init_scan_tables(h); - ff_h264_alloc_tables(h); + if (ff_h264_alloc_tables(h) < 0) { + av_log(h->s.avctx, AV_LOG_ERROR, "Could not allocate memory for h264\n"); + return AVERROR(ENOMEM); + } for(i = 1; i < s->avctx->thread_count; i++) { H264Context *c; From f4a5a730d8e091534ab58f6b2557374b913815ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 13 Aug 2011 11:58:18 +0200 Subject: [PATCH 178/301] VC-1: fix reading of custom PAR. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Custom PAR num/denum are in 1-256 range. Signed-off-by: Reimar Döffinger Signed-off-by: Diego Biurrun (cherry picked from commit 0e8696551414d4ea0aab2559f9475d1fe49d08f3) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/vc1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 7d00072b7a..1ed79af0bd 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -467,8 +467,8 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) if(ar && ar < 14){ v->s.avctx->sample_aspect_ratio = ff_vc1_pixel_aspect[ar]; }else if(ar == 15){ - w = get_bits(gb, 8); - h = get_bits(gb, 8); + w = get_bits(gb, 8) + 1; + h = get_bits(gb, 8) + 1; v->s.avctx->sample_aspect_ratio = (AVRational){w, h}; } av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", v->s.avctx->sample_aspect_ratio.num, v->s.avctx->sample_aspect_ratio.den); From 973bdafe05d051b6e83467c0c4ef548d2ea9a901 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Wed, 8 Jun 2011 14:32:07 +0000 Subject: [PATCH 179/301] flvenc: use int64_t to store offsets Metadata currently is written only at the start of the file in normal cases, when transcoding from a rtmp source metadata could be written later and the offset recorded can exceed 32bit. Signed-off-by: Anton Khirnov (cherry picked from commit 7f5bf4fbaf1f2142547321a16358f9871fabdcc6) Signed-off-by: Anton Khirnov (cherry picked from commit fe3e7297fe56a383baca484dea2c0d603ae305f8) Conflicts: libavformat/flvenc.c Signed-off-by: Reinhard Tartler --- libavformat/flvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index c351117132..fa6a1d13d0 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -162,7 +162,7 @@ static int flv_write_header(AVFormatContext *s) AVCodecContext *audio_enc = NULL, *video_enc = NULL; int i; double framerate = 0.0; - int metadata_size_pos, data_size; + int64_t metadata_size_pos, data_size; for(i=0; inb_streams; i++){ AVCodecContext *enc = s->streams[i]->codec; From e7746f834a7b718f6459b08112bf0d6625362e42 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 17 Aug 2011 10:36:33 +0200 Subject: [PATCH 180/301] rv10/20: tell decoder to use edge emulation This removes out-of-edge motion compensation artifacts (easily spotted green blocks in avplay, gray blocks in transcoding), for example here: http://samples.libav.org/samples/real/tv_watching_t1.rm Signed-off-by: Diego Biurrun (cherry picked from commit 331971116d7d36743601bd2dc5384c5211d3bb48) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/rv10.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index b6ca031dfa..7b635b3a1c 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -454,6 +454,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) s->avctx= avctx; s->out_format = FMT_H263; s->codec_id= avctx->codec_id; + avctx->flags |= CODEC_FLAG_EMU_EDGE; s->orig_width = s->width = avctx->coded_width; s->orig_height= s->height = avctx->coded_height; From 34d2fe68601ed21c2bda20f473ca800dfc980970 Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Tue, 5 Jul 2011 14:21:54 -0400 Subject: [PATCH 181/301] h264: correct the check for invalid long term frame index in MMCO decode The current check on MMCO parameters prohibits a "max long term frame index plus 1" of 16 (frame idx of 15) for the "set max long term frame index" MMCO. Fix this off-by-one error to allow the full range of legal values. Signed-off-by: Diego Biurrun (cherry picked from commit 29a09eae9a827f4dbc9c4517180d8fe2ecef321a) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/h264_refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index ed715c6b03..21c14d8d26 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -657,7 +657,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){ } if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ unsigned int long_arg= get_ue_golomb_31(gb); - if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ + if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && long_arg == 16) && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode); return -1; } From 01b9a6e447d8a3abd86498be26b1aef3479a1cc9 Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Wed, 6 Jul 2011 11:54:36 -0400 Subject: [PATCH 182/301] h264: correct implicit weight table computation for long ref pics Correct computation of implicit weight tables when referencing pictures that are marked for long reference. Signed-off-by: Diego Biurrun (cherry picked from commit 87cf70eb237e7586cc7399627dafa1b980ec0b7d) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/h264.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 1f045a8be7..06ded4d1f1 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1448,15 +1448,17 @@ static void implicit_weight_table(H264Context *h, int field){ for(ref0=ref_start; ref0 < ref_count0; ref0++){ int poc0 = h->ref_list[0][ref0].poc; for(ref1=ref_start; ref1 < ref_count1; ref1++){ - int poc1 = h->ref_list[1][ref1].poc; - int td = av_clip(poc1 - poc0, -128, 127); - int w= 32; - if(td){ - int tb = av_clip(cur_poc - poc0, -128, 127); - int tx = (16384 + (FFABS(td) >> 1)) / td; - int dist_scale_factor = (tb*tx + 32) >> 8; - if(dist_scale_factor >= -64 && dist_scale_factor <= 128) - w = 64 - dist_scale_factor; + int w = 32; + if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref) { + int poc1 = h->ref_list[1][ref1].poc; + int td = av_clip(poc1 - poc0, -128, 127); + if(td){ + int tb = av_clip(cur_poc - poc0, -128, 127); + int tx = (16384 + (FFABS(td) >> 1)) / td; + int dist_scale_factor = (tb*tx + 32) >> 8; + if(dist_scale_factor >= -64 && dist_scale_factor <= 128) + w = 64 - dist_scale_factor; + } } if(field<0){ h->implicit_weight[ref0][ref1][0]= From 4ccb8f5b7b99ebaab5032f0d1b2b42906e3a14c5 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Mon, 25 Jul 2011 18:51:02 -0400 Subject: [PATCH 183/301] cpu detection: avoid a signed overflow 1<<31 overflows because 1 is signed, so force it to unsigned. Signed-off-by: Ronald S. Bultje (cherry picked from commit 5938e02185430ca711106aaec9b5622dbf588af3) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/x86/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/cpuid.c b/libavcodec/x86/cpuid.c index 1ed4d2e7e3..832b9909dc 100644 --- a/libavcodec/x86/cpuid.c +++ b/libavcodec/x86/cpuid.c @@ -98,7 +98,7 @@ int mm_support(void) if(max_ext_level >= 0x80000001){ cpuid(0x80000001, eax, ebx, ecx, ext_caps); - if (ext_caps & (1<<31)) + if (ext_caps & (1U<<31)) rval |= FF_MM_3DNOW; if (ext_caps & (1<<30)) rval |= FF_MM_3DNOWEXT; From 9864518544f85ca8f0c2764fd66d728c47652bcc Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Wed, 7 Sep 2011 23:12:32 +0200 Subject: [PATCH 184/301] Fixed invalid access in wavpack decoder on corrupted extra bits sub-blocks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit beefafda639dd53fc59c21d8a7cf8334da9a1062) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/wavpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 7358d29735..3963a6003d 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -368,7 +368,7 @@ static inline int wv_get_value_integer(WavpackContext *s, uint32_t *crc, int S) if(s->extra_bits){ S <<= s->extra_bits; - if(s->got_extra_bits){ + if(s->got_extra_bits && get_bits_left(&s->gb_extra_bits) >= s->extra_bits){ S |= get_bits(&s->gb_extra_bits, s->extra_bits); *crc = *crc * 9 + (S&0xffff) * 3 + ((unsigned)S>>16); } From 1edc513bcf78341b4614081812cc7b66cd84b465 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Wed, 7 Sep 2011 22:02:55 +0200 Subject: [PATCH 185/301] Fixed invalid access in wavpack decoder on corrupted bitstream. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit 55354b7de21e7bb4bbeb1c12ff55ea17f807c70c) Signed-off-by: Anton Khirnov (cherry picked from commit 4b84e995ad88f3bfa533c38218f2791c14fd72f0) Signed-off-by: Reinhard Tartler --- libavcodec/wavpack.c | 49 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 3963a6003d..906ccea766 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -275,7 +275,14 @@ static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int } }else{ t = get_unary_0_33(gb); - if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1)); + if(t >= 2){ + if(get_bits_left(gb) < t-1) + goto error; + t = get_bits(gb, t - 1) | (1 << (t-1)); + }else{ + if(get_bits_left(gb) < 0) + goto error; + } ctx->zeroes = t; if(ctx->zeroes){ memset(ctx->ch[0].median, 0, sizeof(ctx->ch[0].median)); @@ -286,24 +293,24 @@ static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int } } - if(get_bits_count(gb) >= ctx->data_size){ - *last = 1; - return 0; - } - if(ctx->zero){ t = 0; ctx->zero = 0; }else{ t = get_unary_0_33(gb); - if(get_bits_count(gb) >= ctx->data_size){ - *last = 1; - return 0; - } + if(get_bits_left(gb) < 0) + goto error; if(t == 16) { t2 = get_unary_0_33(gb); - if(t2 < 2) t += t2; - else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1)); + if(t2 < 2){ + if(get_bits_left(gb) < 0) + goto error; + t += t2; + }else{ + if(get_bits_left(gb) < t2 - 1) + goto error; + t += get_bits(gb, t2 - 1) | (1 << (t2 - 1)); + } } if(ctx->one){ @@ -343,9 +350,13 @@ static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int } if(!c->error_limit){ ret = base + get_tail(gb, add); + if (get_bits_left(gb) <= 0) + goto error; }else{ int mid = (base*2 + add + 1) >> 1; while(add > c->error_limit){ + if(get_bits_left(gb) <= 0) + goto error; if(get_bits1(gb)){ add -= (mid - base); base = mid; @@ -359,6 +370,10 @@ static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int if(ctx->hybrid_bitrate) c->slow_level += wp_log2(ret) - LEVEL_DECAY(c->slow_level); return sign ? ~ret : ret; + +error: + *last = 1; + return 0; } static inline int wv_get_value_integer(WavpackContext *s, uint32_t *crc, int S) @@ -559,7 +574,10 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d count++; }while(!last && count < s->max_samples); - s->samples_left -= count; + if (last) + s->samples_left = 0; + else + s->samples_left -= count; if(!s->samples_left){ if(crc != s->CRC){ av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); @@ -632,7 +650,10 @@ static inline int wv_unpack_mono(WavpackContext *s, GetBitContext *gb, void *dst count++; }while(!last && count < s->samples); - s->samples_left -= count; + if (last) + s->samples_left = 0; + else + s->samples_left -= count; if(!s->samples_left){ if(crc != s->CRC){ av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); From f5a8c4242eda7a41d8c93d9ddf352cb31830b06b Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Wed, 7 Sep 2011 22:17:39 +0200 Subject: [PATCH 186/301] Fixed invalid writes in wavpack decoder on corrupted bitstreams. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit 0aedab03405849962b469277afe047aa2c61a87f) Signed-off-by: Anton Khirnov (cherry picked from commit 685940da4c843beb9283a21718cbd2fa4fa5d796) Conflicts: libavcodec/wavpack.c Signed-off-by: Reinhard Tartler --- libavcodec/wavpack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 906ccea766..968ffa600b 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1009,7 +1009,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, int16_t *dst = (int16_t*)samples + samplecount * 2; int16_t *src = (int16_t*)samples + samplecount; int cnt = samplecount; - while(cnt--){ + while(cnt-- > 0){ *--dst = *--src; *--dst = *src; } @@ -1018,7 +1018,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, int32_t *dst = (int32_t*)samples + samplecount * 2; int32_t *src = (int32_t*)samples + samplecount; int cnt = samplecount; - while(cnt--){ + while(cnt-- > 0){ *--dst = *--src; *--dst = *src; } @@ -1027,7 +1027,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, float *dst = (float*)samples + samplecount * 2; float *src = (float*)samples + samplecount; int cnt = samplecount; - while(cnt--){ + while(cnt-- > 0){ *--dst = *--src; *--dst = *src; } From 14fae6eab0e32af483d86fb7c2ac7e69e69d638e Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 8 Sep 2011 11:02:43 -0700 Subject: [PATCH 187/301] wavpack: Check error codes rather than working around error conditions. (cherry picked from commit dba2b63a98bdcac7bda1a8a2c48950518c075e17) Signed-off-by: Anton Khirnov (cherry picked from commit 5d4c065476da547fd1a8a604e3047e1b3a7a29d8) Conflicts: libavcodec/wavpack.c Signed-off-by: Reinhard Tartler --- libavcodec/wavpack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 968ffa600b..db83c44132 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -997,6 +997,9 @@ static int wavpack_decode_frame(AVCodecContext *avctx, else samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_FLT); + if (samplecount < 0) + return -1; + }else{ if(avctx->sample_fmt == SAMPLE_FMT_S16) samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_S16); @@ -1005,6 +1008,9 @@ static int wavpack_decode_frame(AVCodecContext *avctx, else samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_FLT); + if (samplecount < 0) + return -1; + if(s->stereo && avctx->sample_fmt == SAMPLE_FMT_S16){ int16_t *dst = (int16_t*)samples + samplecount * 2; int16_t *src = (int16_t*)samples + samplecount; From 23999c45bc559d8ce56f1f0f07468b3180fd48a0 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 9 Sep 2011 13:24:19 -0700 Subject: [PATCH 188/301] indeo2: init_get_bits size in bits instead of bytes (cherry picked from commit 68ca330cbd479111db9cb7649d7530ad59f04cc8) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/indeo2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index a3d6c80081..7060578044 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -165,7 +165,7 @@ static int ir2_decode_frame(AVCodecContext *avctx, #endif start = 48; /* hardcoded for now */ - init_get_bits(&s->gb, buf + start, buf_size - start); + init_get_bits(&s->gb, buf + start, (buf_size - start) * 8); if (s->decode_delta) { /* intraframe */ ir2_decode_plane(s, avctx->width, avctx->height, From 7f163e5a8749845b8fb25337a1b7023a8d9d4bc0 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 9 Sep 2011 13:26:49 -0700 Subject: [PATCH 189/301] indeo2: fail if input buffer too small (cherry picked from commit b7ce4f1d1c3add86ece7ca595ea6c4a10b471055) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/indeo2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 7060578044..819c94bea1 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -156,6 +156,13 @@ static int ir2_decode_frame(AVCodecContext *avctx, return -1; } + start = 48; /* hardcoded for now */ + + if (start >= buf_size) { + av_log(s->avctx, AV_LOG_ERROR, "input buffer size too small (%d)\n", buf_size); + return AVERROR_INVALIDDATA; + } + s->decode_delta = buf[18]; /* decide whether frame uses deltas or not */ @@ -163,7 +170,6 @@ static int ir2_decode_frame(AVCodecContext *avctx, for (i = 0; i < buf_size; i++) buf[i] = av_reverse[buf[i]]; #endif - start = 48; /* hardcoded for now */ init_get_bits(&s->gb, buf + start, (buf_size - start) * 8); From 5394cdf7759ca12f0dde2c31483ecb5f3450afda Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Wed, 7 Sep 2011 21:43:03 +0200 Subject: [PATCH 190/301] Fixed segfault with wavpack decoder on corrupted decorrelation terms sub-blocks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit 8bfea4ab4e2cb32bc7bf6f697ee30a238c65d296) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/wavpack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index db83c44132..43f28a67d4 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -776,12 +776,13 @@ static int wavpack_decode_frame(AVCodecContext *avctx, } switch(id & WP_IDF_MASK){ case WP_ID_DECTERMS: - s->terms = size; - if(s->terms > MAX_TERMS){ + if(size > MAX_TERMS){ av_log(avctx, AV_LOG_ERROR, "Too many decorrelation terms\n"); + s->terms = 0; buf += ssize; continue; } + s->terms = size; for(i = 0; i < s->terms; i++) { s->decorr[s->terms - i - 1].value = (*buf & 0x1F) - 5; s->decorr[s->terms - i - 1].delta = *buf >> 5; From f79f3a946f91de62d879b73410d80fd4e55ea28f Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 12 Sep 2011 09:40:42 +0200 Subject: [PATCH 191/301] smacker demuxer: handle possible av_realloc() failure. Signed-off-by: Anton Khirnov (cherry picked from commit 47a8589f7bc69d1a29da1dfdfbd0dfa78a9e31fd) Signed-off-by: Anton Khirnov (cherry picked from commit 0b9b3570a3e3f3eff088ee061dbab165ff3eff2f) Conflicts: libavformat/smacker.c Signed-off-by: Reinhard Tartler --- libavformat/smacker.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 0dcc286556..056e9dc22f 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -289,10 +289,15 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) if(flags & 1) { int size; size = get_le32(s->pb) - 4; + uint8_t *tmpbuf; + frame_size -= size; frame_size -= 4; smk->curstream++; - smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size); + tmpbuf = av_realloc(smk->bufs[smk->curstream], size); + if (!tmpbuf) + return AVERROR(ENOMEM); + smk->bufs[smk->curstream] = tmpbuf; smk->buf_sizes[smk->curstream] = size; ret = get_buffer(s->pb, smk->bufs[smk->curstream], size); if(ret != size) From a97e82c48762cd0b1faa249cc0ec3469f149c5f0 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 10 Sep 2011 00:32:12 +0200 Subject: [PATCH 192/301] Fixed size given to init_get_bits() in xan decoder. (cherry picked from commit 393d5031c6aaaf8c2dda4eb5d676974c349fae85) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/xan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 3f6aa8cee5..9f20b7f280 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -88,17 +88,18 @@ static av_cold int xan_decode_init(AVCodecContext *avctx) return 0; } -static int xan_huffman_decode(unsigned char *dest, const unsigned char *src, - int dest_len) +static int xan_huffman_decode(unsigned char *dest, int dest_len, + const unsigned char *src, int src_len) { unsigned char byte = *src++; unsigned char ival = byte + 0x16; const unsigned char * ptr = src + byte*2; + int ptr_len = src_len - 1 - byte*2; unsigned char val = ival; unsigned char *dest_end = dest + dest_len; GetBitContext gb; - init_get_bits(&gb, ptr, 0); // FIXME: no src size available + init_get_bits(&gb, ptr, ptr_len * 8); while ( val != 0x16 ) { val = src[val - 0x17 + get_bits1(&gb) * byte]; @@ -263,7 +264,8 @@ static void xan_wc3_decode_frame(XanContext *s) { vector_segment = s->buf + AV_RL16(&s->buf[4]); imagedata_segment = s->buf + AV_RL16(&s->buf[6]); - xan_huffman_decode(opcode_buffer, huffman_segment, opcode_buffer_size); + xan_huffman_decode(opcode_buffer, opcode_buffer_size, + huffman_segment, s->size - (huffman_segment - s->buf) ); if (imagedata_segment[0] == 2) xan_unpack(s->buffer2, &imagedata_segment[1], s->buffer2_size); From 44925239383d54af3d329fb5b12345f6209e8e62 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 11 Sep 2011 19:17:40 +0200 Subject: [PATCH 193/301] ape demuxer: fix segfault on memory allocation failure. Signed-off-by: Anton Khirnov (cherry picked from commit 273aab99bf7be2bcda95dd64101c2317ee0fcb99) Signed-off-by: Anton Khirnov (cherry picked from commit 4ee014309c377f7cfaa9578a393864ae500136f6) Signed-off-by: Reinhard Tartler --- libavformat/ape.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/ape.c b/libavformat/ape.c index 0ebc307668..56a9c78a39 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -263,6 +263,8 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) if (ape->seektablelength > 0) { ape->seektable = av_malloc(ape->seektablelength); + if (!ape->seektable) + return AVERROR(ENOMEM); for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++) ape->seektable[i] = get_le32(pb); } From 6f70111e817ea83cfad8cc9be313c2c05cb2d28b Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 12 Sep 2011 20:50:13 +0200 Subject: [PATCH 194/301] Check for invalid packet size in the smacker demuxer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit e055932f5636a82275837968eea9c8fcb5bca474) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavformat/smacker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 056e9dc22f..a916a7bdf1 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -306,6 +306,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) } flags >>= 1; } + if (frame_size < 0) + return AVERROR_INVALIDDATA; if (av_new_packet(pkt, frame_size + 768)) return AVERROR(ENOMEM); if(smk->frm_size[smk->cur_frame] & 1) From 9f28eede5e56033a6f5a4fa4bece97111701d2db Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 12 Sep 2011 20:50:34 +0200 Subject: [PATCH 195/301] Fixed off by one packet size allocation in the smacker demuxer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit a92d0fa5d234582583d41b67dddecffc2c819573) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavformat/smacker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index a916a7bdf1..5cefe7bb4e 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -308,7 +308,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) } if (frame_size < 0) return AVERROR_INVALIDDATA; - if (av_new_packet(pkt, frame_size + 768)) + if (av_new_packet(pkt, frame_size + 769)) return AVERROR(ENOMEM); if(smk->frm_size[smk->cur_frame] & 1) palchange |= 2; From 5d6fe49ac91b42436616c4f2aad650231646b51a Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 12 Sep 2011 23:46:49 +0200 Subject: [PATCH 196/301] Check and propagate errors when VLC trees cannot be built in smacker decoder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit 9676ffba8346791f494451e68d2a3b37a2918a9b) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/smacker.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 1d85f68907..1af206f10e 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -133,10 +133,10 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx return -1; } b1 = get_bits_count(gb); - i1 = get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3); + i1 = ctx->v1->table ? get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3) : 0; b1 = get_bits_count(gb) - b1; b2 = get_bits_count(gb); - i2 = get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3); + i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0; b2 = get_bits_count(gb) - b2; val = ctx->recode1[i1] | (ctx->recode2[i2] << 8); if(val == ctx->escapes[0]) { @@ -289,7 +289,8 @@ static int decode_header_trees(SmackVContext *smk) { smk->mmap_tbl[0] = 0; smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1; } else { - smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size); + if (smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size)) + return -1; } if(!get_bits1(&gb)) { av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n"); @@ -297,7 +298,8 @@ static int decode_header_trees(SmackVContext *smk) { smk->mclr_tbl[0] = 0; smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1; } else { - smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size); + if (smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size)) + return -1; } if(!get_bits1(&gb)) { av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\n"); @@ -305,7 +307,8 @@ static int decode_header_trees(SmackVContext *smk) { smk->full_tbl[0] = 0; smk->full_last[0] = smk->full_last[1] = smk->full_last[2] = 1; } else { - smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size); + if (smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size)) + return -1; } if(!get_bits1(&gb)) { av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\n"); @@ -313,7 +316,8 @@ static int decode_header_trees(SmackVContext *smk) { smk->type_tbl[0] = 0; smk->type_last[0] = smk->type_last[1] = smk->type_last[2] = 1; } else { - smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size); + if (smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size)) + return -1; } return 0; @@ -523,8 +527,8 @@ static av_cold int decode_init(AVCodecContext *avctx) return -1; } - decode_header_trees(c); - + if (decode_header_trees(c)) + return -1; return 0; } From 117e04cdfa814d2ce4ce46dd925ec5257614d265 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 12 Sep 2011 23:49:36 +0200 Subject: [PATCH 197/301] Check for invalid VLC value in smacker decoder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit 6489455495fc5bfbebcfe3f57e5d4fdd6a781091) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/smacker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 1af206f10e..0424481f19 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -138,6 +138,8 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx b2 = get_bits_count(gb); i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0; b2 = get_bits_count(gb) - b2; + if (i1 < 0 || i2 < 0) + return -1; val = ctx->recode1[i1] | (ctx->recode2[i2] << 8); if(val == ctx->escapes[0]) { ctx->last[0] = hc->current; From 19a99b6e6bd91d9f177ddf69602106c89698f01d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 13 Sep 2011 23:24:56 +0200 Subject: [PATCH 198/301] smacker: fix a few off by 1 errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stereo & 16bit is untested due to lack of samples Signed-off-by: Martin Storsjö (cherry picked from commit 5166376f24545207607f61ed8ff4e1b0572ff320) Signed-off-by: Anton Khirnov (cherry picked from commit 78cd2e18a4aa2835f6d04cf145121fc82099c1a5) Conflicts: libavcodec/smacker.c Signed-off-by: Reinhard Tartler --- libavcodec/smacker.c | 8 +-- tests/ref/fate/smacker | 160 ++++++++++++++++++++--------------------- 2 files changed, 84 insertions(+), 84 deletions(-) diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 0424481f19..e2c1a8776c 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -625,9 +625,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, if(bits) { //decode 16-bit data for(i = stereo; i >= 0; i--) pred[i] = bswap_16(get_bits(&gb, 16)); - for(i = 0; i < stereo; i++) + for(i = 0; i <= stereo; i++) *samples++ = pred[i]; - for(i = 0; i < unp_size / 2; i++) { + for(; i < unp_size / 2; i++) { if(i & stereo) { if(vlc[2].table) res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3); @@ -659,9 +659,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } else { //8-bit data for(i = stereo; i >= 0; i--) pred[i] = get_bits(&gb, 8); - for(i = 0; i < stereo; i++) + for(i = 0; i <= stereo; i++) *samples8++ = pred[i]; - for(i = 0; i < unp_size; i++) { + for(; i < unp_size; i++) { if(i & stereo){ if(vlc[1].table) res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3); diff --git a/tests/ref/fate/smacker b/tests/ref/fate/smacker index 85c4a9817c..df88a4ae8a 100644 --- a/tests/ref/fate/smacker +++ b/tests/ref/fate/smacker @@ -1,5 +1,5 @@ 0, 0, 192000, 0x8926d7fc -1, 0, 47240, 0xad778a78 +1, 0, 47240, 0x9974897c 0, 6390, 192000, 0x2506d384 0, 12780, 192000, 0x9a8dc93a 0, 19170, 192000, 0x4badb7f2 @@ -15,163 +15,163 @@ 0, 83070, 192000, 0x1a3d7971 0, 89460, 192000, 0xa1a65bd5 0, 95850, 192000, 0x344957b9 -1, 96408, 3128, 0x4c1564ae +1, 96408, 3128, 0x7e4064b4 0, 102240, 192000, 0xe23b5f4e -1, 102792, 3128, 0x34553309 +1, 102792, 3128, 0x80883301 0, 108630, 192000, 0xb5c2710b -1, 109176, 3136, 0xb474d246 +1, 109176, 3136, 0x2ad2d341 0, 115020, 192000, 0x7a25938f -1, 115576, 3128, 0x87b868ea +1, 115576, 3128, 0xda8468e3 0, 121410, 192000, 0x0a84e4c9 -1, 121959, 3136, 0xf1516dc3 +1, 121959, 3136, 0x9d6f6cdf 0, 127800, 192000, 0x94209b0d -1, 128359, 3128, 0x867563cb +1, 128359, 3128, 0x1aaa64b5 0, 134190, 192000, 0xf940e51f -1, 134743, 3128, 0x5200728c +1, 134743, 3128, 0x9182728b 0, 140580, 192000, 0xb9fdec42 -1, 141127, 3136, 0xeda118a0 +1, 141127, 3136, 0xfa8e17b3 0, 146970, 192000, 0x7b04a376 -1, 147527, 3128, 0x03e2c1d6 +1, 147527, 3128, 0x0dc3c1cf 0, 153360, 192000, 0x5fe0026b -1, 153910, 3136, 0xc3e862b6 +1, 153910, 3136, 0x0109639d 0, 159750, 192000, 0x775aca39 -1, 160310, 3128, 0x937a13be +1, 160310, 3128, 0x6d8a12d9 0, 166140, 192000, 0xae14fb32 -1, 166694, 3128, 0x7b1b9577 +1, 166694, 3128, 0x4b9a9597 0, 172530, 192000, 0x661106e5 -1, 173078, 3136, 0x042c7113 +1, 173078, 3136, 0x9112710e 0, 178920, 192000, 0xe8658dbf -1, 179478, 3128, 0xac48f451 +1, 179478, 3128, 0x8cccf522 0, 185310, 192000, 0x5359f0f9 -1, 185861, 3128, 0x018fbbe9 +1, 185861, 3128, 0x6594bbf3 0, 191700, 192000, 0xc1ec80f4 -1, 192245, 3136, 0xc62aa7ce +1, 192245, 3136, 0xd878a7d5 0, 198090, 192000, 0xca53806b -1, 198645, 3128, 0x106e3924 +1, 198645, 3128, 0xaa6e3905 0, 204480, 192000, 0xf0766b2e -1, 205029, 3136, 0xfeb82ecc +1, 205029, 3136, 0x2a062e04 0, 210870, 192000, 0x39962da8 -1, 211429, 3128, 0x7e7c005b +1, 211429, 3128, 0x84e4006a 0, 217260, 192000, 0x4171c37f -1, 217812, 3128, 0x949d3560 +1, 217812, 3128, 0x85183633 0, 223650, 192000, 0x3abf3b46 -1, 224196, 3136, 0x02bd4aff +1, 224196, 3136, 0xb62d4b02 0, 230040, 192000, 0xecc68313 -1, 230596, 3128, 0x4aaf4715 +1, 230596, 3128, 0xe209462a 0, 236430, 192000, 0xea339baf -1, 236980, 3136, 0x2958825f +1, 236980, 3136, 0x57c4824b 0, 242820, 192000, 0x616b8f16 -1, 243380, 3128, 0x99a5914d +1, 243380, 3128, 0x664a9163 0, 249210, 192000, 0xf77a8581 -1, 249763, 3128, 0xe67277a4 +1, 249763, 3128, 0xb4287874 0, 255600, 192000, 0xb315678b -1, 256147, 3136, 0x11296973 +1, 256147, 3136, 0xde626885 0, 261990, 192000, 0x0a4a5218 -1, 262547, 3128, 0x5cc362f7 +1, 262547, 3128, 0x919763c2 0, 268380, 192000, 0x98802be4 -1, 268931, 3128, 0x0c5e6586 +1, 268931, 3128, 0xa4f664e1 0, 274770, 192000, 0xa2f0fd94 -1, 275314, 3136, 0xe940b0f9 +1, 275314, 3136, 0xa0bab0d4 0, 281160, 192000, 0x6671c84f -1, 281714, 3128, 0x2c9292cc +1, 281714, 3128, 0xe938939c 0, 287550, 192000, 0x38327e31 -1, 288098, 3136, 0xa807c096 +1, 288098, 3136, 0x3679bfc7 0, 293940, 192000, 0xb85d3e08 -1, 294498, 3128, 0x9d2254d8 +1, 294498, 3128, 0xc96c55c3 0, 300330, 192000, 0xdc69eba9 -1, 300882, 3128, 0xe68015b0 +1, 300882, 3128, 0x119114d6 0, 306720, 192000, 0x8955a0b3 -1, 307265, 3136, 0x65d58029 +1, 307265, 3136, 0x42f3800f 0, 313110, 192000, 0x714a548b -1, 313665, 3128, 0xcffcc48c +1, 313665, 3128, 0x4250c4ad 0, 319500, 192000, 0xc0471de9 -1, 320049, 3136, 0x8c704944 +1, 320049, 3136, 0x5cdd4925 0, 325890, 192000, 0x2e16e039 -1, 326449, 3128, 0x1459231d +1, 326449, 3128, 0xa4c12360 0, 332280, 192000, 0x9fa4b033 -1, 332833, 3128, 0x7dde4839 +1, 332833, 3128, 0x849f48de 0, 338670, 192000, 0x4a0f9402 -1, 339216, 3136, 0xbb6890e2 +1, 339216, 3136, 0x6acd8ff9 0, 345060, 192000, 0x1f3e6843 -1, 345616, 3128, 0xcd9a8524 +1, 345616, 3128, 0xb2758556 0, 351450, 192000, 0x31774850 -1, 352000, 3128, 0xa244fc31 +1, 352000, 3128, 0x10f2fcb1 0, 357840, 192000, 0x9d5336a2 -1, 358384, 3136, 0x504e2bd9 +1, 358384, 3136, 0xf0f02b23 0, 364230, 192000, 0xf7de27a2 -1, 364784, 3128, 0x655858d8 +1, 364784, 3128, 0x64f759c6 0, 370620, 192000, 0x98c717ce -1, 371167, 3136, 0x46027610 +1, 371167, 3136, 0x7ec075e3 0, 377010, 192000, 0x615b10b8 -1, 377567, 3128, 0x4192d5e3 +1, 377567, 3128, 0xf981d51e 0, 383400, 192000, 0xd5bc0e7e -1, 383951, 3128, 0x21d2e7fe +1, 383951, 3128, 0xc622e8b9 0, 389790, 192000, 0xd5bc0e7e -1, 390335, 3136, 0x7c93e329 +1, 390335, 3136, 0xf632e2f8 0, 396180, 192000, 0xd5bc0e7e -1, 396735, 3128, 0xa67718c0 +1, 396735, 3128, 0xda561864 0, 402570, 192000, 0xd5bc0e7e -1, 403118, 3136, 0x9bb6e8a3 +1, 403118, 3136, 0x14d2e888 0, 408960, 192000, 0xd5bc0e7e -1, 409518, 3128, 0x0933b7a6 +1, 409518, 3128, 0x015bb869 0, 415350, 192000, 0xd5bc0e7e -1, 415902, 3128, 0x07f1fb57 +1, 415902, 3128, 0xedb1fb62 0, 421740, 192000, 0xd5bc0e7e -1, 422286, 3136, 0x8a050cfd +1, 422286, 3136, 0xe0560c41 0, 428130, 192000, 0xd5bc0e7e -1, 428686, 3128, 0xdb773c0b +1, 428686, 3128, 0x14773c9a 0, 434520, 192000, 0xd5bc0e7e -1, 435069, 3136, 0xd1281c53 +1, 435069, 3136, 0x850f1c82 0, 440910, 192000, 0xd5bc0e7e -1, 441469, 3128, 0x9f395324 +1, 441469, 3128, 0xb0bd5347 0, 447300, 192000, 0xd5bc0e7e -1, 447853, 3128, 0x5f13edec +1, 447853, 3128, 0x8f82edbf 0, 453690, 192000, 0xd5bc0e7e -1, 454237, 3136, 0x871cbecf +1, 454237, 3136, 0x493abee2 0, 460080, 192000, 0xd5bc0e7e -1, 460637, 3128, 0x799eff3e +1, 460637, 3128, 0xf5daff3f 0, 466470, 192000, 0xd5bc0e7e -1, 467020, 3128, 0x3f902762 +1, 467020, 3128, 0x78ad2690 0, 472860, 192000, 0xd5bc0e7e -1, 473404, 3136, 0x29f8bb04 +1, 473404, 3136, 0x490ebafc 0, 479250, 192000, 0xd5bc0e7e -1, 479804, 3128, 0xf3523ee9 +1, 479804, 3128, 0x70333fd2 0, 485640, 192000, 0xd5bc0e7e -1, 486188, 3136, 0x4405c435 +1, 486188, 3136, 0x8cb1c350 0, 492030, 192000, 0xd5bc0e7e -1, 492588, 3128, 0x892957cb +1, 492588, 3128, 0x8bd057cb 0, 498420, 192000, 0xd5bc0e7e -1, 498971, 3128, 0xdf483dbd +1, 498971, 3128, 0x161b3dbc 0, 504810, 192000, 0xd5bc0e7e -1, 505355, 3136, 0x5e8ab797 +1, 505355, 3136, 0xb47fb88a 0, 511200, 192000, 0xd5bc0e7e -1, 511755, 3128, 0x92e13820 +1, 511755, 3128, 0x474b381e 0, 517590, 192000, 0xd5bc0e7e -1, 518139, 3136, 0xfde719b6 +1, 518139, 3136, 0x07c519bb 0, 523980, 192000, 0xd5bc0e7e -1, 524539, 3128, 0x442f17ae +1, 524539, 3128, 0x15b916c8 0, 530370, 192000, 0xd5bc0e7e -1, 530922, 3128, 0x011af61f +1, 530922, 3128, 0x0ed7f6fb 0, 536760, 192000, 0xd5bc0e7e -1, 537306, 3136, 0x4e3e3a6d +1, 537306, 3136, 0x54d6397b 0, 543150, 192000, 0xd5bc0e7e -1, 543706, 3128, 0xc11242b9 +1, 543706, 3128, 0x437242bb 0, 549540, 192000, 0xd5bc0e7e -1, 550090, 3128, 0x01415b59 +1, 550090, 3128, 0x38f05c4d 0, 555930, 192000, 0xd5bc0e7e -1, 556473, 3136, 0x302e0e55 +1, 556473, 3136, 0x5d000e59 0, 562320, 192000, 0xd5bc0e7e -1, 562873, 3128, 0x20522d04 +1, 562873, 3128, 0xdeab2d04 0, 568710, 192000, 0xd5bc0e7e -1, 569257, 3136, 0x316a697d +1, 569257, 3136, 0x77de6880 0, 575100, 192000, 0xd5bc0e7e -1, 575657, 3128, 0x6d75ee27 +1, 575657, 3128, 0xbc87ef25 0, 581490, 192000, 0xd5bc0e7e -1, 582041, 3128, 0xcb008ae8 +1, 582041, 3128, 0xc1638ade 0, 587880, 192000, 0xd5bc0e7e -1, 588424, 3136, 0xd2664b51 +1, 588424, 3136, 0xcfb64a5f 0, 594270, 192000, 0xd5bc0e7e -1, 594824, 3128, 0xdfcab728 +1, 594824, 3128, 0x90b1b826 0, 600660, 192000, 0xd5bc0e7e 1, 601208, 3136, 0x00000000 0, 607050, 192000, 0xd5bc0e7e From 23f622de60d66b6e47c28493089566becd635426 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 11 Sep 2011 23:26:12 +0200 Subject: [PATCH 199/301] oggdec: fix out of bound write in the ogg demuxer Between ogg_save() and ogg_restore() calls, the number of streams could have been reduced. Signed-off-by: Luca Barbato (cherry picked from commit 0e7efb9d23c3641d50caa288818e8c27647ce74d) Signed-off-by: Anton Khirnov (cherry picked from commit a3d471e500674c31fa4f52a62ef789d5e7fdbd3c) Signed-off-by: Reinhard Tartler --- libavformat/oggdec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 76b28ab212..bd00d1a4e6 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -94,14 +94,24 @@ ogg_restore (AVFormatContext * s, int discard) ogg->state = ost->next; if (!discard){ + struct ogg_stream *old_streams = ogg->streams; + for (i = 0; i < ogg->nstreams; i++) av_free (ogg->streams[i].buf); url_fseek (bc, ost->pos, SEEK_SET); ogg->curidx = ost->curidx; ogg->nstreams = ost->nstreams; - memcpy(ogg->streams, ost->streams, - ost->nstreams * sizeof(*ogg->streams)); + ogg->streams = av_realloc (ogg->streams, + ogg->nstreams * sizeof (*ogg->streams)); + + if (ogg->streams) { + memcpy(ogg->streams, ost->streams, + ost->nstreams * sizeof(*ogg->streams)); + } else { + av_free(old_streams); + ogg->nstreams = 0; + } } av_free (ost); From 7cd7461ec8013a381938b52568f9eb08ab3d1720 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 18 Sep 2011 00:03:08 +0200 Subject: [PATCH 200/301] rv10: Reject slices that does not have the same type as the first one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prevents crashes with some corrupted bitstreams. Signed-off-by: Martin Storsjö (cherry picked from commit 4a29b471869353c3077fb4b25b6518eb1047afb7) Signed-off-by: Anton Khirnov (cherry picked from commit 28d948ac44e38e8bec2f6268ccf4747ff4d992a9) Signed-off-by: Reinhard Tartler --- libavcodec/rv10.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 7b635b3a1c..af0d16c022 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -559,6 +559,11 @@ static int rv10_decode_packet(AVCodecContext *avctx, if(MPV_frame_start(s, avctx) < 0) return -1; ff_er_frame_start(s); + } else { + if (s->current_picture_ptr->pict_type != s->pict_type) { + av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); + return -1; + } } dprintf(avctx, "qscale=%d\n", s->qscale); From 35f1888585e0ffa2f1334cf92fc0a16fb4a113a6 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 17 Sep 2011 23:43:58 +0200 Subject: [PATCH 201/301] rv34: Avoid NULL dereference on corrupted bitstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rv34_decode_slice() can return without allocating any pictures. Signed-off-by: Martin Storsjö (cherry picked from commit d0f6ab0298f2309c6104626787ed73416298b019) Signed-off-by: Anton Khirnov Signed-off-by: Reinhard Tartler --- libavcodec/rv34.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 88652f9fe1..a1dc799c3e 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1494,7 +1494,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, break; } - if(last){ + if(last && s->current_picture_ptr){ if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); ff_er_frame_end(s); From d5551d788444872deb62101b7a52e335c87db69a Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 17 Sep 2011 16:56:30 +0200 Subject: [PATCH 202/301] rv34: Fix potential overreads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit b4ed3d78cb6c41c9d3ee5918c326ab925edd6a89) Signed-off-by: Anton Khirnov (cherry picked from commit b4a1bf0bbf53cc6a736a608732b2ac1de5c2447b) Conflicts: libavcodec/rv34.c Signed-off-by: Reinhard Tartler --- libavcodec/rv34.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index a1dc799c3e..8d5f4f7e3e 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1439,6 +1439,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, slice_count = (*buf++) + 1; slices_hdr = buf + 4; buf += 8 * slice_count; + buf_size -= 1 + 8 * slice_count; }else slice_count = avctx->slice_count; @@ -1459,7 +1460,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==FF_B_TYPE) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=FF_I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) - return buf_size; + return avpkt->size; /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return buf_size; @@ -1511,7 +1512,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, } s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...) } - return buf_size; + return avpkt->size; } av_cold int ff_rv34_decode_end(AVCodecContext *avctx) From da0900e8bba8d39b022add6eb8cd1857a344c405 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 19 Sep 2011 22:48:53 +0200 Subject: [PATCH 203/301] rv34: Check for invalid slice offsets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö (cherry picked from commit 4cc7732386eb36661ed22d1200339b38a5fa60bc) Signed-off-by: Anton Khirnov (cherry picked from commit 2bbb142a140173e1870017b66c439f4d430a6f67) Signed-off-by: Reinhard Tartler --- libavcodec/rv34.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 8d5f4f7e3e..e6fa3cfd8f 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1444,8 +1444,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, slice_count = avctx->slice_count; //parse first slice header to check whether this frame can be decoded - if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){ - av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); + if(get_slice_offset(avctx, slices_hdr, 0) < 0 || + get_slice_offset(avctx, slices_hdr, 0) > buf_size){ + av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); return -1; } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), buf_size-get_slice_offset(avctx, slices_hdr, 0)); @@ -1473,8 +1474,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, else size= get_slice_offset(avctx, slices_hdr, i+1) - offset; - if(offset > buf_size){ - av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); + if(offset < 0 || offset > buf_size || size < 0){ + av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); break; } From b99366faef3a1ed4a34c9b37107f2c8c24702813 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 11 Sep 2011 19:17:45 +0200 Subject: [PATCH 204/301] vmd: fix segfaults on corruped streams Signed-off-by: Janne Grunau Signed-off-by: Reinhard Tartler (cherry picked from commit 494cfacdb9ba3f0549e37f76b3a2f86a7aeeac3c) Signed-off-by: Reinhard Tartler --- libavcodec/vmdav.c | 104 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 4914d2a09a..2c97d3f707 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -72,9 +72,11 @@ typedef struct VmdVideoContext { #define QUEUE_SIZE 0x1000 #define QUEUE_MASK 0x0FFF -static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_len) +static void lz_unpack(const unsigned char *src, int src_len, + unsigned char *dest, int dest_len) { const unsigned char *s; + unsigned int s_len; unsigned char *d; unsigned char *d_end; unsigned char queue[QUEUE_SIZE]; @@ -87,13 +89,16 @@ static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_le unsigned int i, j; s = src; + s_len = src_len; d = dest; d_end = d + dest_len; dataleft = AV_RL32(s); - s += 4; + s += 4; s_len -= 4; memset(queue, 0x20, QUEUE_SIZE); + if (s_len < 4) + return; if (AV_RL32(s) == 0x56781234) { - s += 4; + s += 4; s_len -= 4; qpos = 0x111; speclen = 0xF + 3; } else { @@ -101,32 +106,41 @@ static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_le speclen = 100; /* no speclen */ } - while (dataleft > 0) { - tag = *s++; + while (dataleft > 0 && s_len > 0) { + tag = *s++; s_len--; if ((tag == 0xFF) && (dataleft > 8)) { - if (d + 8 > d_end) + if (d + 8 > d_end || s_len < 8) return; for (i = 0; i < 8; i++) { queue[qpos++] = *d++ = *s++; qpos &= QUEUE_MASK; } + s_len -= 8; dataleft -= 8; } else { for (i = 0; i < 8; i++) { if (dataleft == 0) break; if (tag & 0x01) { - if (d + 1 > d_end) + if (d + 1 > d_end || s_len < 1) return; queue[qpos++] = *d++ = *s++; qpos &= QUEUE_MASK; dataleft--; + s_len--; } else { + if (s_len < 2) + return; chainofs = *s++; chainofs |= ((*s & 0xF0) << 4); chainlen = (*s++ & 0x0F) + 3; - if (chainlen == speclen) + s_len -= 2; + if (chainlen == speclen) { + if (s_len < 1) + return; chainlen = *s++ + 0xF + 3; + s_len--; + } if (d + chainlen > d_end) return; for (j = 0; j < chainlen; j++) { @@ -143,7 +157,7 @@ static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_le } static int rle_unpack(const unsigned char *src, unsigned char *dest, - int src_len, int dest_len) + int src_count, int src_size, int dest_len) { const unsigned char *ps; unsigned char *pd; @@ -152,31 +166,40 @@ static int rle_unpack(const unsigned char *src, unsigned char *dest, ps = src; pd = dest; - if (src_len & 1) + if (src_count & 1) { + if (src_size < 1) + return 0; *pd++ = *ps++; + src_size--; + } - src_len >>= 1; + src_count >>= 1; i = 0; do { + if (src_size < 1) + break; l = *ps++; + src_size--; if (l & 0x80) { l = (l & 0x7F) * 2; - if (pd + l > dest_end) + if (pd + l > dest_end || src_size < l) return ps - src; memcpy(pd, ps, l); ps += l; + src_size -= l; pd += l; } else { - if (pd + i > dest_end) + if (pd + i > dest_end || src_size < 2) return ps - src; for (i = 0; i < l; i++) { *pd++ = ps[0]; *pd++ = ps[1]; } ps += 2; + src_size -= 2; } i += l; - } while (i < src_len); + } while (i < src_count); return ps - src; } @@ -191,6 +214,7 @@ static void vmd_decode(VmdVideoContext *s) const unsigned char *p = s->buf + 16; const unsigned char *pb; + unsigned int pb_size; unsigned char meth; unsigned char *dp; /* pointer to current frame */ unsigned char *pp; /* pointer to previous frame */ @@ -205,6 +229,16 @@ static void vmd_decode(VmdVideoContext *s) frame_y = AV_RL16(&s->buf[8]); frame_width = AV_RL16(&s->buf[10]) - frame_x + 1; frame_height = AV_RL16(&s->buf[12]) - frame_y + 1; + if (frame_x < 0 || frame_width < 0 || + frame_x >= s->avctx->width || + frame_width > s->avctx->width || + frame_x + frame_width > s->avctx->width) + return; + if (frame_y < 0 || frame_height < 0 || + frame_y >= s->avctx->height || + frame_height > s->avctx->height || + frame_y + frame_height > s->avctx->height) + return; if ((frame_width == s->avctx->width && frame_height == s->avctx->height) && (frame_x || frame_y)) { @@ -217,8 +251,9 @@ static void vmd_decode(VmdVideoContext *s) /* if only a certain region will be updated, copy the entire previous * frame before the decode */ - if (frame_x || frame_y || (frame_width != s->avctx->width) || - (frame_height != s->avctx->height)) { + if (s->prev_frame.data[0] && + (frame_x || frame_y || (frame_width != s->avctx->width) || + (frame_height != s->avctx->height))) { memcpy(s->frame.data[0], s->prev_frame.data[0], s->avctx->height * s->frame.linesize[0]); @@ -236,14 +271,19 @@ static void vmd_decode(VmdVideoContext *s) } s->size -= (256 * 3 + 2); } - if (s->size >= 0) { + if (s->size > 0) { /* originally UnpackFrame in VAG's code */ pb = p; - meth = *pb++; + pb_size = s->buf + s->size - pb; + if (pb_size < 1) + return; + meth = *pb++; pb_size--; if (meth & 0x80) { - lz_unpack(pb, s->unpack_buffer, s->unpack_buffer_size); + lz_unpack(pb, pb_size, + s->unpack_buffer, s->unpack_buffer_size); meth &= 0x7F; pb = s->unpack_buffer; + pb_size = s->unpack_buffer_size; } dp = &s->frame.data[0][frame_y * s->frame.linesize[0] + frame_x]; @@ -254,17 +294,21 @@ static void vmd_decode(VmdVideoContext *s) for (i = 0; i < frame_height; i++) { ofs = 0; do { + if (pb_size < 1) + return; len = *pb++; + pb_size--; if (len & 0x80) { len = (len & 0x7F) + 1; - if (ofs + len > frame_width) + if (ofs + len > frame_width || pb_size < len) return; memcpy(&dp[ofs], pb, len); pb += len; + pb_size -= len; ofs += len; } else { /* interframe pixel copy */ - if (ofs + len + 1 > frame_width) + if (ofs + len + 1 > frame_width || !s->prev_frame.data[0]) return; memcpy(&dp[ofs], &pp[ofs], len + 1); ofs += len + 1; @@ -282,8 +326,11 @@ static void vmd_decode(VmdVideoContext *s) case 2: for (i = 0; i < frame_height; i++) { + if (pb_size < frame_width) + return; memcpy(dp, pb, frame_width); pb += frame_width; + pb_size -= frame_width; dp += s->frame.linesize[0]; pp += s->prev_frame.linesize[0]; } @@ -293,18 +340,27 @@ static void vmd_decode(VmdVideoContext *s) for (i = 0; i < frame_height; i++) { ofs = 0; do { + if (pb_size < 1) + return; len = *pb++; + pb_size--; if (len & 0x80) { len = (len & 0x7F) + 1; + if (pb_size < 1) + return; if (*pb++ == 0xFF) - len = rle_unpack(pb, &dp[ofs], len, frame_width - ofs); - else + len = rle_unpack(pb, &dp[ofs], len, pb_size, frame_width - ofs); + else { + if (pb_size < len) + return; memcpy(&dp[ofs], pb, len); + } pb += len; + pb_size -= 1 + len; ofs += len; } else { /* interframe pixel copy */ - if (ofs + len + 1 > frame_width) + if (ofs + len + 1 > frame_width || !s->prev_frame.data[0]) return; memcpy(&dp[ofs], &pp[ofs], len + 1); ofs += len + 1; From 0f7bf1786e43d05c4ec1667a1457df7b22b05561 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 1 Oct 2011 00:45:05 +0200 Subject: [PATCH 205/301] Check for out of bound writes in the QDM2 decoder. Signed-off-by: Michael Niedermayer Signed-off-by: Justin Ruggles (cherry picked from commit 291d74a46d32183653db07818c7b3407fd50a288) Signed-off-by: Reinhard Tartler (cherry picked from commit a31ccacb1a9b2abc0e140a812fb0ffca6f7c2591) Signed-off-by: Reinhard Tartler --- libavcodec/qdm2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 6451fbe91f..3273dd1795 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -75,6 +75,7 @@ do { \ #define SAMPLES_NEEDED_2(why) \ av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why); +#define QDM2_MAX_FRAME_SIZE 512 typedef int8_t sb_int8_array[2][30][64]; @@ -167,7 +168,7 @@ typedef struct { /// I/O data const uint8_t *compressed_data; int compressed_size; - float output_buffer[1024]; + float output_buffer[QDM2_MAX_FRAME_SIZE * 2]; /// Synthesis filter DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512*2]; @@ -1799,6 +1800,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) avctx->channels = s->nb_channels = s->channels = AV_RB32(extradata); extradata += 4; + if (s->channels > MPA_MAX_CHANNELS) + return AVERROR_INVALIDDATA; avctx->sample_rate = AV_RB32(extradata); extradata += 4; @@ -1820,6 +1823,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) // something like max decodable tones s->group_order = av_log2(s->group_size) + 1; s->frame_size = s->group_size / 16; // 16 iterations per super block + if (s->frame_size > QDM2_MAX_FRAME_SIZE) + return AVERROR_INVALIDDATA; s->sub_sampling = s->fft_order - 7; s->frequency_range = 255 / (1 << (2 - s->sub_sampling)); From 8856c4c5c924b85888fcaf486e71ba15b8af610b Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 1 Oct 2011 00:45:04 +0200 Subject: [PATCH 206/301] Fix out of bound reads in the QDM2 decoder. Signed-off-by: Michael Niedermayer Signed-off-by: Justin Ruggles (cherry picked from commit 5a19acb17ceb71657b0eec51dac651953520e5c8) Signed-off-by: Reinhard Tartler (cherry picked from commit 0d93d5c4614fafea74bdac681673f5b32eb49063) Signed-off-by: Reinhard Tartler --- libavcodec/qdm2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 3273dd1795..ec33c492f4 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1356,6 +1356,8 @@ static void qdm2_fft_decode_tones (QDM2Context *q, int duration, GetBitContext * return; local_int_14 = (offset >> local_int_8); + if (local_int_14 >= FF_ARRAY_ELEMS(fft_level_index_table)) + return; if (q->nb_channels > 1) { channel = get_bits1(gb); From 201fcfb89482c6f73d6b679a294aac8da9612bbd Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Tue, 16 Aug 2011 16:46:34 -0400 Subject: [PATCH 207/301] vp6: partially propagate huffman tree building errors during coeff model parsing and fix misspelling Signed-off-by: Ronald S. Bultje (cherry picked from commit f913eeea43078b3b9052efd8d8d29e7b29b39208) Signed-off-by: Reinhard Tartler (cherry picked from commit 7367cbec1b8cf0cbb49707fb0fdfded8ec397b0d) Signed-off-by: Reinhard Tartler --- libavcodec/vp6.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 58c31f965b..b9d86e3154 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -212,8 +212,8 @@ static int vp6_huff_cmp(const void *va, const void *vb) return (a->count - b->count)*16 + (b->sym - a->sym); } -static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[], - const uint8_t *map, unsigned size, VLC *vlc) +static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[], + const uint8_t *map, unsigned size, VLC *vlc) { Node nodes[2*size], *tmp = &nodes[size]; int a, b, i; @@ -228,9 +228,9 @@ static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[], } free_vlc(vlc); - /* then build the huffman tree accodring to probabilities */ - ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp, - FF_HUFFMAN_FLAG_HNODE_FIRST); + /* then build the huffman tree according to probabilities */ + return ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp, + FF_HUFFMAN_FLAG_HNODE_FIRST); } static void vp6_parse_coeff_models(VP56Context *s) From a62779d986292a5a4d5fb4c39031f9665c39b4a4 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Wed, 21 Sep 2011 20:46:32 +0200 Subject: [PATCH 208/301] vp6: Check for huffman tree build errors Signed-off-by: Janne Grunau (cherry picked from commit 066fff755a5d8edc660c010ddb08474d208eeade) Signed-off-by: Reinhard Tartler (cherry picked from commit 30c08e226156e5a36a835c008c67114f22c8da8f) Signed-off-by: Reinhard Tartler --- libavcodec/vp5.c | 3 ++- libavcodec/vp56.c | 4 +++- libavcodec/vp56.h | 2 +- libavcodec/vp6.c | 20 ++++++++++++-------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 1479344ba4..703a1c3389 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -116,7 +116,7 @@ static void vp5_parse_vector_models(VP56Context *s) model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7); } -static void vp5_parse_coeff_models(VP56Context *s) +static int vp5_parse_coeff_models(VP56Context *s) { VP56RangeCoder *c = &s->c; VP56Model *model = s->modelp; @@ -160,6 +160,7 @@ static void vp5_parse_coeff_models(VP56Context *s) for (ctx=0; ctx<6; ctx++) for (node=0; node<5; node++) model->coeff_acct[pt][ct][cg][ctx][node] = av_clip(((model->coeff_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254); + return 0; } static void vp5_parse_coeff(VP56Context *s) diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 74fe5ff5f4..ebfd00634c 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -537,7 +537,8 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, s->mb_type = VP56_MB_INTER_NOVEC_PF; } - s->parse_coeff_models(s); + if (s->parse_coeff_models(s)) + goto next; memset(s->prev_dc, 0, sizeof(s->prev_dc)); s->prev_dc[1][VP56_FRAME_CURRENT] = 128; @@ -601,6 +602,7 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } } + next: if (p->key_frame || golden_frame) { if (s->framep[VP56_FRAME_GOLDEN]->data[0] && s->framep[VP56_FRAME_GOLDEN] != s->framep[VP56_FRAME_GOLDEN2]) diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 89eba0563e..ad5849ac17 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -41,7 +41,7 @@ typedef void (*VP56Filter)(VP56Context *s, uint8_t *dst, uint8_t *src, typedef void (*VP56ParseCoeff)(VP56Context *s); typedef void (*VP56DefaultModelsInit)(VP56Context *s); typedef void (*VP56ParseVectorModels)(VP56Context *s); -typedef void (*VP56ParseCoeffModels)(VP56Context *s); +typedef int (*VP56ParseCoeffModels)(VP56Context *s); typedef int (*VP56ParseHeader)(VP56Context *s, const uint8_t *buf, int buf_size, int *golden_frame); diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index b9d86e3154..98befe6a8b 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -233,7 +233,7 @@ static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[], FF_HUFFMAN_FLAG_HNODE_FIRST); } -static void vp6_parse_coeff_models(VP56Context *s) +static int vp6_parse_coeff_models(VP56Context *s) { VP56RangeCoder *c = &s->c; VP56Model *model = s->modelp; @@ -278,15 +278,18 @@ static void vp6_parse_coeff_models(VP56Context *s) if (s->use_huffman) { for (pt=0; pt<2; pt++) { - vp6_build_huff_tree(s, model->coeff_dccv[pt], - vp6_huff_coeff_map, 12, &s->dccv_vlc[pt]); - vp6_build_huff_tree(s, model->coeff_runv[pt], - vp6_huff_run_map, 9, &s->runv_vlc[pt]); + if (vp6_build_huff_tree(s, model->coeff_dccv[pt], + vp6_huff_coeff_map, 12, &s->dccv_vlc[pt])) + return -1; + if (vp6_build_huff_tree(s, model->coeff_runv[pt], + vp6_huff_run_map, 9, &s->runv_vlc[pt])) + return -1; for (ct=0; ct<3; ct++) for (cg = 0; cg < 6; cg++) - vp6_build_huff_tree(s, model->coeff_ract[pt][ct][cg], - vp6_huff_coeff_map, 12, - &s->ract_vlc[pt][ct][cg]); + if (vp6_build_huff_tree(s, model->coeff_ract[pt][ct][cg], + vp6_huff_coeff_map, 12, + &s->ract_vlc[pt][ct][cg])) + return -1; } memset(s->nb_null, 0, sizeof(s->nb_null)); } else { @@ -296,6 +299,7 @@ static void vp6_parse_coeff_models(VP56Context *s) for (node=0; node<5; node++) model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255); } + return 0; } static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect) From e28bb18fdc894dfdc1befa9f5e748ccb649a8c76 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Fri, 23 Sep 2011 22:36:11 +0200 Subject: [PATCH 209/301] vp6: Reset the internal state when aborting key frames header parsing It prevents leaving the state only half initialized. Signed-off-by: Janne Grunau (cherry picked from commit a72cad0a6c05aa74940101e937cb3dc602d7d67b) Signed-off-by: Reinhard Tartler (cherry picked from commit c76505e0dee0890e39636ddebd2707ab3ea5b8de) Signed-off-by: Reinhard Tartler --- libavcodec/vp6.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 98befe6a8b..955a6e9fd5 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -136,8 +136,11 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, if (coeff_offset) { buf += coeff_offset; buf_size -= coeff_offset; - if (buf_size < 0) + if (buf_size < 0) { + if (s->framep[VP56_FRAME_CURRENT]->key_frame) + avcodec_set_dimensions(s->avctx, 0, 0); return 0; + } if (s->use_huffman) { s->parse_coeff = vp6_parse_coeff_huffman; init_get_bits(&s->gb, buf, buf_size<<3); From 8d68083298e2481669de4db0b7b86c915119df6d Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 3 Nov 2011 15:55:52 -0700 Subject: [PATCH 210/301] vp6: Fix illegal read. (cherry picked from commit 2a6eb06254df79e96b3d791b6b89b2534ced3119) Signed-off-by: Reinhard Tartler (cherry picked from commit 67a7ed623b678a84c992dd7bf3e3d0329f83621b) Signed-off-by: Reinhard Tartler --- libavcodec/vp6.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 955a6e9fd5..87834cd5c4 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -373,7 +373,7 @@ static void vp6_parse_coeff_huffman(VP56Context *s) if (b > 3) pt = 1; vlc_coeff = &s->dccv_vlc[pt]; - for (coeff_idx=0; coeff_idx<64; ) { + for (coeff_idx = 0;;) { int run = 1; if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) { s->nb_null[coeff_idx][pt]--; @@ -410,6 +410,8 @@ static void vp6_parse_coeff_huffman(VP56Context *s) } } coeff_idx+=run; + if (coeff_idx >= 64) + break; cg = FFMIN(vp6_coeff_groups[coeff_idx], 3); vlc_coeff = &s->ract_vlc[pt][ct][cg]; } From 94aacaf5083313378c6105bd71db04ce8f62c058 Mon Sep 17 00:00:00 2001 From: Thierry Foucu Date: Thu, 17 Nov 2011 09:39:52 -0800 Subject: [PATCH 211/301] vp6: Fix illegal read. Found with Address Sanitizer Signed-off-by: Alex Converse (cherry picked from commit e0966eb140b3569b3d6b5b5008961944ef229c06) Signed-off-by: Reinhard Tartler (cherry picked from commit ba4b08b78918f399f9c9524750b26e904d146078) Signed-off-by: Reinhard Tartler --- libavcodec/vp6.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 87834cd5c4..1fe24cf28c 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -439,7 +439,8 @@ static void vp6_parse_coeff(VP56Context *s) model1 = model->coeff_dccv[pt]; model2 = model->coeff_dcct[pt][ctx]; - for (coeff_idx=0; coeff_idx<64; ) { + coeff_idx = 0; + for (;;) { if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) { /* parse a coeff */ if (vp56_rac_get_prob(c, model2[2])) { @@ -480,8 +481,10 @@ static void vp6_parse_coeff(VP56Context *s) run += vp56_rac_get_prob(c, model3[i+8]) << i; } } - - cg = vp6_coeff_groups[coeff_idx+=run]; + coeff_idx += run; + if (coeff_idx >= 64) + break; + cg = vp6_coeff_groups[coeff_idx]; model1 = model2 = model->coeff_ract[pt][ct][cg]; } From 8ddc0b491d3c9c11c1e3d638fda51b4b604d32f4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 18 Nov 2011 19:10:21 +0100 Subject: [PATCH 212/301] svq1dec: call avcodec_set_dimensions() after dimensions changed. Fixes NGS00148, CVE-2011-4579 Found-by: Phillip Langlois Signed-off-by: Michael Niedermayer (cherry picked from commit 6e24b9488e67849a28e64a8056e05f83cf439229) Signed-off-by: Reinhard Tartler (cherry picked from commit 0eca0da06e40b73af495cc05fbcfaa030fcf78ea) Signed-off-by: Reinhard Tartler --- libavcodec/svq1dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index 2aa28ab0b0..8c6f0c8f62 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -678,6 +678,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, #endif return result; } + avcodec_set_dimensions(avctx, s->width, s->height); //FIXME this avoids some confusion for "B frames" without 2 references //this should be removed after libavcodec can handle more flexible picture types & ordering From bd071de29ae33a0ea99fd52793394a377ca61589 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 4 Dec 2011 10:10:33 +0100 Subject: [PATCH 213/301] vp3dec: Check coefficient index in vp3_dequant() Based on a patch by Michael Niedermayer Fixes NGS00145, CVE-2011-4352 Found-by: Phillip Langlois Signed-off-by: Reinhard Tartler (cherry picked from commit 8b94df0f2047e9728cb872adc9e64557b7a5152f) Signed-off-by: Reinhard Tartler (cherry picked from commit bba709214a51ffd665a67404d3beb3727bb3f319) Signed-off-by: Reinhard Tartler --- libavcodec/vp3.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index c08de6ca2c..fe8af86440 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1285,6 +1285,10 @@ static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag, case 1: // zero run s->dct_tokens[plane][i]++; i += (token >> 2) & 0x7f; + if (i > 63) { + av_log(s->avctx, AV_LOG_ERROR, "Coefficient index overflow\n"); + return i; + } block[perm[i]] = (token >> 9) * dequantizer[perm[i]]; i++; break; @@ -1458,7 +1462,10 @@ static void render_slice(Vp3DecodeContext *s, int slice) /* invert DCT and place (or add) in final output */ if (s->all_fragments[i].coding_method == MODE_INTRA) { - vp3_dequant(s, s->all_fragments + i, plane, 0, block); + int index; + index = vp3_dequant(s, s->all_fragments + i, plane, 0, block); + if (index > 63) + continue; if(s->avctx->idct_algo!=FF_IDCT_VP3) block[0] += 128<<3; s->dsp.idct_put( @@ -1466,7 +1473,10 @@ static void render_slice(Vp3DecodeContext *s, int slice) stride, block); } else { - if (vp3_dequant(s, s->all_fragments + i, plane, 1, block)) { + int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block); + if (index > 63) + continue; + if (index > 0) { s->dsp.idct_add( output_plane + first_pixel, stride, From ca87ec53e9c7fb5d79847e8d8fc33553d2d52310 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 1 Dec 2011 18:48:33 +0100 Subject: [PATCH 214/301] swscale: #include "libavutil/mathematics.h" this file uses the M_PI macro since 4e74187db2f5db52f88729efc662df9d6bc763e1, so include the correct header directly. Signed-off-by: Reinhard Tartler (cherry picked from commit 5089ce1b5abe2ecbbfd7235aeb0ad47ba38305c1) Signed-off-by: Reinhard Tartler (cherry picked from commit 851098c9e004b2ce294b687cb18633b038dcc3fe) Conflicts: libswscale/utils.c --- libswscale/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libswscale/utils.c b/libswscale/utils.c index d7a6ea25b0..2629b3590b 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -42,6 +42,7 @@ #include "libavutil/x86_cpu.h" #include "libavutil/avutil.h" #include "libavutil/bswap.h" +#include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" unsigned swscale_version(void) From 92b964969b228799fded70827d8b78044aff5019 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 22 Nov 2011 13:37:52 -0500 Subject: [PATCH 215/301] wma: initialize prev_block_len_bits, next_block_len_bits, and block_len_bits. The initial values are not checked against the number of block sizes. Initializing them to frame_len_bits will result in a block size index of 0 in these cases instead of something that might be out-of-range. Fixes Bug 81. (cherry picked from commit 05d1e45d1f42cc90d1f2f36c546d0096cea126a8) Signed-off-by: Reinhard Tartler (cherry picked from commit 8dba5608dcf76032d8a9aa4bd8a3fc1392682281) Signed-off-by: Reinhard Tartler --- libavcodec/wma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/wma.c b/libavcodec/wma.c index 65780459aa..45d431a2b1 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -135,6 +135,9 @@ int ff_wma_init(AVCodecContext *avctx, int flags2) /* compute MDCT block size */ s->frame_len_bits = ff_wma_get_frame_len_bits(s->sample_rate, s->version, 0); + s->next_block_len_bits = s->frame_len_bits; + s->prev_block_len_bits = s->frame_len_bits; + s->block_len_bits = s->frame_len_bits; s->frame_len = 1 << s->frame_len_bits; if (s->use_variable_block_len) { From ccd2ca02463df0d9e5246758676b0ca52fcc2fb8 Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Wed, 14 Dec 2011 18:29:21 +0530 Subject: [PATCH 216/301] 4xm: Add a check in decode_i_frame to prevent buffer overreads Fixes bugzilla #135 Signed-off-by: Janne Grunau (cherry picked from commit 355d917c0bd8163a3f1c7d4a6866dac749efdb84) Signed-off-by: Reinhard Tartler (cherry picked from commit d912a30c7d5cf9b8fdb26402804c9b0f999b4ff1) Signed-off-by: Reinhard Tartler --- libavcodec/4xm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 219850302c..f6e50e9d5c 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -641,9 +641,18 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){ uint16_t *dst= (uint16_t*)f->current_picture.data[0]; const int stride= f->current_picture.linesize[0]>>1; const unsigned int bitstream_size= AV_RL32(buf); - const int token_count av_unused = AV_RL32(buf + bitstream_size + 8); - unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4); - const uint8_t *prestream= buf + bitstream_size + 12; + int token_count av_unused; + unsigned int prestream_size; + const uint8_t *prestream; + + if (length < bitstream_size + 12) { + av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n"); + return AVERROR_INVALIDDATA; + } + + token_count = AV_RL32(buf + bitstream_size + 8); + prestream_size = 4 * AV_RL32(buf + bitstream_size + 4); + prestream = buf + bitstream_size + 12; if(prestream_size + bitstream_size + 12 != length || bitstream_size > (1<<26) From b26c1a8b7ed1a199b19f92bb5d62c61f1c149215 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Fri, 19 Nov 2010 06:52:30 +0000 Subject: [PATCH 217/301] Fix qdm2 decoder packet handling to match the api Originally committed as revision 25767 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/qdm2.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index ec33c492f4..93f72ceda5 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1890,7 +1890,7 @@ static av_cold int qdm2_decode_close(AVCodecContext *avctx) } -static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) +static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) { int ch, i; const int frame_size = (q->frame_size * q->channels); @@ -1926,7 +1926,7 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) { SAMPLES_NEEDED_2("has errors, and C list is not empty") - return; + return -1; } } @@ -1947,6 +1947,8 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) out[i] = value; } + + return 0; } @@ -1957,25 +1959,26 @@ static int qdm2_decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; QDM2Context *s = avctx->priv_data; + int16_t *out = data; + int i; if(!buf) return 0; if(buf_size < s->checksum_size) return -1; - *data_size = s->channels * s->frame_size * sizeof(int16_t); - av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n", buf_size, buf, s->checksum_size, data, *data_size); - qdm2_decode(s, buf, data); - - // reading only when next superblock found - if (s->sub_packet == 0) { - return s->checksum_size; + for (i = 0; i < 16; i++) { + if (qdm2_decode(s, buf, out) < 0) + return -1; + out += s->channels * s->frame_size; } - return 0; + *data_size = (uint8_t*)out - (uint8_t*)data; + + return buf_size; } AVCodec qdm2_decoder = From cfb9b47a1ecdc9e88e6561aa213d98245ee70267 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 14 Sep 2011 13:57:04 -0400 Subject: [PATCH 218/301] qdm2: check output buffer size before decoding (cherry picked from commit 7d49f79f1cd47783a963a757a6563b9cac29db62) Signed-off-by: Reinhard Tartler (cherry picked from commit 73472053516f82b7d273a3d42c583f894077a191) Conflicts: libavcodec/qdm2.c --- libavcodec/qdm2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 93f72ceda5..839e3fe1bf 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1960,13 +1960,20 @@ static int qdm2_decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; QDM2Context *s = avctx->priv_data; int16_t *out = data; - int i; + int i, out_size; if(!buf) return 0; if(buf_size < s->checksum_size) return -1; + out_size = 16 * s->channels * s->frame_size * + av_get_bits_per_sample_format(avctx->sample_fmt)/8; + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n", buf_size, buf, s->checksum_size, data, *data_size); @@ -1976,7 +1983,7 @@ static int qdm2_decode_frame(AVCodecContext *avctx, out += s->channels * s->frame_size; } - *data_size = (uint8_t*)out - (uint8_t*)data; + *data_size = out_size; return buf_size; } From dbe7e209df03c18eabdc29f87b73bbc4e3430d20 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 24 Dec 2011 15:59:10 +0100 Subject: [PATCH 219/301] Bump version number for 0.6.4 release. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 844f6a91ac..d2b13eb644 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.3 +0.6.4 From 6b156c45638ceb2e076586b7efeb4cf9e04e0a84 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 25 Dec 2011 09:41:03 +0100 Subject: [PATCH 220/301] Release notes and changelog for 0.6.4 --- Changelog | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ RELEASE | 18 +++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/Changelog b/Changelog index f0d163bb36..7e9ce5dc15 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,65 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.4: +- 4xm: Add a check in decode_i_frame to prevent buffer overreads +- wma: initialize prev_block_len_bits, next_block_len_bits, and block_len_bits. +- swscale: #include "libavutil/mathematics.h" +- vp3dec: Check coefficient index in vp3_dequant() (CVE-2011-4352) +- svq1dec: call avcodec_set_dimensions() after dimensions changed. (CVE-2011-4579) +- commits related to CVE-2011-4353: + - vp6: Fix illegal read. + - vp6: Reset the internal state when aborting key frames header parsing + - vp6: Check for huffman tree build errors + - vp6: partially propagate huffman tree building errors during coeff model parsing and fix misspelling +- commits related to CVE-2011-4351: + - qdm2: check output buffer size before decoding + - Fix qdm2 decoder packet handling to match the api + - Fix out of bound reads in the QDM2 decoder. + - Check for out of bound writes in the QDM2 decoder. +- vmd: fix segfaults on corruped streams (CVE-2011-4364) +- rv34: Check for invalid slice offsets +- rv34: Fix potential overreads +- rv34: Avoid NULL dereference on corrupted bitstream +- rv10: Reject slices that does not have the same type as the first one +- oggdec: fix out of bound write in the ogg demuxer +- smacker: fix a few off by 1 errors +- Check for invalid VLC value in smacker decoder. +- Check and propagate errors when VLC trees cannot be built in smacker decoder. +- Fixed off by one packet size allocation in the smacker demuxer. +- Check for invalid packet size in the smacker demuxer. +- ape demuxer: fix segfault on memory allocation failure. +- Fixed size given to init_get_bits() in xan decoder. +- smacker demuxer: handle possible av_realloc() failure. +- Fixed segfault with wavpack decoder on corrupted decorrelation terms sub-blocks. +- indeo2: fail if input buffer too small +- indeo2: init_get_bits size in bits instead of bytes +- wavpack: Check error codes rather than working around error conditions. +- Fixed invalid writes and reads in wavpack decoder on corrupted bitstreams. +- cpu detection: avoid a signed overflow +- h264: correct implicit weight table computation for long ref pics +- h264: correct the check for invalid long term frame index in MMCO decode +- rv10/20: tell decoder to use edge emulation +- flvenc: use int64_t to store offsets +- VC-1: fix reading of custom PAR. +- h264: notice memory allocation failure +- libx264: do not set pic quality if no frame is output +- mxfdec: Include FF_INPUT_BUFFER_PADDING_SIZE when allocating extradata. +- rv30: return AVERROR(EINVAL) instead of EINVAL +- Do not decode RV30 files if the extradata is too small +- aacps: skip some memcpy() if src and dst would be equal +- mpegts: fix Continuity Counter error detection +- alsa: fallback to buffer_size/4 for period_size. +- mxfenc: fix ignored drop flag in binary timecode representation. +- dca: set AVCodecContext frame_size for DTS audio +- H.264: fix overreads of qscale_table +- postprocess.c: filter name needs to be double 0 terminated +- Replace strncpy() with av_strlcpy() in libpostproc. +- jpegdec: actually search for and parse RSTn +- riff: Add mpgv MPEG-2 fourcc +- Added M701 codec_tag for mpeg2video + + version 0.6.3: - fix compilation with --enable-hardcoded-tables diff --git a/RELEASE b/RELEASE index 97f04d6ae6..8193b2877b 100644 --- a/RELEASE +++ b/RELEASE @@ -158,3 +158,21 @@ been backported from the Libav 0.7.2 release. Distributors and system integrators are encouraged to update and share their patches against this branch. For a full list of changes please see the Changelog file. + + +* 0.6.4 + +General notes +------------- + +This mostly maintenance-only release that addresses a number a number of +bugs such as security and compilation issues that have been brought to +our attention. Among other (rather minor) fixes, this release features +fixes for the QDM2 decoder (CVE-2011-4351), vp3 decoder (CVE-2011-4352), +DoS in the VP5/VP6 decoders (CVE-2011-4353), a buffer overflow in the +Sierra VMD decoder CVE-2011-4364, and a safety fix in the svq1 decoder +(CVE-2011-4579). + +Distributors and system integrators are encouraged +to update and share their patches against this branch. For a full list +of changes please see the Changelog file. From e1a2bcbec84eb687d0636a149e8f7f97069a4240 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Dec 2011 04:42:04 +0100 Subject: [PATCH 221/301] h264: fix init of topleft ref/mv. Fixes Ticket778 Signed-off-by: Michael Niedermayer (cherry picked from commit 680880c98db2817437e19c3fc7f6349261bbbbb0) --- libavcodec/h264.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index c6563af35e..72bc390ce5 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -1048,7 +1048,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ AV_ZERO32(h->mv_cache [list][scan8[0] + 4 - 1*8]); h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; } - if(h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){ + if(h->ref_cache[list][scan8[0] + 2 - 1*8] < 0 || h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){ if(USES_LIST(topleft_type, list)){ const int b_xy = h->mb2b_xy [topleft_xy] + 3 + h->b_stride + (h->topleft_partition & 2*h->b_stride); const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2); From c9c7db0af2a0fc14764a07f0e61cebf11238e3c2 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 28 Oct 2011 23:50:04 -0700 Subject: [PATCH 222/301] vp3: fix oob read for negative tokens and memleaks on error. (cherry picked from commit 8370e426e42f2e4b9d14a1fb8107ecfe5163ce7f) Fixes: #189 Chromium-Bug: 101172,100465 CVE-2011-3892 Removed the parts that are related to multi-threading, which is not included before 0.7. Signed-off-by: Reinhard Tartler (cherry picked from commit c624935554332f8921a15265b8720f0c7b3c8cc2) Conflicts: libavcodec/vp3.c --- libavcodec/vp3.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index fe8af86440..87cf03d24b 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -884,7 +884,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, /* decode a VLC into a token */ token = get_vlc2(gb, vlc_table, 11, 3); /* use the token to get a zero run, a coefficient, and an eob run */ - if (token <= 6) { + if ((unsigned) token <= 6U) { eob_run = eob_run_base[token]; if (eob_run_get_bits[token]) eob_run += get_bits(gb, eob_run_get_bits[token]); @@ -902,7 +902,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, coeff_i += eob_run; eob_run = 0; } - } else { + } else if (token >= 0) { bits_to_get = coeff_get_bits[token]; if (bits_to_get) bits_to_get = get_bits(gb, bits_to_get); @@ -936,6 +936,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb, for (i = coeff_index+1; i <= coeff_index+zero_run; i++) s->num_coded_frags[plane][i]--; coeff_i++; + } else { + av_log(s->avctx, AV_LOG_ERROR, + "Invalid token %d\n", token); + return -1; } } @@ -985,6 +989,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb) /* unpack the Y plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0, 0, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; /* reverse prediction of the Y-plane DC coefficients */ reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]); @@ -992,8 +998,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb) /* unpack the C plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 1, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 2, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; /* reverse prediction of the C-plane DC coefficients */ if (!(s->avctx->flags & CODEC_FLAG_GRAY)) @@ -1030,11 +1040,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb) for (i = 1; i <= 63; i++) { residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, 0, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 1, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 2, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; } return 0; From ae24b5ce3a955e4003c667e5ab3526ce80c71138 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Tue, 3 Jan 2012 13:38:01 +0100 Subject: [PATCH 223/301] vp3: fix streams with non-zero last coefficient Fixes a regression introduced in 8b94df0f2047e972. (cherry picked from commit 9b4767e4784577f3107730316fe652ccaccd9b3a) Signed-off-by: Reinhard Tartler (cherry picked from commit 82a11fcff24d9827070d77f1a3c6ba5d4dc12984) Signed-off-by: Reinhard Tartler --- libavcodec/vp3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 87cf03d24b..a4dd70d61f 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1316,6 +1316,8 @@ static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag, return i; } } while (i < 64); + // return value is expected to be a valid level + i--; end: // the actual DC+prediction is in the fragment structure block[0] = frag->dc * s->qmat[0][inter][plane][0]; From 6d6254ba9fbb22260939c06db1faed5bbd295ad4 Mon Sep 17 00:00:00 2001 From: Chris Evans Date: Thu, 5 Jan 2012 21:25:41 +0100 Subject: [PATCH 224/301] vorbis: Avoid some out-of-bounds reads Fixes Bug: #190 Chromium Bug: #100543 Related to CVE-2011-3893 Signed-off-by: Reinhard Tartler (cherry picked from commit 57cd6d709565e84e84385f8f2a9641ca3fa718be) Signed-off-by: Reinhard Tartler (cherry picked from commit 4a94678f1be4b7d47f862e9523ca3358255da5d4) Signed-off-by: Reinhard Tartler --- libavcodec/vorbis.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index 47388d8302..109737976c 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -156,7 +156,7 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) } } -static inline void render_line_unrolled(intptr_t x, intptr_t y, int x1, +static inline void render_line_unrolled(intptr_t x, uint8_t y, int x1, intptr_t sy, int ady, int adx, float *buf) { @@ -179,7 +179,7 @@ static inline void render_line_unrolled(intptr_t x, intptr_t y, int x1, } } -static void render_line(int x0, int y0, int x1, int y1, float *buf) +static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf) { int dy = y1 - y0; int adx = x1 - x0; @@ -189,10 +189,10 @@ static void render_line(int x0, int y0, int x1, int y1, float *buf) if (ady*2 <= adx) { // optimized common case render_line_unrolled(x0, y0, x1, sy, ady, adx, buf); } else { - int base = dy / adx; - int x = x0; - int y = y0; - int err = -adx; + int base = dy / adx; + int x = x0; + uint8_t y = y0; + int err = -adx; ady -= FFABS(base) * adx; while (++x < x1) { y += base; @@ -210,7 +210,8 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint_fast16_t *y_list, int *flag, int multiplier, float *out, int samples) { - int lx, ly, i; + int lx, i; + uint8_t ly; lx = 0; ly = y_list[0] * multiplier; for (i = 1; i < values; i++) { From 90a4a467477be8c292daa08a9516ee78ca0d517b Mon Sep 17 00:00:00 2001 From: Chris Evans Date: Thu, 5 Jan 2012 21:19:30 +0100 Subject: [PATCH 225/301] matroskadec: Fix a bug where a pointer was cached to an array that might later move due to a realloc() Fixes bug #190 Chromium bug #100492 related to CVE-2011-3893 Signed-off-by: Reinhard Tartler (cherry-picked from commit faaec4676cb4c7a2303d50df66c6290bc96a7657) Signed-off-by: Reinhard Tartler (cherry picked from commit 1f625431e2bb9564760fba3ab8077ae07ce7c7a1) Signed-off-by: Reinhard Tartler --- libavformat/matroskadec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 9745585ca5..ab42e0a70e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1074,13 +1074,13 @@ static void matroska_convert_tags(AVFormatContext *s) static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) { EbmlList *seekhead_list = &matroska->seekhead; - MatroskaSeekhead *seekhead = seekhead_list->elem; uint32_t level_up = matroska->level_up; int64_t before_pos = url_ftell(matroska->ctx->pb); MatroskaLevel level; int i; for (i=0; inb_elem; i++) { + MatroskaSeekhead *seekhead = seekhead_list->elem; int64_t offset = seekhead[i].pos + matroska->segment_start; if (seekhead[i].pos <= before_pos From b945f558c797b623733c319c9b68639be0a2c391 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 2 Jan 2012 15:27:43 +0100 Subject: [PATCH 226/301] vp3: fix regression with mplayer-crash.ogv Signed-off-by: Michael Niedermayer (cherry picked from commit a2a12e3358c3bbdc0246ffc94973e58eba50ee30) Signed-off-by: Michael Niedermayer --- libavcodec/vp3.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index fe8af86440..99842e07c7 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1462,10 +1462,7 @@ static void render_slice(Vp3DecodeContext *s, int slice) /* invert DCT and place (or add) in final output */ if (s->all_fragments[i].coding_method == MODE_INTRA) { - int index; - index = vp3_dequant(s, s->all_fragments + i, plane, 0, block); - if (index > 63) - continue; + vp3_dequant(s, s->all_fragments + i, plane, 0, block); if(s->avctx->idct_algo!=FF_IDCT_VP3) block[0] += 128<<3; s->dsp.idct_put( @@ -1473,10 +1470,7 @@ static void render_slice(Vp3DecodeContext *s, int slice) stride, block); } else { - int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block); - if (index > 63) - continue; - if (index > 0) { + if (vp3_dequant(s, s->all_fragments + i, plane, 1, block)) { s->dsp.idct_add( output_plane + first_pixel, stride, From 42f0a6696889ba275aa2087b57fa99f7a97033a0 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 5 Jan 2012 21:40:18 +0100 Subject: [PATCH 227/301] vorbisdec: Fix decoding bug with channel handling Fixes Bug: #191 Chromium Bug: #101458 CVE-2011-3895 Signed-off-by: Reinhard Tartler (cherry picked from commit e6d527ff729e42d80e4756cab779ff4ad693631b) Signed-off-by: Reinhard Tartler (cherry picked from commit 97f23c72a3815739ab28e297ce60f943349f6939) Conflicts: libavcodec/vorbis_dec.c --- libavcodec/vorbis_dec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index f8067db41c..4910860167 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -656,7 +656,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) res_setup->partition_size = get_bits(gb, 24) + 1; /* Validations to prevent a buffer overflow later. */ if (res_setup->begin>res_setup->end || - res_setup->end>vc->blocksize[1] / (res_setup->type == 2 ? 1 : 2) || + res_setup->end > (res_setup->type == 2 ? vc->avccontext->channels : 1) * vc->blocksize[1] / 2 || (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) { av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2); return -1; @@ -1473,6 +1473,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) uint_fast8_t res_num = 0; int_fast16_t retlen = 0; float fadd_bias = vc->add_bias; + int ch_left = vc->audio_channels; if (get_bits1(gb)) { av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n"); @@ -1546,9 +1547,14 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) } } residue = &vc->residues[mapping->submap_residue[i]]; + if (ch_left < ch) { + av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n"); + return -1; + } vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2); ch_res_ptr += ch * blocksize / 2; + ch_left -= ch; } // Inverse coupling From a5e0afe3c936220a793db0cdae04bb228f1904e0 Mon Sep 17 00:00:00 2001 From: Chris Evans Date: Thu, 5 Jan 2012 21:25:41 +0100 Subject: [PATCH 228/301] vorbis: An additional defense in the Vorbis codec. Fixes Bug: #190 Chromium Bug: #100543 Related to CVE-2011-3893 Signed-off-by: Reinhard Tartler (cherry picked from commit afb2aa537954db537d54358997b68f46561fd5a7) Signed-off-by: Reinhard Tartler (cherry picked from commit b0283ccb9e8945ce9e56f7c6ba0c676e7179d7a3) Conflicts: libavcodec/vorbis_dec.c --- libavcodec/vorbis_dec.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index 4910860167..e5ad4aaae3 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -1262,6 +1262,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, + unsigned ch_left, int vr_type) { GetBitContext *gb = &vc->gb; @@ -1273,6 +1274,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, uint_fast8_t ch_used; uint_fast8_t i,j,l; uint_fast16_t k; + unsigned max_output = (ch - 1) * vlen; if (vr_type == 2) { for (j = 1; j < ch; ++j) @@ -1280,8 +1282,15 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, if (do_not_decode[0]) return 0; ch_used = 1; + max_output += vr->end / ch; } else { ch_used = ch; + max_output += vr->end; + } + + if (max_output > ch_left * vlen) { + av_log(vc->avccontext, AV_LOG_ERROR, "Insufficient output buffer\n"); + return -1; } AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c); @@ -1403,14 +1412,16 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, - float *vec, uint_fast16_t vlen) + float *vec, uint_fast16_t vlen, + unsigned ch_left) + { if (vr->type == 2) - return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2); + return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 2); else if (vr->type == 1) - return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1); + return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 1); else if (vr->type == 0) - return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0); + return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 0); else { av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n"); return -1; @@ -1473,7 +1484,8 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) uint_fast8_t res_num = 0; int_fast16_t retlen = 0; float fadd_bias = vc->add_bias; - int ch_left = vc->audio_channels; + unsigned ch_left = vc->audio_channels; + unsigned vlen; if (get_bits1(gb)) { av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n"); @@ -1492,11 +1504,12 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) blockflag = vc->modes[mode_number].blockflag; blocksize = vc->blocksize[blockflag]; + vlen = blocksize / 2; if (blockflag) skip_bits(gb, 2); // previous_window, next_window - memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2); //FIXME can this be removed ? - memset(ch_floor_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2); //FIXME can this be removed ? + memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * vlen); //FIXME can this be removed ? + memset(ch_floor_ptr, 0, sizeof(float) * vc->audio_channels * vlen); //FIXME can this be removed ? // Decode floor @@ -1516,7 +1529,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) return -1; } no_residue[i] = ret; - ch_floor_ptr += blocksize / 2; + ch_floor_ptr += vlen; } // Nonzero vector propagate @@ -1533,6 +1546,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) for (i = 0; i < mapping->submaps; ++i) { vorbis_residue *residue; uint_fast8_t ch = 0; + int ret; for (j = 0; j < vc->audio_channels; ++j) { if ((mapping->submaps == 1) || (i == mapping->mux[j])) { @@ -1551,9 +1565,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n"); return -1; } - vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2); + if (ch) { + ret = vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, vlen, ch_left); + if (ret < 0) + return ret; + } - ch_res_ptr += ch * blocksize / 2; + ch_res_ptr += ch * vlen; ch_left -= ch; } From 7efa13b4b49128f9660d2c4a6b9aa5da357b4720 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 10 Jan 2012 21:02:32 +0100 Subject: [PATCH 229/301] Bump version number for 0.6.5 release. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d2b13eb644..ef5e445445 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.4 +0.6.5 From 62c473934822afd317dfef27754a0ff71f58ce2a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 10 Jan 2012 21:03:20 +0100 Subject: [PATCH 230/301] Release notes and changelog for 0.6.5 --- Changelog | 10 ++++++++++ RELEASE | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Changelog b/Changelog index 7e9ce5dc15..11a554b28c 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,16 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.5: +- vorbis: An additional defense in the Vorbis codec. (CVE-2011-3895) +- vorbisdec: Fix decoding bug with channel handling. +- matroskadec: Fix a bug where a pointer was cached to an array that might + later move due to a realloc(). (CVE-2011-3893) +- vorbis: Avoid some out-of-bounds reads. (CVE-2011-3893) +- vp3: fix oob read for negative tokens and memleaks on error, (CVE-2011-3892) +- vp3: fix streams with non-zero last coefficient. + + version 0.6.4: - 4xm: Add a check in decode_i_frame to prevent buffer overreads - wma: initialize prev_block_len_bits, next_block_len_bits, and block_len_bits. diff --git a/RELEASE b/RELEASE index 8193b2877b..cd18270ca4 100644 --- a/RELEASE +++ b/RELEASE @@ -176,3 +176,19 @@ Sierra VMD decoder CVE-2011-4364, and a safety fix in the svq1 decoder Distributors and system integrators are encouraged to update and share their patches against this branch. For a full list of changes please see the Changelog file. + + +* 0.6.5 + +General notes +------------- + +This mostly maintenance-only release that addresses a number a number of +bugs such as security and compilation issues that have been brought to +our attention. Among other (rather minor) fixes, this release features +fixes for the VP3 decoder (CVE-2011-3892), vorbis decoder, and matroska +demuxer (CVE-2011-3893 and CVE-2011-3895). + +Distributors and system integrators are encouraged +to update and share their patches against this branch. For a full list +of changes please see the Changelog file. From 431cf16963fccd28051ee81e82d8dff1acac30dd Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 15 Dec 2011 02:43:03 +0100 Subject: [PATCH 231/301] h264: check chroma_format_idc range. Fixes Ticket758 Bug found by: Diana Elena Muscalu Signed-off-by: Michael Niedermayer (cherry picked from commit 7fff64e00d886fde11d61958888c82b461cf99b9) Signed-off-by: Michael Niedermayer --- libavcodec/h264_ps.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 7648e2c7a6..351d52b6c0 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -297,6 +297,10 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ if(sps->profile_idc >= 100){ //high profile sps->chroma_format_idc= get_ue_golomb_31(&s->gb); + if (sps->chroma_format_idc > 3U) { + av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc %d is illegal\n", sps->chroma_format_idc); + goto fail; + } if(sps->chroma_format_idc == 3) sps->residual_color_transform_flag = get_bits1(&s->gb); sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8; From 1014e20492d529ba165227a5376d9199a4e24175 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Dec 2011 03:18:58 +0100 Subject: [PATCH 232/301] atrac3: Fix crash in tonal component decoding. Fixes Ticket780 Bug Found by: cosminamironesei Signed-off-by: Michael Niedermayer (cherry picked from commit 9af6abdc17deb95c9b1f1d9242ba49b8b5e0b016) Signed-off-by: Michael Niedermayer --- libavcodec/atrac3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 5179c345cf..49f70d2516 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -393,6 +393,8 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent for (k=0; k=64) + return AVERROR_INVALIDDATA; pComponent[component_count].pos = j * 64 + (get_bits(gb,6)); max_coded_values = 1024 - pComponent[component_count].pos; coded_values = coded_values_per_component + 1; From f70c720d42d0e222b70fc580a36832a7b0ef89fa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 31 Mar 2012 07:52:42 +0200 Subject: [PATCH 233/301] id3v2: fix skipping extended header in id3v2.4 In v2.4, the length includes the length field itself. (cherry picked from commit ddb4431208745ea270dce8fce4cba999f0ed4303) Conflicts: libavformat/id3v2.c Signed-off-by: Anton Khirnov --- libavformat/id3v2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 6fa11db6c0..8c1c0710e7 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -187,8 +187,17 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) goto error; } - if (isv34 && flags & 0x40) /* Extended header present, just skip over it */ - url_fskip(s->pb, get_size(s->pb, 4)); + if (isv34 && flags & 0x40) { /* Extended header present, just skip over it */ + int extlen = get_size(s->pb, 4); + if (version == 4) + extlen -= 4; // in v2.4 the length includes the length field we just read + + if (extlen < 0) { + reason = "invalid extended header length"; + goto error; + } + url_fskip(s->pb, extlen); + } while (len >= taghdrlen) { if (isv34) { From b56606e6bc1156f0edf5fca53216481ebde48630 Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Thu, 22 Mar 2012 19:28:52 +0100 Subject: [PATCH 234/301] Replace SSE2 instruction in scalarproduct_float_sse() by SSE equivalent. Fixes an AAC decoding issue with the sample from ticket #213 on machines with SSE but without SSE2. Based on 89411a by Reimar. (cherry picked from commit f6b78638086beae9bcab672d4c9de1790be5a928) --- libavcodec/x86/dsputil_yasm.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index e2478a4845..1a3bd1ae66 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -417,7 +417,7 @@ cglobal scalarproduct_float_sse, 3,3,2, v1, v2, offset shufps xmm0, xmm0, 1 addss xmm0, xmm1 %ifndef ARCH_X86_64 - movd r0m, xmm0 + movss r0m, xmm0 fld dword r0m %endif RET From 1edf848a81464afd514afbbbcb97b471d334e14a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 24 Jan 2012 22:20:26 +0100 Subject: [PATCH 235/301] nsvdec: Fix use of uninitialized streams. Fixes CVE-2011-3940 (Out of bounds read resulting in out of bounds write) Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit 5c011706bc752d34bc6ada31d7df2ca0c9af7c6b) Signed-off-by: Alex Converse (cherry picked from commit 6a89b41d9780325ba6d89a37f2aeb925aa68e6a3) Signed-off-by: Reinhard Tartler (cherry picked from commit 65beb8c1173906b0541442713cb29e8ba44c47ef) Signed-off-by: Reinhard Tartler --- libavformat/nsvdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 44e5097d59..3a14cfa22c 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -609,12 +609,12 @@ null_chunk_retry: } /* map back streams to v,a */ - if (s->streams[0]) + if (s->nb_streams > 0) st[s->streams[0]->id] = s->streams[0]; - if (s->streams[1]) + if (s->nb_streams > 1) st[s->streams[1]->id] = s->streams[1]; - if (vsize/* && st[NSV_ST_VIDEO]*/) { + if (vsize && st[NSV_ST_VIDEO]) { nst = st[NSV_ST_VIDEO]->priv_data; pkt = &nsv->ahead[NSV_ST_VIDEO]; av_get_packet(pb, pkt, vsize); @@ -629,7 +629,7 @@ null_chunk_retry: if(st[NSV_ST_VIDEO]) ((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++; - if (asize/*st[NSV_ST_AUDIO]*/) { + if (asize && st[NSV_ST_AUDIO]) { nst = st[NSV_ST_AUDIO]->priv_data; pkt = &nsv->ahead[NSV_ST_AUDIO]; /* read raw audio specific header on the first audio chunk... */ From 87007519c81c37d8a3de424de3db14078ae84333 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 17:21:46 -0800 Subject: [PATCH 236/301] nsvdec: Be more careful with av_malloc(). Check results for av_malloc() and fix an overflow in one call. Related to CVE-2011-3940. Based in part on work from Michael Niedermayer. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind (cherry picked from commit 8fd8a48263ff1437f9d02d7e78dc63efb9b5ed3a) Signed-off-by: Reinhard Tartler (cherry picked from commit be524c186b50337db64d34a5726dfe3e8ea94f09) Signed-off-by: Reinhard Tartler --- libavformat/nsvdec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 3a14cfa22c..beeb73911f 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -319,7 +319,9 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap) char *token, *value; char quote; - p = strings = av_mallocz(strings_size + 1); + p = strings = av_mallocz((size_t)strings_size + 1); + if (!p) + return AVERROR(ENOMEM); endp = strings + strings_size; get_buffer(pb, strings, strings_size); while (p < endp) { @@ -354,6 +356,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap) if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t)) return -1; nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t)); + if (!nsv->nsvs_file_offset) + return AVERROR(ENOMEM); for(i=0;insvs_file_offset[i] = get_le32(pb) + size; @@ -361,6 +365,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap) if(table_entries > table_entries_used && get_le32(pb) == MKTAG('T','O','C','2')) { nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t)); + if (!nsv->nsvs_timestamps) + return AVERROR(ENOMEM); for(i=0;insvs_timestamps[i] = get_le32(pb); } From 3253dd2b420583a7f10afa87e47b9cb73e950e2a Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 17:23:09 -0800 Subject: [PATCH 237/301] nsvdec: Propagate errors Related to CVE-2011-3940. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind (cherry picked from commit c898431ca5ef2a997fe9388b650f658fb60783e5) Conflicts: libavformat/nsvdec.c Signed-off-by: Reinhard Tartler (cherry picked from commit 0100c4b1b0736e0f5b3c98f9b0ab8acbef574888) Signed-off-by: Reinhard Tartler --- libavformat/nsvdec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index beeb73911f..169e95e321 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -536,11 +536,16 @@ static int nsv_read_header(AVFormatContext *s, AVFormatParameters *ap) for (i = 0; i < NSV_MAX_RESYNC_TRIES; i++) { if (nsv_resync(s) < 0) return -1; - if (nsv->state == NSV_FOUND_NSVF) + if (nsv->state == NSV_FOUND_NSVF) { err = nsv_parse_NSVf_header(s, ap); + if (err < 0) + return err; + } /* we need the first NSVs also... */ if (nsv->state == NSV_FOUND_NSVS) { err = nsv_parse_NSVs_header(s, ap); + if (err < 0) + return err; break; /* we just want the first one */ } } From 38421f27b3899a930552750fe1e0dffd45b71b8e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 24 Jan 2012 17:48:23 +0100 Subject: [PATCH 238/301] dv: check stype dv: check stype Fixes part1 of CVE-2011-3929 Possibly fixes part of CVE-2011-3936 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Reviewed-by: Roman Shaposhnik Signed-off-by: Michael Niedermayer Signed-off-by: Alex Converse (cherry picked from commit 635bcfccd439480003b74a665b5aa7c872c1ad6b) Signed-off-by: Reinhard Tartler (cherry picked from commit bb737d381f6d6413899a0697f426fb082eac66fc) Signed-off-by: Reinhard Tartler --- libavformat/dv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/dv.c b/libavformat/dv.c index b6f9c6ae54..1ad224e9e1 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -202,6 +202,12 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) stype = (as_pack[3] & 0x1f); /* 0 - 2CH, 2 - 4CH, 3 - 8CH */ quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ + if (stype > 3) { + av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype); + c->ach = 0; + return 0; + } + /* note: ach counts PAIRS of channels (i.e. stereo channels) */ ach = ((int[4]){ 1, 0, 2, 4})[stype]; if (ach == 1 && quant && freq == 2) From b46141b0d1d7efb74dad172b7c1b52413441592f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 24 Jan 2012 17:51:40 +0100 Subject: [PATCH 239/301] dv: Fix null pointer dereference due to ach=0 dv: Fix null pointer dereference due to ach=0 Fixes part2 of CVE-2011-3929 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Reviewed-by: Roman Shaposhnik Signed-off-by: Michael Niedermayer Signed-off-by: Alex Converse (cherry picked from commit 5a396bb3a66a61a68b80f2369d0249729bf85e04) Signed-off-by: Reinhard Tartler (cherry picked from commit 44e182d41e3a73548f3f5e8445ec428d3846e6d6) Signed-off-by: Reinhard Tartler --- libavformat/dv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index 1ad224e9e1..92b93f7501 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -341,7 +341,8 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate; ppcm[i] = c->audio_buf[i]; } - dv_extract_audio(buf, ppcm, c->sys); + if (c->ach) + dv_extract_audio(buf, ppcm, c->sys); /* We work with 720p frames split in half, thus even frames have * channels 0,1 and odd 2,3. */ From a8f4db0acd9b588ba33e3b8c0c21feea5916cfd1 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 15:08:26 -0800 Subject: [PATCH 240/301] dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936. Found with asan. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Alex Converse (cherry picked from commit 2d1c0dea5f6b91bec7f5fa53ec050913d851e366) Signed-off-by: Reinhard Tartler (cherry picked from commit 00fa6ffe1a0b252d6a81815e51f125225cd0b97a) Signed-off-by: Reinhard Tartler --- libavformat/dv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index 92b93f7501..d65d4fffbd 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -125,10 +125,14 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], /* We work with 720p frames split in half, thus even frames have * channels 0,1 and odd 2,3. */ ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0; - pcm = ppcm[ipcm++]; /* for each DIF channel */ for (chan = 0; chan < sys->n_difchan; chan++) { + /* next stereo channel (50Mbps and 100Mbps only) */ + pcm = ppcm[ipcm++]; + if (!pcm) + break; + /* for each DIF segment */ for (i = 0; i < sys->difseg_size; i++) { frame += 6 * 80; /* skip DIF segment header */ @@ -176,11 +180,6 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ } } - - /* next stereo channel (50Mbps and 100Mbps only) */ - pcm = ppcm[ipcm++]; - if (!pcm) - break; } return size; From 224025d852dcc42f752c0922fef7121808d1e42f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Dec 2011 03:18:58 +0100 Subject: [PATCH 241/301] atrac3: Fix crash in tonal component decoding. Add a check to avoid writing past the end of the channel_unit.components[] array. Bug Found by: cosminamironesei Fixes CVE-2012-0853 CC: libav-stable@libav.org Signed-off-by: Michael Niedermayer Signed-off-by: Justin Ruggles (cherry picked from commit c509f4f74713b035a06f79cb4d00e708f5226bc5) Signed-off-by: Reinhard Tartler (cherry picked from commit f43b6e2b1ed47a1254a5d44c700a7fad5e9784be) Signed-off-by: Reinhard Tartler (cherry picked from commit f728ad26f0ec87650d2986a892785c0e2b97d161) Signed-off-by: Reinhard Tartler --- libavcodec/atrac3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 5179c345cf..8452853d7b 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -393,6 +393,8 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent for (k=0; k= 64) + return AVERROR_INVALIDDATA; pComponent[component_count].pos = j * 64 + (get_bits(gb,6)); max_coded_values = 1024 - pComponent[component_count].pos; coded_values = coded_values_per_component + 1; From 6ca010f20965ef71d97a53e871edae2eb9c05a5f Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 25 Jan 2012 13:39:24 -0800 Subject: [PATCH 242/301] mjpegbdec: Fix overflow in SOS. Based in part by a fix from Michael Niedermayer Fixes CVE-2011-3947 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind (cherry picked from commit b57d262412204e54a7ef8fa1b23ff4dcede622e5) Signed-off-by: Reinhard Tartler (cherry picked from commit 083a8a00373b12dc06b8ae4c49eec61fb5e55f4b) Signed-off-by: Reinhard Tartler (cherry picked from commit 6ae95a0b93e8df15fe5f364535a7214be0817736) Signed-off-by: Reinhard Tartler --- libavcodec/mjpegbdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index b418f5734c..324806e5e2 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -59,6 +59,9 @@ read_header: s->restart_count = 0; s->mjpb_skiptosod = 0; + if (buf_end - buf_ptr >= 1 << 28) + return AVERROR_INVALIDDATA; + init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8); skip_bits(&hgb, 32); /* reserved zeros */ @@ -109,8 +112,8 @@ read_header: av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs); if (sos_offs) { -// init_get_bits(&s->gb, buf+sos_offs, (buf_end - (buf+sos_offs))*8); - init_get_bits(&s->gb, buf_ptr+sos_offs, field_size*8); + init_get_bits(&s->gb, buf_ptr + sos_offs, + 8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs)); s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16)); s->start_code = SOS; ff_mjpeg_decode_sos(s); From 1156f07c6a82af5bd692847d2e66478a28ab1ee2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 25 Jan 2012 23:23:35 +0100 Subject: [PATCH 243/301] kgv1dec: Increase offsets array size so it is large enough. Fixes CVE-2011-3945 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit 807a045ab7f51993a2c1b3116016cbbd4f3d20d6) Signed-off-by: Alex Converse (cherry picked from commit a02e8df973f5478ec82f4c507f5b5b191a5ecb6b) (cherry picked from commit d5f2382d0389ed47a566ea536887af908bf9b14f) Signed-off-by: Reinhard Tartler (cherry picked from commit a0b65938b7cf37680a4ce0667444a217a151c551) Signed-off-by: Reinhard Tartler --- libavcodec/kgv1dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 5af6b3b2bb..494aa11b0b 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -38,7 +38,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac const uint8_t *buf = avpkt->data; const uint8_t *buf_end = buf + avpkt->size; KgvContext * const c = avctx->priv_data; - int offsets[7]; + int offsets[8]; uint16_t *out, *prev; int outcnt = 0, maxcnt; int w, h, i; @@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac return -1; c->prev = prev; - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) offsets[i] = -1; while (outcnt < maxcnt && buf_end - 2 > buf) { From 5933af562ea78b4be5d0cb0b7b7dcedd5aba6d7e Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Fri, 7 Oct 2011 18:08:55 +0200 Subject: [PATCH 244/301] motionpixels: decode only the 111 complete frames for fate Signed-off-by: Janne Grunau (cherry picked from commit c2f2dfb3dd20e036b8b08c0fd1486a3044e8f02a) Signed-off-by: Anton Khirnov (cherry picked from commit 90d7146511db0e2dd2d2b1baf2ceb7177b30dd8d) Conflicts: tests/fate.mak tests/ref/fate/motionpixels Signed-off-by: Reinhard Tartler --- tests/fate.mak | 2 +- tests/ref/fate/motionpixels | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/fate.mak b/tests/fate.mak index 933dec6348..c44de42eb2 100644 --- a/tests/fate.mak +++ b/tests/fate.mak @@ -503,7 +503,7 @@ fate-maxis-xa: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/maxis-xa/SC2KBUG.XA FATE_TESTS += fate-mimic fate-mimic: CMD = $$BUILD_PATH/ffmpeg -idct simple -i $$SAMPLES_PATH/mimic/mimic2-womanloveffmpeg.cam -vsync 0 -f framecrc - FATE_TESTS += fate-motionpixels -fate-motionpixels: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/motion-pixels/INTRO-partial.MVI -an -pix_fmt rgb24 -f framecrc - +fate-motionpixels: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/motion-pixels/INTRO-partial.MVI -an -pix_fmt rgb24 -vframes 111 -f framecrc - FATE_TESTS += fate-mpc7-demux fate-mpc7-demux: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/musepack/inside-mp7.mpc -acodec copy -f crc - FATE_TESTS += fate-mpc8-demux diff --git a/tests/ref/fate/motionpixels b/tests/ref/fate/motionpixels index e588ed3e18..fa86f7379f 100644 --- a/tests/ref/fate/motionpixels +++ b/tests/ref/fate/motionpixels @@ -109,4 +109,3 @@ 0, 648003, 230400, 0xb343f372 0, 654003, 230400, 0xf7f1e588 0, 660003, 230400, 0x9682bdb2 -0, 666003, 230400, 0x538a3db8 From e9c9707316582f5d5c4ddd46f9b5c43ca205ca87 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 2 May 2012 12:08:03 -0700 Subject: [PATCH 245/301] motionpixels: Clip YUV values after applying a gradient. Prevents illegal reads on truncated and malformed input. CC: libav-stable@libav.org (cherry picked from commit b5da848facd41169283d7bfe568b83bdfa7fc42e) Signed-off-by: Reinhard Tartler (cherry picked from commit aaa6a666774eb02c351c84e80622a5c69e9b642e) Signed-off-by: Reinhard Tartler (cherry picked from commit 50073e2395522b6e2b8698ff0dd06ffaf8cbf8ce) Signed-off-by: Reinhard Tartler --- libavcodec/motionpixels.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 9bc5e2035d..91f28cfe62 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -188,10 +188,13 @@ static void mp_decode_line(MotionPixelsContext *mp, GetBitContext *gb, int y) p = mp_get_yuv_from_rgb(mp, x - 1, y); } else { p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb)); + p.y = av_clip(p.y, 0, 31); if ((x & 3) == 0) { if ((y & 3) == 0) { p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb)); + p.v = av_clip(p.v, -32, 31); p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb)); + p.u = av_clip(p.u, -32, 31); mp->hpt[((y / 4) * mp->avctx->width + x) / 4] = p; } else { p.v = mp->hpt[((y / 4) * mp->avctx->width + x) / 4].v; @@ -215,9 +218,12 @@ static void mp_decode_frame_helper(MotionPixelsContext *mp, GetBitContext *gb) p = mp_get_yuv_from_rgb(mp, 0, y); } else { p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb)); + p.y = av_clip(p.y, 0, 31); if ((y & 3) == 0) { p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb)); + p.v = av_clip(p.v, -32, 31); p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb)); + p.u = av_clip(p.u, -32, 31); } mp->vpt[y] = p; mp_set_rgb_from_yuv(mp, 0, y, &p); From bf0ec375ef7df1d154f07a820de90f6393d22363 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 4 May 2012 10:27:03 -0700 Subject: [PATCH 246/301] celp filters: Do not read earlier than the start of the 'out' vector. CC: libav-stable@libav.org (cherry picked from commit 37ddd3833219fa7b913fff3f5cccc6878b047e6b) Signed-off-by: Reinhard Tartler (cherry picked from commit 9ea94c44b1b414ab3bc6e9220ebb77621423ca38) Signed-off-by: Reinhard Tartler (cherry picked from commit 08c81f7365af96c1655767e68d6ec85bea50600c) Signed-off-by: Reinhard Tartler --- libavcodec/celp_filters.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/celp_filters.c b/libavcodec/celp_filters.c index 26a62eed14..0f8e071735 100644 --- a/libavcodec/celp_filters.c +++ b/libavcodec/celp_filters.c @@ -133,9 +133,8 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, out2 -= val * old_out2; out3 -= val * old_out3; - old_out3 = out[-5]; - for (i = 5; i <= filter_length; i += 2) { + old_out3 = out[-i]; val = filter_coeffs[i-1]; out0 -= val * old_out3; @@ -154,7 +153,6 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, FFSWAP(float, old_out0, old_out2); old_out1 = old_out3; - old_out3 = out[-i-2]; } tmp0 = out0; From e02249b13055c978379f34367840553faa902d1c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 23 Apr 2012 13:16:33 +0100 Subject: [PATCH 247/301] vqavideo: return error if image size is not a multiple of block size The decoder assumes in various places that the image size is a multiple of the block size, and there is no obvious way to support odd sizes. Bailing out early if the header specifies a bad size avoids various errors later on. Fixes CVE-2012-0947. Signed-off-by: Mans Rullgard (cherry picked from commit 58b2e0f0f2fc96c1158e04f8aba95cbe6157a1a3) Signed-off-by: Reinhard Tartler (cherry picked from commit d5207e2af81580dd5e6277b354c8b459c3624f26) Signed-off-by: Reinhard Tartler (cherry picked from commit c71c77e56fcc6d469d45e1c8ce04aa053124d3f8) Signed-off-by: Reinhard Tartler --- libavcodec/vqavideo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index a1698394ef..12f4dbcaca 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -162,6 +162,12 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) return -1; } + if (s->width & (s->vector_width - 1) || + s->height & (s->vector_height - 1)) { + av_log(avctx, AV_LOG_ERROR, "Image size not multiple of block size\n"); + return AVERROR_INVALIDDATA; + } + /* allocate codebooks */ s->codebook_size = MAX_CODEBOOK_SIZE; s->codebook = av_malloc(s->codebook_size); From 212217504afc45ac96d5a070e8bda3604bcda092 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 17 Feb 2012 14:13:40 -0800 Subject: [PATCH 248/301] dpcm: ignore extra unpaired bytes in stereo streams. Fixes: CVE-2011-3951 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind (cherry picked from commit ce7aee9b733134649a6ce2fa743e51733f33e67e) (cherry picked from commit eaeaeb265fe46e1d81452960de918227541873b4) Conflicts: libavcodec/dpcm.c Signed-off-by: Reinhard Tartler (cherry picked from commit 1ce9c93198fc997e8f23934a78e2937af670e4e9) Signed-off-by: Reinhard Tartler --- libavcodec/dpcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index 7c5351686e..8cc8fb56a2 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -169,6 +169,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, int in, out = 0; int predictor[2]; int channel_number = 0; + int stereo = s->channels - 1; short *output_samples = data; int shift[2]; unsigned char byte; @@ -177,6 +178,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx, if (!buf_size) return 0; + if (stereo && (buf_size & 1)) + buf_size--; + // almost every DPCM variant expands one byte of data into two if(*data_size/2 < buf_size) return -1; @@ -295,7 +299,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, } *data_size = out * sizeof(short); - return buf_size; + return avpkt->size; } #define DPCM_DECODER(id, name, long_name_) \ From 32b73701c72153980cbd09743bf3011a08e6af90 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 10 Jan 2012 13:07:09 -0800 Subject: [PATCH 249/301] aacsbr: prevent out of bounds memcpy(). Fixes Libav Bug 195. Fixes CVE-2012-0850 This doesn't make the code handle sample rate or upsample/downsample change properly but this is still a good sanity check. Based on change by Michael Niedermayer. Signed-off-by: Alex Converse (cherry picked from commit 17ce52912f59a74ecc265e062578fb1181456e18) Signed-off-by: Reinhard Tartler (cherry picked from commit 01804cc91ab231ac79092eee21325d7644357975) Conflicts: libavcodec/aacsbr.c Signed-off-by: Reinhard Tartler --- libavcodec/aacsbr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index cac34bb085..a8ce7ce9a2 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -1182,14 +1182,15 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, int i, n; const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; int scale_and_bias = scale != 1.0f || bias != 0.0f; + const int step = 128 >> div; float *v; for (i = 0; i < 32; i++) { - if (*v_off == 0) { + if (*v_off < step) { int saved_samples = (1280 - 128) >> div; memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float)); - *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - (128 >> div); + *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step; } else { - *v_off -= 128 >> div; + *v_off -= step; } v = v0 + *v_off; if (div) { From 7a5fbe40344ae51ce629cc0694a436535beb1233 Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Sat, 24 Mar 2012 17:32:14 -0400 Subject: [PATCH 250/301] h264: Add check for invalid chroma_format_idc Fixes a crash when FF_DEBUG_PICT_INFO is used. Signed-off-by: Ronald S. Bultje (cherry picked from commit 6ef4063957aa5025c8d2cd757b6a537e4b6874df) Fixes: CVE-2012-0851 Signed-off-by: Reinhard Tartler (cherry picked from commit 47132345184dc3d0ff962a57a1225564fe979548) Signed-off-by: Reinhard Tartler (cherry picked from commit c5f7c755cfccd7aa01010a2d566104c2b0fa6d86) Signed-off-by: Reinhard Tartler --- libavcodec/h264_ps.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 7648e2c7a6..d6728304aa 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -297,8 +297,12 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ if(sps->profile_idc >= 100){ //high profile sps->chroma_format_idc= get_ue_golomb_31(&s->gb); - if(sps->chroma_format_idc == 3) + if(sps->chroma_format_idc > 3) { + av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc (%u) out of range\n", sps->chroma_format_idc); + return -1; + } else if(sps->chroma_format_idc == 3) { sps->residual_color_transform_flag = get_bits1(&s->gb); + } sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8; sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8; sps->transform_bypass = get_bits1(&s->gb); From 15c819e23ff1820ab6e0ea71291f939e36b2efb3 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Thu, 5 Jan 2012 20:50:55 +0100 Subject: [PATCH 251/301] adpcm: ADPCM Electronic Arts has always two channels Fixes half of http://ffmpeg.org/trac/ffmpeg/ticket/794 Adresses CVE-2012-0852 (cherry picked from commit bb5b3940b08d8dad5b7e948e8f3b02cd2eb70716) Conflicts: libavcodec/adpcm.c Signed-off-by: Reinhard Tartler (cherry picked from commit b581580bd1cc8506befa65b0a5c9ae429240f21f) Signed-off-by: Reinhard Tartler --- libavcodec/adpcm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 68bd656aa6..2cf2d20f46 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -678,17 +678,23 @@ static int adpcm_encode_frame(AVCodecContext *avctx, static av_cold int adpcm_decode_init(AVCodecContext * avctx) { ADPCMContext *c = avctx->priv_data; + unsigned int min_channels = 1; unsigned int max_channels = 2; switch(avctx->codec->id) { + case CODEC_ID_ADPCM_EA: + min_channels = 2; + break; case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: max_channels = 6; break; } - if(avctx->channels > max_channels){ - return -1; + + if (avctx->channels < min_channels || avctx->channels > max_channels) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); + return AVERROR(EINVAL); } switch(avctx->codec->id) { From 40cb7b3b490fbe84c36cb998a818e333a9074df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Rullg=C3=A5rd?= Date: Sat, 26 Jun 2010 14:34:21 +0000 Subject: [PATCH 252/301] shorten: remove VLA and check for buffer overflow Originally committed as revision 23798 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit 02591641f88097aec2a573f0ae384c8b87bcfe3b) Signed-off-by: Reinhard Tartler --- libavcodec/shorten.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 7e17f18e17..934da8e8b6 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -83,6 +83,7 @@ typedef struct ShortenContext { int32_t *decoded[MAX_CHANNELS]; int32_t *offset[MAX_CHANNELS]; + int *coeffs; uint8_t *bitstream; int bitstream_size; int bitstream_index; @@ -112,6 +113,8 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx) static int allocate_buffers(ShortenContext *s) { int i, chan; + int *coeffs; + for (chan=0; chanchannels; chan++) { if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){ av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n"); @@ -129,6 +132,12 @@ static int allocate_buffers(ShortenContext *s) s->decoded[chan][i] = 0; s->decoded[chan] += s->nwrap; } + + coeffs = av_realloc(s->coeffs, s->nwrap * sizeof(*s->coeffs)); + if (!coeffs) + return AVERROR(ENOMEM); + s->coeffs = coeffs; + return 0; } @@ -253,7 +262,7 @@ static int16_t * interleave_buffer(int16_t *samples, int nchan, int blocksize, i static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_size, int pred_order) { int sum, i, j; - int coeffs[pred_order]; + int *coeffs = s->coeffs; for (i=0; igb, LPCQUANT); @@ -427,6 +436,12 @@ static int shorten_decode_frame(AVCodecContext *avctx, case FN_QLPC: { int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); + if (pred_order > s->nwrap) { + av_log(avctx, AV_LOG_ERROR, + "invalid pred_order %d\n", + pred_order); + return -1; + } for (i=0; idecoded[channel][i - pred_order] -= coffset; decode_subframe_lpc(s, channel, residual_size, pred_order); @@ -515,6 +530,7 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx) av_freep(&s->offset[i]); } av_freep(&s->bitstream); + av_freep(&s->coeffs); return 0; } From 8f924ee66ff38e8758e404bac9d7cbd4c5676df8 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 2 Oct 2011 00:48:12 +0000 Subject: [PATCH 253/301] shorten: Prevent block size from increasing Signed-off-by: Janne Grunau (cherry picked from commit 95010d18b2d808db9a49377e41bc2f7cf4dfa03e) Signed-off-by: Anton Khirnov (cherry picked from commit 22949c42edf5352c5fa8c43870efe20698432b35) Signed-off-by: Reinhard Tartler --- libavcodec/shorten.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 934da8e8b6..833a817561 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -486,9 +486,15 @@ static int shorten_decode_frame(AVCodecContext *avctx, case FN_BITSHIFT: s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); break; - case FN_BLOCKSIZE: - s->blocksize = get_uint(s, av_log2(s->blocksize)); + case FN_BLOCKSIZE: { + int blocksize = get_uint(s, av_log2(s->blocksize)); + if (blocksize > s->blocksize) { + av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); + return AVERROR_PATCHWELCOME; + } + s->blocksize = blocksize; break; + } case FN_QUIT: *data_size = 0; return buf_size; From 58b3f439cc7e900fe269a7b73c58cf57a6e0c0fb Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Fri, 30 Sep 2011 01:26:22 +0000 Subject: [PATCH 254/301] shorten: Fix out of bound writes in fix_bitshift() The data pointers s->decoded[*] already take into account s->nwrap. Signed-off-by: Janne Grunau (cherry picked from commit 5f05cf4ea9aaafed8edcabe785c2719786103ec1) Signed-off-by: Anton Khirnov (cherry picked from commit 737bea21b6c2c1d4dca0b7b18824c0a3205556d2) Signed-off-by: Reinhard Tartler --- libavcodec/shorten.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 833a817561..22fdcff403 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -156,7 +156,7 @@ static void fix_bitshift(ShortenContext *s, int32_t *buffer) if (s->bitshift != 0) for (i = 0; i < s->blocksize; i++) - buffer[s->nwrap + i] <<= s->bitshift; + buffer[i] <<= s->bitshift; } From 46d9022859d1b991735fab91c88ff8dcb6891f57 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 15 Sep 2011 18:08:52 -0400 Subject: [PATCH 255/301] shorten: check for realloc failure (cherry picked from commit 9e5e2c2d010c05c10337e9c1ec9d0d61495e0c9c) Signed-off-by: Reinhard Tartler (cherry picked from commit a207a2fecc6a77735ab0cf209fdba0b4dd942a86) Signed-off-by: Reinhard Tartler --- libavcodec/shorten.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 22fdcff403..bf2783550f 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -114,6 +114,7 @@ static int allocate_buffers(ShortenContext *s) { int i, chan; int *coeffs; + void *tmp_ptr; for (chan=0; chanchannels; chan++) { if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){ @@ -125,9 +126,15 @@ static int allocate_buffers(ShortenContext *s) return -1; } - s->offset[chan] = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); + tmp_ptr = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->offset[chan] = tmp_ptr; - s->decoded[chan] = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + tmp_ptr = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->decoded[chan] = tmp_ptr; for (i=0; inwrap; i++) s->decoded[chan][i] = 0; s->decoded[chan] += s->nwrap; @@ -286,8 +293,15 @@ static int shorten_decode_frame(AVCodecContext *avctx, int i, input_buf_size = 0; int16_t *samples = data; if(s->max_framesize == 0){ + void *tmp_ptr; s->max_framesize= 1024; // should hopefully be enough for the first header - s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize); + tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, + s->max_framesize); + if (!tmp_ptr) { + av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); + return AVERROR(ENOMEM); + } + s->bitstream = tmp_ptr; } if(1 && s->max_framesize){//FIXME truncated From cfad9930ff1e53452fc9664be62c975943acf353 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 25 Dec 2011 12:28:50 +0100 Subject: [PATCH 256/301] shorten: Use separate pointers for the allocated memory for decoded samples. Fixes invalid free() if any of the buffers are not allocated due to either not decoding a header or an error prior to allocating all buffers. Fixes CVE-2012-0858 CC: libav-stable@libav.org Signed-off-by: Michael Niedermayer Signed-off-by: Justin Ruggles (cherry picked from commit 204cb29b3c84a74cbcd059d353c70c8bdc567d98) Signed-off-by: Reinhard Tartler (cherry picked from commit 6fc3287b9ccece290c5881b92948772bbf72e68c) Signed-off-by: Reinhard Tartler (cherry picked from commit 96ed18cab1048f03ff1c825f46b25d49218f1da4) Signed-off-by: Reinhard Tartler --- libavcodec/shorten.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index bf2783550f..49708ef54c 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -82,6 +82,7 @@ typedef struct ShortenContext { int channels; int32_t *decoded[MAX_CHANNELS]; + int32_t *decoded_base[MAX_CHANNELS]; int32_t *offset[MAX_CHANNELS]; int *coeffs; uint8_t *bitstream; @@ -131,13 +132,14 @@ static int allocate_buffers(ShortenContext *s) return AVERROR(ENOMEM); s->offset[chan] = tmp_ptr; - tmp_ptr = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + tmp_ptr = av_realloc(s->decoded_base[chan], (s->blocksize + s->nwrap) * + sizeof(s->decoded_base[0][0])); if (!tmp_ptr) return AVERROR(ENOMEM); - s->decoded[chan] = tmp_ptr; + s->decoded_base[chan] = tmp_ptr; for (i=0; inwrap; i++) - s->decoded[chan][i] = 0; - s->decoded[chan] += s->nwrap; + s->decoded_base[chan][i] = 0; + s->decoded[chan] = s->decoded_base[chan] + s->nwrap; } coeffs = av_realloc(s->coeffs, s->nwrap * sizeof(*s->coeffs)); @@ -545,8 +547,8 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx) int i; for (i = 0; i < s->channels; i++) { - s->decoded[i] -= s->nwrap; - av_freep(&s->decoded[i]); + s->decoded[i] = NULL; + av_freep(&s->decoded_base[i]); av_freep(&s->offset[i]); } av_freep(&s->bitstream); From 07bff951764c129d39ab2e06a644b13d1f0d6e48 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 17:30:49 +0100 Subject: [PATCH 257/301] kmvc: Check palsize. Fixes: CVE-2011-3952 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Based on fix by Michael Niedermayer (cherry picked from commit 386741f887714d3e46c9e8fe577e326a7964037b) (cherry picked from commit 416849f2e06227b1b4a451c392f100db1d709a0c) Signed-off-by: Reinhard Tartler --- libavcodec/kmvc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 3e8dccd363..c8de28b3e5 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -33,6 +33,7 @@ #define KMVC_KEYFRAME 0x80 #define KMVC_PALETTE 0x40 #define KMVC_METHOD 0x0F +#define MAX_PALSIZE 256 /* * Decoder context @@ -43,7 +44,7 @@ typedef struct KmvcContext { int setpal; int palsize; - uint32_t pal[256]; + uint32_t pal[MAX_PALSIZE]; uint8_t *cur, *prev; uint8_t *frm0, *frm1; } KmvcContext; @@ -365,6 +366,10 @@ static av_cold int decode_init(AVCodecContext * avctx) c->palsize = 127; } else { c->palsize = AV_RL16(avctx->extradata + 10); + if (c->palsize >= MAX_PALSIZE) { + av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n"); + return AVERROR_INVALIDDATA; + } } if (avctx->extradata_size == 1036) { // palette in extradata From 4bccd5a36bb14d9befecdc10cd8c4c4a5d3d24fe Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 2 May 2012 16:12:46 +0000 Subject: [PATCH 258/301] qdm2: clip array indices returned by qdm2_get_vlc(). Prevents subsequent overreads when these numbers are used as indices in arrays. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org Signed-off-by: Justin Ruggles (cherry picked from commit 64953f67f98da2e787aeb45cc7f504390fa32a69) Signed-off-by: Derek Buitenhuis Conflicts: libavcodec/qdm2.c --- libavcodec/qdm2.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 839e3fe1bf..946f7d29f7 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -883,9 +883,13 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l break; case 30: - if (BITS_LEFT(length,gb) >= 4) - samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)]; - else + if (BITS_LEFT(length,gb) >= 4) { + unsigned index = qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1); + if (index < FF_ARRAY_ELEMS(type30_dequant)) { + samples[0] = type30_dequant[index]; + } else + samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); + } else samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; @@ -899,8 +903,12 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l type34_predictor = samples[0]; type34_first = 0; } else { - samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor; - type34_predictor = samples[0]; + unsigned index = qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1); + if (index < FF_ARRAY_ELEMS(type34_delta)) { + samples[0] = type34_delta[index] / type34_div + type34_predictor; + type34_predictor = samples[0]; + } else + samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); From 68d2c6e872d2d063ff0642399524e6e804039f9c Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Sat, 10 Jul 2010 04:08:02 +0000 Subject: [PATCH 259/301] configure: properly check for mingw-w64 through installed headers. mingw-w64 can also target 32-bit code. Originally committed as revision 24156 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit 0a4307d6307516d333ce2cde2a2ffa0f50bc176c) Signed-off-by: Derek Buitenhuis --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index b3e2fe1489..1474ddbdc0 100755 --- a/configure +++ b/configure @@ -2230,7 +2230,7 @@ case $target_os in dlltool="${cross_prefix}dlltool" enable dos_paths check_cflags -fno-common - if ! enabled x86_64; then + if ! check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR)"; then check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW runtime version must be >= 3.15." enabled_any avisynth vfwcap_indev && From 732dbc0f030c751e297cb648863ab0d5598a9e54 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Sun, 11 Jul 2010 22:17:17 +0000 Subject: [PATCH 260/301] mingw32: properly check if vfw capture is supported by the system headers Remove check for an specific w32api version, checking instead if vfw.h supports vfw capture. The defines in w32api 3.12 were wrong, so this must be accounted for in the check. Originally committed as revision 24203 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit ec1ee802a2e1cb3317bd44851cc28f95b5916051) Signed-off-by: Derek Buitenhuis Conflicts: configure --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 1474ddbdc0..4d0705b40e 100755 --- a/configure +++ b/configure @@ -1412,7 +1412,7 @@ oss_indev_deps_any="soundcard_h sys_soundcard_h" oss_outdev_deps_any="soundcard_h sys_soundcard_h" v4l_indev_deps="linux_videodev_h" v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" -vfwcap_indev_deps="capCreateCaptureWindow" +vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines" vfwcap_indev_extralibs="-lavicap32" x11_grab_device_indev_deps="x11grab XShmCreateImage" x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes" @@ -2233,9 +2233,6 @@ case $target_os in if ! check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR)"; then check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW runtime version must be >= 3.15." - enabled_any avisynth vfwcap_indev && - { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" || - die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; } fi ;; cygwin*) @@ -2689,6 +2686,9 @@ check_header linux/videodev2.h check_header sys/videoio.h check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs" +# check that WM_CAP_DRIVER_CONNECT is defined to the proper value +# w32api 3.12 had it defined wrong +check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines # check for ioctl_meteor.h, ioctl_bt848.h and alternatives { check_header dev/bktr/ioctl_meteor.h && From 77630b68e584b3493ae5691dad8f5346fa3fea15 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Sun, 11 Jul 2010 22:31:41 +0000 Subject: [PATCH 261/301] mingw32: merge checks for mingw-w64 and mingw32-runtime >= 3.15 into one Originally committed as revision 24204 to svn://svn.ffmpeg.org/ffmpeg/trunk (cherry picked from commit e26011d0f495de1148b8014995cbe923611b6b76) Signed-off-by: Derek Buitenhuis --- configure | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 4d0705b40e..0e72cb9359 100755 --- a/configure +++ b/configure @@ -2230,10 +2230,9 @@ case $target_os in dlltool="${cross_prefix}dlltool" enable dos_paths check_cflags -fno-common - if ! check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR)"; then - check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || + check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \ + || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW runtime version must be >= 3.15." - fi ;; cygwin*) target_os=cygwin From 97ed486fffc817317561a91bc6ecd71a8eb493c6 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 19 Feb 2011 00:42:11 +0000 Subject: [PATCH 262/301] dxva2: define required feature selection macros Signed-off-by: Mans Rullgard (cherry picked from commit 04973f8082c5a822112d2e42d535b7f3f59dccc0) Signed-off-by: Derek Buitenhuis --- libavcodec/dxva2_internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index a9be7a07e7..23d4d87522 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -23,6 +23,8 @@ #ifndef AVCODEC_DXVA_INTERNAL_H #define AVCODEC_DXVA_INTERNAL_H +#define _WIN32_WINNT 0x0600 +#define COBJMACROS #include "dxva2.h" #include "avcodec.h" #include "mpegvideo.h" From e17b1536a1d019d62ffa627948a36881a5b7ce1e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 2 May 2012 10:58:55 -0700 Subject: [PATCH 263/301] png: check bit depth for PAL8/Y400A pixel formats. Wrong bit depth can lead to invalid rowsize values, which crashes the decoder further down. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit d2205d6543881f2e6fa18c8a354bbcf91a1235f7) Signed-off-by: Reinhard Tartler (cherry picked from commit b8d6ba9d50e80fdce2ed74cdaffd4960df8a21c5) Signed-off-by: Reinhard Tartler (cherry picked from commit 33f93005f1a86c108302b4c5978aa1a3d8e092cc) Signed-off-by: Reinhard Tartler --- libavcodec/pngdec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 03859a9913..24b0fd4cc7 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -487,9 +487,11 @@ static int decode_frame(AVCodecContext *avctx, } else if (s->bit_depth == 1 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = PIX_FMT_MONOBLACK; - } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) { + } else if (s->bit_depth == 8 && + s->color_type == PNG_COLOR_TYPE_PALETTE) { avctx->pix_fmt = PIX_FMT_PAL8; - } else if (s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + } else if (s->bit_depth == 8 && + s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = PIX_FMT_Y400A; } else { goto fail; From 679de9b5aa511dfcbb223b4a0a42382f95c104e8 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 4 May 2012 16:06:26 -0700 Subject: [PATCH 264/301] ea: check chunk_size for validity. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 273e6af47b38391f2bcc157cca0423fe7fcbf55c) Signed-off-by: Reinhard Tartler (cherry picked from commit 6a86b705e1d4b72f0dddfbe23ad3eed9947001d5) Signed-off-by: Reinhard Tartler (cherry picked from commit e74bc64dd376c4691a610ba62a66ed30affc97ec) Conflicts: libavformat/electronicarts.c --- libavformat/electronicarts.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index 86d7f91e66..5f485290c8 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -457,12 +457,17 @@ static int ea_read_packet(AVFormatContext *s, while (!packet_read) { chunk_type = get_le32(pb); - chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; + chunk_size = ea->big_endian ? get_be32(pb) : get_le32(pb); + if (chunk_size <= 8) + return AVERROR_INVALIDDATA; + chunk_size -= 8; switch (chunk_type) { /* audio data */ case ISNh_TAG: /* header chunk also contains data; skip over the header portion*/ + if (chunk_size < 32) + return AVERROR_INVALIDDATA; url_fskip(pb, 32); chunk_size -= 32; case ISNd_TAG: From 83fa442b716189d61a19b17aef2adc3777e1fbf2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 19 Dec 2011 04:13:37 +0100 Subject: [PATCH 265/301] tqi: Pass errors from the MB decoder This silences some valgrind warnings. CC: libav-stable@libav.org Fixes second half of http://ffmpeg.org/trac/ffmpeg/ticket/794 Bug found by: Oana Stratulat Signed-off-by: Michael Niedermayer Signed-off-by: Reinhard Tartler (cherry picked from commit f85334f58e1286287d0547a49fa9c93b40cbf48f) (cherry picked from commit 90290a5150e84fb138ccde57657dc03830f08c1c) Signed-off-by: Reinhard Tartler (cherry picked from commit 5872580e65aab026b77754eb184f97ba7cc6ea35) Signed-off-by: Reinhard Tartler (cherry picked from commit 2f2fd8c6d1c51a6b817e6c0bc4eff308b8f9cd18) Signed-off-by: Reinhard Tartler --- libavcodec/eatqi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 7f1901d309..53f21a2c84 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -59,12 +59,15 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx) return 0; } -static void tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64]) +static int tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64]) { int n; s->dsp.clear_blocks(block[0]); for (n=0; n<6; n++) - ff_mpeg1_decode_block_intra(s, block[n], n); + if (ff_mpeg1_decode_block_intra(s, block[n], n) < 0) + return -1; + + return 0; } static inline void tqi_idct_put(TqiContext *t, DCTELEM (*block)[64]) @@ -136,7 +139,8 @@ static int tqi_decode_frame(AVCodecContext *avctx, for (s->mb_y=0; s->mb_y<(avctx->height+15)/16; s->mb_y++) for (s->mb_x=0; s->mb_x<(avctx->width+15)/16; s->mb_x++) { - tqi_decode_mb(s, t->block); + if (tqi_decode_mb(s, t->block) < 0) + break; tqi_idct_put(t, t->block); } From 4451f9ae169534999c64b77cccc5cf2976832660 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 3 Jun 2012 22:42:54 +0200 Subject: [PATCH 266/301] Bump version number for 0.6.6 release. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ef5e445445..05e8a4593f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.5 +0.6.6 From 888cee659ebb23e8a8d3909521c1c287f934149b Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Fri, 8 Jun 2012 15:20:14 -0400 Subject: [PATCH 267/301] Update changelog for 0.6.6 release Signed-off-by: Derek Buitenhuis --- Changelog | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Changelog b/Changelog index 11a554b28c..239943f0f8 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,41 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 0.6.6: +- id3v2: fix skipping extended header in id3v2.4 +- nsvdec: Fix use of uninitialized streams +- nsvdec: Be more careful with av_malloc() +- nsvdec: Propagate errors +- dv: check stype +- dv: Fix null pointer dereference due to ach=0 +- dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936. +- atrac3: Fix crash in tonal component decoding +- mjpegbdec: Fix overflow in SOS +- kgv1dec: Increase offsets array size so it is large enough +- motionpixels: decode only the 111 complete frames for fate +- motionpixels: Clip YUV values after applying a gradient +- celp filters: Do not read earlier than the start of the 'out' vector +- vqavideo: return error if image size is not a multiple of block size (CVE-2012-0947) +- dpcm: ignore extra unpaired bytes in stereo streams (CVE-2011-3951) +- aacsbr: prevent out of bounds memcpy() (CVE-2012-0850) +- h264: Add check for invalid chroma_format_idc (CVE-2012-0851) +- adpcm: ADPCM Electronic Arts has always two channels (CVE-2012-0852) +- shorten: remove VLA and check for buffer overflow +- shorten: Prevent block size from increasing +- shorten: Fix out of bound writes in fix_bitshift() +- shorten: check for realloc failure (CVE-2012-0858) +- shorten: Use separate pointers for the allocated memory for decoded samples (CVE-2012-0858) +- kmvc: Check palsize (CVE-2011-3952) +- qdm2: clip array indices returned by qdm2_get_vlc() +- configure: properly check for mingw-w64 through installed headers +- mingw32: properly check if vfw capture is supported by the system headers +- mingw32: merge checks for mingw-w64 and mingw32-runtime >= 3.15 into one +- dxva2: define required feature selection macros +- png: check bit depth for PAL8/Y400A pixel formats +- ea: check chunk_size for validity +- tqi: Pass errors from the MB decoder + + version 0.6.5: - vorbis: An additional defense in the Vorbis codec. (CVE-2011-3895) - vorbisdec: Fix decoding bug with channel handling. From 64eb6892ec839fb11f5b62db38810efb638ba806 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 9 Jun 2012 12:05:53 +0200 Subject: [PATCH 268/301] Release notes for 0.6.6 --- RELEASE | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/RELEASE b/RELEASE index cd18270ca4..746ddb480e 100644 --- a/RELEASE +++ b/RELEASE @@ -192,3 +192,21 @@ demuxer (CVE-2011-3893 and CVE-2011-3895). Distributors and system integrators are encouraged to update and share their patches against this branch. For a full list of changes please see the Changelog file. + + +* 0.6.6 + +General notes +------------- + +This mostly maintenance-only release that addresses a number a number of +bugs such as security and compilation issues that have been brought to +our attention. Among other fixes, this release features includes +security updates for the, DV decoder (CVE-2011-3929 and CVE-2011-3936), +VQA Video Decoder (CVE-2012-0947), DPCM codecs (CVE-2011-3951), AAC SBR +(CVE-2012-0850), H.264 (CVE-2012-0851), ADPCM (CVE-2012-0852), Shorten +(CVE-2012-0858), and the KMVC decoder (CVE-2011-3952). + +Distributors and system integrators are encouraged +to update and share their patches against this branch. For a full list +of changes please see the Changelog file or the git commit history. From 42bdeaecd41cb99f80901ce1a9649a9cb2b639b6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 May 2012 16:50:15 +0200 Subject: [PATCH 269/301] cdgraphics: Fix out of array write Fixes Ticket1359 Found-by: Piotr Bandurski Signed-off-by: Michael Niedermayer (cherry picked from commit 1e5c7376c4ed733910845c9a09e272ac7696b1f4) Signed-off-by: Michael Niedermayer --- libavcodec/cdgraphics.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index c174aa9d98..8d8aea437d 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -280,6 +280,10 @@ static int cdg_decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n"); return AVERROR(EINVAL); } + if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) { + av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n"); + return AVERROR(EINVAL); + } ret = avctx->reget_buffer(avctx, &cc->frame); if (ret) { From 62cbdd71eb2c0051cc5a9797db5ea82399337344 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 May 2012 17:08:06 +0200 Subject: [PATCH 270/301] yop: check for missing extradata Fixes null ptr deref Fixes Ticket1361 Signed-off-by: Michael Niedermayer (cherry picked from commit 77a4c8b959fa9bc6bcaa42b40a0b046cdf3fec38) Signed-off-by: Michael Niedermayer --- libavcodec/yop.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 1eb76b128e..1adbd612ad 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -89,6 +89,11 @@ static av_cold int yop_decode_init(AVCodecContext *avctx) return -1; } + if (!avctx->extradata) { + av_log(avctx, AV_LOG_ERROR, "extradata missing\n"); + return AVERROR_INVALIDDATA; + } + avctx->pix_fmt = PIX_FMT_PAL8; s->num_pal_colors = avctx->extradata[0]; From 9291fc881384201760df69dadf16fe5d8710e15a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 May 2012 17:17:49 +0200 Subject: [PATCH 271/301] motionpixels: check extradata size Fixes null ptr derefernce Fixes Ticket1363 Signed-off-by: Michael Niedermayer (cherry picked from commit 50122084a6b3be06781a2b3d8ec036f2d67c32e3) Signed-off-by: Michael Niedermayer --- libavcodec/motionpixels.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 91f28cfe62..4af56abe37 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -53,6 +53,11 @@ static av_cold int mp_decode_init(AVCodecContext *avctx) { MotionPixelsContext *mp = avctx->priv_data; + if(avctx->extradata_size < 2){ + av_log(avctx, AV_LOG_ERROR, "extradata too small\n"); + return AVERROR_INVALIDDATA; + } + motionpixels_tableinit(); mp->avctx = avctx; dsputil_init(&mp->dsp, avctx); From 32ac7c0cf6761c9ccc1c13ffad92d71ecf9c3f7c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 May 2012 16:19:36 +0200 Subject: [PATCH 272/301] truemotion1: Check index, fix out of array read Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit fd4c1c0b70b5a06dd572d7e27799a2f4c3d9b984) Signed-off-by: Michael Niedermayer --- libavcodec/truemotion1.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 4306917912..f8c98a0502 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -518,6 +518,10 @@ hres,vres,i,i%vres (0 < i < 4) } #define APPLY_C_PREDICTOR() \ + if(index > 1023){\ + av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ + return; \ + }\ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -535,6 +539,10 @@ hres,vres,i,i%vres (0 < i < 4) index++; #define APPLY_C_PREDICTOR_24() \ + if(index > 1023){\ + av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ + return; \ + }\ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -553,6 +561,10 @@ hres,vres,i,i%vres (0 < i < 4) #define APPLY_Y_PREDICTOR() \ + if(index > 1023){\ + av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ + return; \ + }\ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -570,6 +582,10 @@ hres,vres,i,i%vres (0 < i < 4) index++; #define APPLY_Y_PREDICTOR_24() \ + if(index > 1023){\ + av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ + return; \ + }\ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ From e37599001cefd7efb683c8228feedf3d291ef1db Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 1 Jun 2012 15:51:50 +0200 Subject: [PATCH 273/301] yopdec: check that palette fits in the packet Signed-off-by: Michael Niedermayer (cherry picked from commit b6fdf8dea7aaf3cb9a979dce91f752c2ce3086a3) Signed-off-by: Michael Niedermayer --- libavcodec/yop.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 1adbd612ad..69f2e8e816 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -203,6 +203,11 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size, if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); + if (avpkt->size < 4 + 3*s->num_pal_colors) { + av_log(avctx, AV_LOG_ERROR, "packet of size %d too small\n", avpkt->size); + return AVERROR_INVALIDDATA; + } + ret = avctx->get_buffer(avctx, &s->frame); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); From 3074e8f78c4d84f93c1bdc05f36f0bce8b8a830f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 1 Jun 2012 15:52:20 +0200 Subject: [PATCH 274/301] yopdec: check frame oddness to be within supported limits Fixes Ticket1365 Signed-off-by: Michael Niedermayer (cherry picked from commit febc013dc5d6db1535a4f91cf02fa8089038937c) Signed-off-by: Michael Niedermayer --- libavcodec/yop.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 69f2e8e816..7f933b5f46 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -223,6 +223,10 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size, s->low_nibble = NULL; is_odd_frame = avpkt->data[0]; + if(is_odd_frame>1){ + av_log(avctx, AV_LOG_ERROR, "frame is too odd %d\n", is_odd_frame); + return AVERROR_INVALIDDATA; + } firstcolor = s->first_color[is_odd_frame]; palette = (uint32_t *)s->frame.data[1]; From 6b14563c0e7848992a5fe70a80135fe090bfad51 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 1 Jun 2012 21:42:29 +0200 Subject: [PATCH 275/301] wmv1: check that the input buffer is large enough Fixes null ptr deref Fixes Ticket1367 Signed-off-by: Michael Niedermayer (cherry picked from commit f23a2418fb0ccc56fdae4dbf83a5994cc917c475) Signed-off-by: Michael Niedermayer --- libavcodec/wnv1.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 56634d10ac..27026c5bd7 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -70,6 +70,11 @@ static int decode_frame(AVCodecContext *avctx, int prev_y = 0, prev_u = 0, prev_v = 0; uint8_t *rbuf; + if(buf_size<=8) { + av_log(avctx, AV_LOG_ERROR, "buf_size %d is too small\n", buf_size); + return AVERROR_INVALIDDATA; + } + rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if(!rbuf){ av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); From 62133b38ed043b57eeecbe7fc8b6f187fd92e5e0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Jun 2012 14:41:21 +0200 Subject: [PATCH 276/301] h263: disable loop filter with lowres Fixes ticket1212 Found-by: Piotr Bandurski Signed-off-by: Michael Niedermayer (cherry picked from commit cc229d4e83889d1298f1a0863b55feec6c5c339a) Signed-off-by: Michael Niedermayer --- libavcodec/intelh263dec.c | 2 +- libavcodec/ituh263dec.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 5e451294da..182b4955cc 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -72,7 +72,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s) } if(get_bits(&s->gb, 2)) av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n"); - s->loop_filter = get_bits1(&s->gb); + s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres; if(get_bits1(&s->gb)) av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n"); if(get_bits1(&s->gb)) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 8b5d9391b2..618eac3e44 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -961,6 +961,8 @@ int h263_decode_picture_header(MpegEncContext *s) s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */ s->loop_filter= get_bits1(&s->gb); s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter; + if(s->avctx->lowres) + s->loop_filter = 0; s->h263_slice_structured= get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { From 4eea330a2afa317940a11d5bf5461ba673ab6b67 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 30 May 2012 04:04:54 +0100 Subject: [PATCH 277/301] h264: allow cropping to AVCodecContext.width/height Override the frame size from the SPS with AVCodecContext values if the latter specify a size smaller by less than one macroblock. This is required for correct cropping of MOV files from Canon cameras. Signed-off-by: Mans Rullgard (cherry picked from commit 30f515091c323da59c0f1b533703dedca2f4b95d) Conflicts: libavcodec/h264.c (cherry picked from commit e1608014c50eeb9f4744a53de0794eb6bb1269a2) Signed-off-by: Reinhard Tartler (cherry picked from commit b102d5d97daedb717c023ec7bfa43047d97de284) Signed-off-by: Reinhard Tartler --- libavcodec/h264.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 06ded4d1f1..02ff83309f 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1799,6 +1799,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ else s->height= 16*s->mb_height - 4*FFMIN(h->sps.crop_bottom, 3); + if (FFALIGN(s->avctx->width, 16) == s->width && + FFALIGN(s->avctx->height, 16) == s->height) { + s->width = s->avctx->width; + s->height = s->avctx->height; + } + if (s->context_initialized && ( s->width != s->avctx->width || s->height != s->avctx->height || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) { From 44e6cf3f75f00d201a8cb1b836251f5a826186a0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 30 May 2012 04:06:00 +0100 Subject: [PATCH 278/301] mov: set AVCodecContext.width/height for h264 This is required for correct cropping of files from Canon cameras. Signed-off-by: Mans Rullgard (cherry picked from commit 8aa93e900449c88c3169ff5636fed03f41779cac) Signed-off-by: Reinhard Tartler (cherry picked from commit 2fb4be9a99a2c2a9435339830e3d940171cc0d9b) Signed-off-by: Reinhard Tartler (cherry picked from commit 0054d70f23edd1f61a10a1c2c687b3a04831feb9) Signed-off-by: Reinhard Tartler --- libavformat/mov.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2edd27e440..f1cde0b767 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1820,9 +1820,6 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom) #if CONFIG_H263_DECODER case CODEC_ID_H263: #endif -#if CONFIG_H264_DECODER - case CODEC_ID_H264: -#endif #if CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif From 371e221d632d3e2450223c152c8c7e26ae4005a8 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 24 Jun 2012 11:17:13 +0100 Subject: [PATCH 279/301] dxva2: include dxva.h if found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently, some build environments require dxva.h even for dxva2, while others lack this header entirely. Including it conditionally allows building in both cases. Signed-off-by: Martin Storsjö (cherry picked from commit fa84506177f0246b30d4ea6a99ee5d419f3e4550) Signed-off-by: Michael Niedermayer --- configure | 2 ++ libavcodec/dxva2_internal.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/configure b/configure index 89bd4dc22d..9587c88169 100755 --- a/configure +++ b/configure @@ -1037,6 +1037,7 @@ HAVE_LIST=" dlfcn_h dlopen dos_paths + dxva_h ebp_available ebx_available exp2 @@ -2543,6 +2544,7 @@ check_func_headers windows.h VirtualAlloc check_header conio.h check_header dlfcn.h +check_header dxva.h check_header dxva2api.h check_header malloc.h check_header poll.h diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 23d4d87522..fcf45bc664 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -25,7 +25,14 @@ #define _WIN32_WINNT 0x0600 #define COBJMACROS + +#include "config.h" + #include "dxva2.h" +#if HAVE_DXVA_H +#include +#endif + #include "avcodec.h" #include "mpegvideo.h" From 79234907128390d775ceb1206dd0fed111a17896 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 13 Sep 2012 09:26:55 +0200 Subject: [PATCH 280/301] Fix muxing mjpeg in swf. --- libavformat/swfenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 1a1a9ab808..769f4e3e0d 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -498,8 +498,10 @@ static int swf_write_trailer(AVFormatContext *s) put_le32(pb, file_size); url_fseek(pb, swf->duration_pos, SEEK_SET); put_le16(pb, swf->video_frame_number); + if (swf->vframes_pos) { url_fseek(pb, swf->vframes_pos, SEEK_SET); put_le16(pb, swf->video_frame_number); + } url_fseek(pb, file_size, SEEK_SET); } return 0; From aa4121276777b20eaaa83bf9bd544b00748c865c Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 27 Sep 2012 19:25:06 +0200 Subject: [PATCH 281/301] vc1dec: add flush function for WMV9 and VC-1 decoders CC: libav-stable@libav.org (cherry picked from commit 4dc8c8386eef942dba35c4f2fb3210e22b511a5b) Signed-off-by: Anton Khirnov (cherry picked from commit 02b72394627933dc8ce26445231a69f00dba491b) Conflicts: libavcodec/vc1dec.c Signed-off-by: Anton Khirnov (cherry picked from commit 0173a7966b331105158a88f96b9afcc431d2fef8) Signed-off-by: Anton Khirnov --- libavcodec/vc1dec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index abcc5ecda8..8d31e8bc1e 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3328,6 +3328,7 @@ AVCodec vc1_decoder = { vc1_decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DELAY, NULL, + .flush = ff_mpeg_flush, .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), .pix_fmts = ff_hwaccel_pixfmt_list_420 }; @@ -3344,6 +3345,7 @@ AVCodec wmv3_decoder = { vc1_decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DELAY, NULL, + .flush = ff_mpeg_flush, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), .pix_fmts = ff_hwaccel_pixfmt_list_420 }; From 459feb7cce03af7154c098171fc9d36fc9d472f6 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Mon, 6 Aug 2012 13:59:04 +0200 Subject: [PATCH 282/301] nuv: check RTjpeg header for validity CC: libav-stable@libav.org (cherry picked from commit 859a579e9bbf47fae2e09494c43bcf813dcb2fad) Signed-off-by: Anton Khirnov (cherry picked from commit 6704522ca9dd32c858ee474492be568c386910f9) Signed-off-by: Anton Khirnov (cherry picked from commit f31170d4e7f9671e019315391160d454b18d7296) Signed-off-by: Anton Khirnov --- libavcodec/nuv.c | 9 +++++---- libavcodec/rtjpeg.h | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 791f450913..6f832cc27a 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -184,17 +184,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, } if (c->codec_frameheader) { int w, h, q; - if (buf_size < 12) { + if (buf_size < RTJPEG_HEADER_SIZE || buf[4] != RTJPEG_HEADER_SIZE || + buf[5] != RTJPEG_FILE_VERSION) { av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n"); - return -1; + return AVERROR_INVALIDDATA; } w = AV_RL16(&buf[6]); h = AV_RL16(&buf[8]); q = buf[10]; if (!codec_reinit(avctx, w, h, q)) return -1; - buf = &buf[12]; - buf_size -= 12; + buf = &buf[RTJPEG_HEADER_SIZE]; + buf_size -= RTJPEG_HEADER_SIZE; } if (keyframe && c->pic.data[0]) diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h index 4bcb9f70ca..73d41f481d 100644 --- a/libavcodec/rtjpeg.h +++ b/libavcodec/rtjpeg.h @@ -25,6 +25,9 @@ #include #include "dsputil.h" +#define RTJPEG_FILE_VERSION 0 +#define RTJPEG_HEADER_SIZE 12 + typedef struct { int w, h; DSPContext *dsp; From fd7426ed898533bed98e6b472ff5f5c8e47f2eb5 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Mon, 2 Jul 2012 10:46:39 +0200 Subject: [PATCH 283/301] imgconvert: avoid undefined left shift in avcodec_find_best_pix_fmt CC: libav-stable@libav.org (cherry picked from commit 39bb27bf79bc4c2d8beaed637a14176264cb1916) Signed-off-by: Anton Khirnov (cherry picked from commit 7a7229b52d1900279041991fadbd29b27e8dfe95) Signed-off-by: Anton Khirnov (cherry picked from commit 8812b5f164109553f009ce385e17a1af16b6ea53) Signed-off-by: Anton Khirnov --- libavcodec/imgconvert.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 8f789c4ae0..ae8ec16543 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -851,7 +851,8 @@ static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask, /* find exact color match with smallest size */ dst_pix_fmt = PIX_FMT_NONE; min_dist = 0x7fffffff; - for(i = 0;i < PIX_FMT_NB; i++) { + /* test only the first 64 pixel formats to avoid undefined behaviour */ + for (i = 0; i < 64; i++) { if (pix_fmt_mask & (1ULL << i)) { loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask; if (loss == 0) { From c82ae85a8a78a98f7c7fea68d24a4ac0ca74d01f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 20 Nov 2011 17:19:25 +0100 Subject: [PATCH 284/301] mpegvideo: Don't use ff_mspel_motion() for vc1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using ff_mspel_motion assumes that s (a MpegEncContext poiinter) really is a Wmv2Context. This fixes crashes in error resilience on vc1/wmv3 videos. CC: libav-stable@libav.org Signed-off-by: Martin Storsjö (cherry picked from commit 18f2d5cb9c48d06895960f37467576725c9dc2d1) Signed-off-by: Anton Khirnov (cherry picked from commit da0c457663479bc1828918e1bb3e4a5e4de0d557) Signed-off-by: Anton Khirnov (cherry picked from commit 899d95efe12f1e250b361837c1c8c06df9ac9b86) Signed-off-by: Anton Khirnov --- libavcodec/mpegvideo_common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h index 73106664f9..258f7cdaa7 100644 --- a/libavcodec/mpegvideo_common.h +++ b/libavcodec/mpegvideo_common.h @@ -727,7 +727,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, 0, 0, 0, ref_picture, pix_op, qpix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); - }else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel){ + } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && + s->mspel && s->codec_id == CODEC_ID_WMV2) { ff_mspel_motion(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); From a4e277312cacfb78ef7583ed0b4fe4ccf5a0bcb1 Mon Sep 17 00:00:00 2001 From: Mina Nagy Zaki Date: Wed, 8 Jun 2011 19:24:25 +0300 Subject: [PATCH 285/301] lavfi: avfilter_merge_formats: handle case where inputs are same This fixes a double-free crash if lists are the same due to the two merge_ref() calls at the end of the (useless) merging that happens. Signed-off-by: Anton Khirnov (cherry picked from commit 11b6a82412bcd372adf694a26d83b07d337e1325) Conflicts: libavfilter/formats.c Signed-off-by: Reinhard Tartler (cherry picked from commit e5f4e249422834f727bcd432b73af971277f1371) Signed-off-by: Anton Khirnov (cherry picked from commit b6c5848a1f8fc2755ea70d325acaddae9fac45ab) Signed-off-by: Anton Khirnov --- libavfilter/formats.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 2a9bdb0bd0..8b8bf75962 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -44,6 +44,9 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) AVFilterFormats *ret; unsigned i, j, k = 0; + if (a == b) + return a; + ret = av_mallocz(sizeof(AVFilterFormats)); /* merge list of formats */ From 0e2f415adf5d8c0e8bbb210c3c2693315854718f Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 4 Jun 2012 18:27:03 -0700 Subject: [PATCH 286/301] vorbis: Validate that the floor 1 X values contain no duplicates. Duplicate values in this vector are explicitly banned by the Vorbis I spec and cause divide-by-zero crashes later on. (cherry picked from commit ecf79c4d3e8baaf2f303278ef81db6f8407656bc) Signed-off-by: Reinhard Tartler (cherry picked from commit 9aaaeba45c41cf2b3fa4100abbdee7437428f93c) Signed-off-by: Anton Khirnov (cherry picked from commit d6e250abfc36b239ef0c1fc9d45d588b853bfcb9) Signed-off-by: Anton Khirnov --- libavcodec/vorbis.c | 9 ++++++++- libavcodec/vorbis.h | 3 ++- libavcodec/vorbis_dec.c | 6 +++++- libavcodec/vorbis_enc.c | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index 109737976c..5f0ddda32f 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -123,7 +123,8 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num) return 0; } -void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) +int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext, + vorbis_floor1_entry *list, int values) { int i; list[0].sort = 0; @@ -147,6 +148,11 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) for (i = 0; i < values - 1; i++) { int j; for (j = i + 1; j < values; j++) { + if (list[i].x == list[j].x) { + av_log(avccontext, AV_LOG_ERROR, + "Duplicate value found in floor 1 X coordinates\n"); + return AVERROR_INVALIDDATA; + } if (list[list[i].sort].x > list[list[j].sort].x) { int tmp = list[i].sort; list[i].sort = list[j].sort; @@ -154,6 +160,7 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) } } } + return 0; } static inline void render_line_unrolled(intptr_t x, uint8_t y, int x1, diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h index ce9bead425..18a826eee8 100644 --- a/libavcodec/vorbis.h +++ b/libavcodec/vorbis.h @@ -35,7 +35,8 @@ typedef struct { uint_fast16_t high; } vorbis_floor1_entry; -void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values); +int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext, + vorbis_floor1_entry *list, int values); unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n) int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num); void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index e5ad4aaae3..a2ae854699 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -550,7 +550,11 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) } // Precalculate order of x coordinates - needed for decode - ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim); + if (ff_vorbis_ready_floor1_list(vc->avccontext, + floor_setup->data.t1.list, + floor_setup->data.t1.x_list_dim)) { + return AVERROR_INVALIDDATA; + } } else if (floor_setup->floor_type == 0) { uint_fast8_t max_codebook_dim = 0; diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbis_enc.c index 934463d1e1..2fb41d16eb 100644 --- a/libavcodec/vorbis_enc.c +++ b/libavcodec/vorbis_enc.c @@ -302,7 +302,8 @@ static void create_vorbis_context(vorbis_enc_context *venc, }; fc->list[i].x = a[i - 2]; } - ff_vorbis_ready_floor1_list(fc->list, fc->values); + if (ff_vorbis_ready_floor1_list(avccontext, fc->list, fc->values)) + return AVERROR(EINVAL); venc->nresidues = 1; venc->residues = av_malloc(sizeof(vorbis_enc_residue) * venc->nresidues); From 636c42de19f6a3399632a860dec1105cc0091765 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Tue, 22 Jan 2013 17:49:29 -0500 Subject: [PATCH 287/301] rtmp: fix multiple broken overflow checks Sanity checks like `data + size >= data_end || data + size < data' are broken, because `data + size < data' assumes pointer overflow, which is undefined behavior in C. Many compilers such as gcc/clang optimize such checks away. Use `size < 0 || size >= data_end - data' instead. Signed-off-by: Xi Wang Signed-off-by: Michael Niedermayer (cherry picked from commit 902cfe2f74d777a7dc20ac68f2393b9f84b790c1) Signed-off-by: Michael Niedermayer --- libavformat/rtmppkt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 58c3abe345..856b2f5f75 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -275,11 +275,11 @@ int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end) data++; break; } - if (data + size >= data_end || data + size < data) + if (size < 0 || size >= data_end - data) return -1; data += size; t = ff_amf_tag_size(data, data_end); - if (t < 0 || data + t >= data_end) + if (t < 0 || t >= data_end - data) return -1; data += t; } @@ -308,7 +308,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, int size = bytestream_get_be16(&data); if (!size) break; - if (data + size >= data_end || data + size < data) + if (size < 0 || size >= data_end - data) return -1; data += size; if (size == namelen && !memcmp(data-size, name, namelen)) { @@ -329,7 +329,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, return 0; } len = ff_amf_tag_size(data, data_end); - if (len < 0 || data + len >= data_end || data + len < data) + if (len < 0 || len >= data_end - data) return -1; data += len; } @@ -400,13 +400,13 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d data++; break; } - if (data + size >= data_end || data + size < data) + if (size < 0 || size >= data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, " %s: ", buf); ff_amf_tag_contents(ctx, data, data_end); t = ff_amf_tag_size(data, data_end); - if (t < 0 || data + t >= data_end) + if (t < 0 || t >= data_end - data) return; data += t; } From 9aa60889f3f9cc2b1ae8109dfa51c330365c0c76 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Tue, 22 Jan 2013 21:40:05 -0500 Subject: [PATCH 288/301] rtmp: fix buffer overflows in ff_amf_tag_contents() A negative `size' will bypass FFMIN(). In the subsequent memcpy() call, `size' will be considered as a large positive value, leading to a buffer overflow. Change the type of `size' to unsigned int to avoid buffer overflow, and simplify overflow checks accordingly. Signed-off-by: Xi Wang Signed-off-by: Michael Niedermayer (cherry picked from commit 4e692374f7962ea358c329de38c380103f8991b6) Signed-off-by: Michael Niedermayer --- libavformat/rtmppkt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 856b2f5f75..b998423184 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -359,7 +359,7 @@ static const char* rtmp_packet_type(int type) static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *data_end) { - int size; + unsigned int size; char buf[1024]; if (data >= data_end) @@ -378,7 +378,7 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d } else { size = bytestream_get_be32(&data); } - size = FFMIN(size, 1023); + size = FFMIN(size, sizeof(buf) - 1); memcpy(buf, data, size); buf[size] = 0; av_log(ctx, AV_LOG_DEBUG, " string '%s'\n", buf); @@ -391,16 +391,15 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d case AMF_DATA_TYPE_OBJECT: av_log(ctx, AV_LOG_DEBUG, " {\n"); for (;;) { - int size = bytestream_get_be16(&data); int t; - memcpy(buf, data, size); - buf[size] = 0; + size = bytestream_get_be16(&data); + av_strlcpy(buf, data, FFMIN(sizeof(buf), size + 1)); if (!size) { av_log(ctx, AV_LOG_DEBUG, " }\n"); data++; break; } - if (size < 0 || size >= data_end - data) + if (size >= data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, " %s: ", buf); From a7faa1d0703b7c2539122ea2140362411d7f62e0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 18:29:41 +0100 Subject: [PATCH 289/301] huffyuvdec: Check init_vlc() return codes. Prevents out of array writes Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit f67a0d115254461649470452058fa3c28c0df294) Signed-off-by: Michael Niedermayer (cherry picked from commit 95ab8d33e1a680f30a5a9605175112008ab81afc) Conflicts: libavcodec/huffyuv.c (cherry picked from commit 277def59fce10d91e3113e5c0f63e22bc4abfa88) Conflicts: libavcodec/huffyuv.c (cherry picked from commit adf022f458d75e2c8041262e1906a249366ad518) Signed-off-by: Michael Niedermayer --- libavcodec/huffyuv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 7764c35181..d7e0f8041a 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -285,6 +285,7 @@ static void generate_joint_tables(HYuvContext *s){ int len1 = s->len[p][u]; if(len1 > limit) continue; + assert(i < (1 << VLC_BITS)); len[i] = len0 + len1; bits[i] = (s->bits[0][y] << len1) + s->bits[p][u]; symbols[i] = (y<<8) + u; @@ -318,6 +319,7 @@ static void generate_joint_tables(HYuvContext *s){ int len2 = s->len[2][r&255]; if(len2 > limit1) continue; + assert(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; bits[i] = (code << len2) + s->bits[2][r&255]; if(s->decorrelate){ @@ -341,6 +343,7 @@ static void generate_joint_tables(HYuvContext *s){ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){ GetBitContext gb; int i; + int ret; init_get_bits(&gb, src, length*8); @@ -356,7 +359,8 @@ printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j); } #endif free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); @@ -368,6 +372,7 @@ static int read_old_huffman_tables(HYuvContext *s){ #if 1 GetBitContext gb; int i; + int ret; init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8); if(read_len_table(s->len[0], &gb)<0) @@ -388,7 +393,8 @@ static int read_old_huffman_tables(HYuvContext *s){ for(i=0; i<3; i++){ free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); From a77cf47d887a01567ae4d5327cba2886ea929e43 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 19:22:33 +0100 Subject: [PATCH 290/301] huffyuvdec: Skip len==0 cases Fixes vlc decoding for hypothetical files that would contain such cases. Signed-off-by: Michael Niedermayer (cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31) Signed-off-by: Michael Niedermayer (cherry picked from commit 5ff41ffeb4cb9ea6df49757dc859619dc3d3ab4f) Conflicts: libavcodec/huffyuv.c (cherry picked from commit 9bc70fe1ae50fd2faa0b9429d47cfbda01a92ebc) Signed-off-by: Michael Niedermayer --- libavcodec/huffyuv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index d7e0f8041a..883abac18e 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -279,11 +279,11 @@ static void generate_joint_tables(HYuvContext *s){ for(i=y=0; y<256; y++){ int len0 = s->len[0][y]; int limit = VLC_BITS - len0; - if(limit <= 0) + if(limit <= 0 || !len0) continue; for(u=0; u<256; u++){ int len1 = s->len[p][u]; - if(len1 > limit) + if (len1 > limit || !len1) continue; assert(i < (1 << VLC_BITS)); len[i] = len0 + len1; @@ -307,17 +307,17 @@ static void generate_joint_tables(HYuvContext *s){ for(i=0, g=-16; g<16; g++){ int len0 = s->len[p0][g&255]; int limit0 = VLC_BITS - len0; - if(limit0 < 2) + if (limit0 < 2 || !len0) continue; for(b=-16; b<16; b++){ int len1 = s->len[p1][b&255]; int limit1 = limit0 - len1; - if(limit1 < 1) + if (limit1 < 1 || !len1) continue; code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255]; for(r=-16; r<16; r++){ int len2 = s->len[2][r&255]; - if(len2 > limit1) + if (len2 > limit1 || !len2) continue; assert(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; From 3f785a538b4b45f64282fd44bcee57b83f5eb878 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 14 Jan 2013 20:38:33 +0100 Subject: [PATCH 291/301] configure: Make warnings from -Wreturn-type fatal errors These warnings have no false positives and point to serious bugs. (cherry picked from commit 99853cb8d4237b810b2fffb4a34f66fd0064ef72) Conflicts: configure Signed-off-by: Michael Niedermayer --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 9587c88169..9d30ed92a8 100755 --- a/configure +++ b/configure @@ -2796,8 +2796,10 @@ elif enabled gcc; then check_cflags -fno-tree-vectorize check_cflags -Werror=implicit check_cflags -Werror=missing-prototypes + check_cflags -Werror=return-type elif enabled clang; then check_cflags -Qunused-arguments + check_cflags -Werror=return-type elif enabled armcc; then # 2523: use of inline assembler is deprecated add_cflags -Wrvct,--diag_suppress=2523 From 6ad4a116a2068341b47f1a05a06d12a0937a48dc Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 22 Aug 2013 01:07:32 +0200 Subject: [PATCH 292/301] avcodec/rpza: Perform pointer advance and checks before using the pointers Fixes out of array accesses Fixes Ticket2850 Signed-off-by: Michael Niedermayer (cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34) Conflicts: libavcodec/rpza.c (cherry picked from commit edba432b8b01d68c22e70a508f47553359f59fb5) Signed-off-by: Michael Niedermayer --- libavcodec/rpza.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index e103f525d2..a1bef87922 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s) unsigned short *pixels = (unsigned short *)s->frame.data[0]; int row_ptr = 0; - int pixel_ptr = 0; + int pixel_ptr = -4; int block_ptr; int pixel_x, pixel_y; int total_blocks; @@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s) colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; while (n_blocks--) { + ADVANCE_BLOCK() block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ @@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s) } block_ptr += row_inc; } - ADVANCE_BLOCK(); } break; @@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s) color4[2] |= ((21 * ta + 11 * tb) >> 5); while (n_blocks--) { + ADVANCE_BLOCK(); block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { index = s->buf[stream_ptr++]; @@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s) } block_ptr += row_inc; } - ADVANCE_BLOCK(); } break; /* Fill block with 16 colors */ case 0x00: + ADVANCE_BLOCK(); block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ @@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s) } block_ptr += row_inc; } - ADVANCE_BLOCK(); break; /* Unknown opcode */ From f9225c2884bb387f9c9db72e756f6b6ce6b5f948 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 20 May 2013 04:00:30 +0200 Subject: [PATCH 293/301] matroska_read_seek: Fix used streams for subtitle index compensation Might fix Ticket1907 (I have no testcase so i cant test) Signed-off-by: Michael Niedermayer (cherry picked from commit 4758e32a6c48044f77102a49110c79b4f338f648) Signed-off-by: Michael Niedermayer --- libavformat/matroskadec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index ab42e0a70e..3efed30fb5 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1868,10 +1868,11 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE && !tracks[i].stream->discard != AVDISCARD_ALL) { index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD); - if (index_sub >= 0 - && st->index_entries[index_sub].pos < st->index_entries[index_min].pos - && st->index_entries[index].timestamp - st->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale) - index_min = index_sub; + while(index_sub >= 0 + && index_min >= 0 + && tracks[i].stream->index_entries[index_sub].pos < st->index_entries[index_min].pos + && st->index_entries[index].timestamp - tracks[i].stream->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale) + index_min--; } } From b51c4df35b52ee2bdc01067f83d3c92a4ea7f765 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 30 Aug 2013 23:40:47 +0200 Subject: [PATCH 294/301] avcodec/dsputil: fix signedness in sizeof() comparissions Signed-off-by: Michael Niedermayer (cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760) Signed-off-by: Michael Niedermayer --- libavcodec/dsputil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 07013240c0..060a73cce6 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3217,7 +3217,7 @@ static void clear_blocks_c(DCTELEM *blocks) static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){ long i; - for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ + for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){ long a = *(long*)(src+i); long b = *(long*)(dst+i); *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); @@ -3228,7 +3228,7 @@ static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){ static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ long i; - for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ + for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){ long a = *(long*)(src1+i); long b = *(long*)(src2+i); *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); @@ -3253,7 +3253,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ } }else #endif - for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ + for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){ long a = *(long*)(src1+i); long b = *(long*)(src2+i); *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80); From c7ab9de727e5d1fc89e5c04b751deeac1bc43a21 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 9 Sep 2013 17:58:18 +0200 Subject: [PATCH 295/301] avcodec/ffv1enc: update buffer check for 16bps Signed-off-by: Michael Niedermayer (cherry picked from commit 3728603f1854b5c79d1a64dd3b41b80640ef1e7f) Conflicts: libavcodec/ffv1enc.c (cherry picked from commit c900c6e5c26cd86cf34f9c8d4347cedbd01f3935) --- libavcodec/ffv1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 12056e1208..7a4f4d383d 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -437,7 +437,7 @@ static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], in int run_mode=0; if(s->ac){ - if(c->bytestream_end - c->bytestream < w*20){ + if(c->bytestream_end - c->bytestream < w*35){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } From 243396f06dc42c64d565b3795d274f5f65f46c47 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 23 Sep 2013 01:23:35 +0200 Subject: [PATCH 296/301] update for 0.6.7 Signed-off-by: Michael Niedermayer --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 05e8a4593f..2228cad41f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.6 +0.6.7 From 0cbef38cb81833df36a35cbf2f14453be184c81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Dec 2013 15:02:35 +0200 Subject: [PATCH 297/301] arm: Don't clobber callee saved registers in scalarproduct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit q4-q7/d8-d15 are supposed to not be clobbered by the callee. CC: libav-stable@libav.org Signed-off-by: Martin Storsjö (cherry picked from commit d307e408d4a9ada22df443cc38be77cc5e492694) Signed-off-by: Martin Storsjö --- libavcodec/arm/int_neon.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/arm/int_neon.S b/libavcodec/arm/int_neon.S index e8023e0686..f86bf53f95 100644 --- a/libavcodec/arm/int_neon.S +++ b/libavcodec/arm/int_neon.S @@ -67,10 +67,10 @@ function ff_scalarproduct_int16_neon, export=1 3: vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 - vpadd.s32 d10, d4, d5 - vpadd.s32 d11, d6, d7 + vpadd.s32 d18, d4, d5 + vpadd.s32 d19, d6, d7 vpadd.s32 d0, d16, d17 - vpadd.s32 d1, d10, d11 + vpadd.s32 d1, d18, d19 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] @@ -107,10 +107,10 @@ function ff_scalarproduct_and_madd_int16_neon, export=1 vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 - vpadd.s32 d10, d4, d5 - vpadd.s32 d11, d6, d7 + vpadd.s32 d18, d4, d5 + vpadd.s32 d19, d6, d7 vpadd.s32 d0, d16, d17 - vpadd.s32 d1, d10, d11 + vpadd.s32 d1, d18, d19 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] From a94d12b69027955f1b01aedffc8dd8c7e96a15cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Dec 2013 15:02:35 +0200 Subject: [PATCH 298/301] arm: Don't clobber callee saved registers in scalarproduct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit q4-q7/d8-d15 are supposed to not be clobbered by the callee. CC: libav-stable@libav.org Signed-off-by: Martin Storsjö (cherry picked from commit d307e408d4a9ada22df443cc38be77cc5e492694) --- libavcodec/arm/int_neon.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/arm/int_neon.S b/libavcodec/arm/int_neon.S index e8023e0686..f86bf53f95 100644 --- a/libavcodec/arm/int_neon.S +++ b/libavcodec/arm/int_neon.S @@ -67,10 +67,10 @@ function ff_scalarproduct_int16_neon, export=1 3: vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 - vpadd.s32 d10, d4, d5 - vpadd.s32 d11, d6, d7 + vpadd.s32 d18, d4, d5 + vpadd.s32 d19, d6, d7 vpadd.s32 d0, d16, d17 - vpadd.s32 d1, d10, d11 + vpadd.s32 d1, d18, d19 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] @@ -107,10 +107,10 @@ function ff_scalarproduct_and_madd_int16_neon, export=1 vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 - vpadd.s32 d10, d4, d5 - vpadd.s32 d11, d6, d7 + vpadd.s32 d18, d4, d5 + vpadd.s32 d19, d6, d7 vpadd.s32 d0, d16, d17 - vpadd.s32 d1, d10, d11 + vpadd.s32 d1, d18, d19 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] From 9a073b1f0f27471fdad501d6f1fff0dd1b482d63 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 26 Sep 2013 21:03:48 +0200 Subject: [PATCH 299/301] avcodec/parser: reset indexes on realloc failure Fixes Ticket2982 Signed-off-by: Michael Niedermayer (cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a) Signed-off-by: Michael Niedermayer --- libavcodec/parser.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 864b5f2d2a..1d8eb3a36c 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -271,8 +271,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s if(next == END_NOT_FOUND){ void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - if(!new_buffer) + if(!new_buffer) { + pc->index = 0; return AVERROR(ENOMEM); + } pc->buffer = new_buffer; memcpy(&pc->buffer[pc->index], *buf, *buf_size); pc->index += *buf_size; @@ -285,9 +287,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s /* append to buffer */ if(pc->index){ void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - - if(!new_buffer) + if(!new_buffer) { + pc->overread_index = + pc->index = 0; return AVERROR(ENOMEM); + } pc->buffer = new_buffer; memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; From 101e1b36cccda73709c31b54c90fa1fa7f432d14 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Oct 2013 23:27:28 +0100 Subject: [PATCH 300/301] avcodec/jpeglsdec: check err value for ls_get_code_runterm() Fixes infinite loop Fixes Ticket3086 Signed-off-by: Michael Niedermayer (cherry picked from commit cc0e47b55096361723b364afa43b79a3f5619cdc) Signed-off-by: Michael Niedermayer --- libavcodec/jpeglsdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 6b7dd94647..4dbc88b288 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -143,6 +143,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI ret = ret >> 1; } + if(FFABS(ret) > 0xFFFF) + return -0x10000; /* update state */ state->A[Q] += FFABS(ret) - RItype; ret *= state->twonear; From 0a849fe1f2d7b7b5186f8eade6cd000e20d0df4b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 31 Jul 2015 15:54:38 +0200 Subject: [PATCH 301/301] MAINTAINERS: Remove myself as leader Signed-off-by: Michael Niedermayer (cherry picked from commit f2c58931e629343f7d68258cc2b2d62c5f501ba5) Signed-off-by: Michael Niedermayer --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index f9891fed87..c558bad2c7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8,7 +8,6 @@ FFmpeg code. Project Leader ============== -Michael Niedermayer final design decisions