[SCM] libav/master: Sync post v0.8b2 commits
siretart at users.alioth.debian.org
siretart at users.alioth.debian.org
Mon Jan 16 18:25:45 UTC 2012
The following commit has been merged in the master branch:
commit c81d9267e35551e913c663ae05232930c57c27e8
Author: Reinhard Tartler <siretart at tauware.de>
Date: Mon Jan 16 17:50:49 2012 +0100
Sync post v0.8b2 commits
All these commits will end up in the final 0.8 release.
diff --git a/debian/patches/post-0.8b2/0001-Fix-a-bunch-of-platform-name-and-other-typos.patch b/debian/patches/post-0.8b2/0001-Fix-a-bunch-of-platform-name-and-other-typos.patch
new file mode 100644
index 0000000..5326b20
--- /dev/null
+++ b/debian/patches/post-0.8b2/0001-Fix-a-bunch-of-platform-name-and-other-typos.patch
@@ -0,0 +1,128 @@
+From 5ea20630b4cc96a6538a6a11b08698debe3a303a Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Mon, 12 Dec 2011 21:21:24 +0100
+Subject: [PATCH 01/63] Fix a bunch of platform name and other typos.
+
+---
+ Doxyfile | 2 +-
+ avplay.c | 2 +-
+ configure | 2 +-
+ doc/platform.texi | 6 +++---
+ libavcodec/error_resilience.c | 2 +-
+ libavcodec/msrle.c | 4 ++--
+ tools/patcheck | 2 +-
+ 7 files changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/Doxyfile b/Doxyfile
+index f28fb70..457cf51 100644
+--- a/Doxyfile
++++ b/Doxyfile
+@@ -864,7 +864,7 @@ HTML_DYNAMIC_SECTIONS = NO
+
+ # If the GENERATE_DOCSET tag is set to YES, additional index files
+ # will be generated that can be used as input for Apple's Xcode 3
+-# integrated development environment, introduced with OSX 10.5 (Leopard).
++# integrated development environment, introduced with OS X 10.5 (Leopard).
+ # To create a documentation set, doxygen will generate a Makefile in the
+ # HTML output directory. Running make will produce the docset in that
+ # directory and running "make install" will install the docset in
+diff --git a/avplay.c b/avplay.c
+index 3bbb7ef..4d21234 100644
+--- a/avplay.c
++++ b/avplay.c
+@@ -2692,7 +2692,7 @@ static void toggle_full_screen(void)
+ {
+ is_full_screen = !is_full_screen;
+ #if defined(__APPLE__) && SDL_VERSION_ATLEAST(1, 2, 14)
+- /* OSX needs to empty the picture_queue */
++ /* OS X needs to empty the picture_queue */
+ for (int i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {
+ cur_stream->pictq[i].reallocate = 1;
+ }
+diff --git a/configure b/configure
+index 526aa77..3146641 100755
+--- a/configure
++++ b/configure
+@@ -239,7 +239,7 @@ Advanced options (experts only):
+ --disable-armvfp disable ARM VFP optimizations
+ --disable-iwmmxt disable iwmmxt optimizations
+ --disable-mmi disable MMI optimizations
+- --disable-neon disable neon optimizations
++ --disable-neon disable NEON optimizations
+ --disable-vis disable VIS optimizations
+ --disable-yasm disable use of yasm assembler
+ --enable-pic build position-independent code
+diff --git a/doc/platform.texi b/doc/platform.texi
+index 6a44640..7ec7cb3 100644
+--- a/doc/platform.texi
++++ b/doc/platform.texi
+@@ -45,17 +45,17 @@ bash ./configure
+ @end example
+
+ @anchor{Darwin}
+- at section Darwin (OSX, iPhone)
++ at section Darwin (OS X, iPhone)
+
+ The toolchain provided with Xcode is sufficient to build the basic
+ unacelerated code.
+
+-OSX on PowerPC or ARM (iPhone) requires a preprocessor from
++OS X on PowerPC or ARM (iPhone) requires a preprocessor from
+ @url{http://github.com/yuvi/gas-preprocessor} to build the optimized
+ assembler functions. Just download the Perl script and put it somewhere
+ in your PATH, Libav's configure will pick it up automatically.
+
+-OSX on amd64 and x86 requires @command{yasm} to build most of the
++OS X on AMD64 and x86 requires @command{yasm} to build most of the
+ optimized assembler functions @url{http://mxcl.github.com/homebrew/, Homebrew},
+ @url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix}
+ or @url{http://www.macports.org, MacPorts} can easily provide it.
+diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
+index 855ae77..6ffc4e9 100644
+--- a/libavcodec/error_resilience.c
++++ b/libavcodec/error_resilience.c
+@@ -50,7 +50,7 @@ static void decode_mb(MpegEncContext *s, int ref){
+ h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
+ memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache));
+ assert(ref>=0);
+- /* FIXME: It is posible albeit uncommon that slice references
++ /* FIXME: It is possible albeit uncommon that slice references
+ * differ between slices. We take the easy approach and ignore
+ * it for now. If this turns out to have any relevance in
+ * practice then correct remapping should be added. */
+diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
+index 11ac7be..41f1fd8 100644
+--- a/libavcodec/msrle.c
++++ b/libavcodec/msrle.c
+@@ -1,5 +1,5 @@
+ /*
+- * Micrsoft RLE Video Decoder
++ * Microsoft RLE video decoder
+ * Copyright (C) 2003 the ffmpeg project
+ *
+ * This file is part of Libav.
+@@ -21,7 +21,7 @@
+
+ /**
+ * @file
+- * MS RLE Video Decoder by Mike Melanson (melanson at pcisys.net)
++ * MS RLE video decoder by Mike Melanson (melanson at pcisys.net)
+ * For more information about the MS RLE format, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+diff --git a/tools/patcheck b/tools/patcheck
+index 3061716..94e1232 100755
+--- a/tools/patcheck
++++ b/tools/patcheck
+@@ -67,7 +67,7 @@ $EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^
+ cat $TMP
+ hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $*
+
+-hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed|upto|paket)\b' 'common typos' $*
++hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed|upto|paket|posible)\b' 'common typos' $*
+
+ hiegrep 'av_log\( *NULL' 'Missing context in av_log' $*
+ hiegrep '[^sn]printf' 'Please use av_log' $*
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0002-doc-Fix-names-of-av_log-color-environment-variables.patch b/debian/patches/post-0.8b2/0002-doc-Fix-names-of-av_log-color-environment-variables.patch
new file mode 100644
index 0000000..d9e0a95
--- /dev/null
+++ b/debian/patches/post-0.8b2/0002-doc-Fix-names-of-av_log-color-environment-variables.patch
@@ -0,0 +1,27 @@
+From 1466a5181b516a4d33cfd0da0c8222589742df27 Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Wed, 11 Jan 2012 10:49:49 +0100
+Subject: [PATCH 02/63] doc: Fix names of av_log color environment variables.
+
+---
+ doc/avtools-common-opts.texi | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
+index 18e7ba5..badd358 100644
+--- a/doc/avtools-common-opts.texi
++++ b/doc/avtools-common-opts.texi
+@@ -119,8 +119,8 @@ Set the logging level used by the library.
+ By default the program logs to stderr, if coloring is supported by the
+ terminal, colors are used to mark errors and warnings. Log coloring
+ can be disabled setting the environment variable
+- at env{FFMPEG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting
+-the environment variable @env{FFMPEG_FORCE_COLOR}.
++ at env{AV_LOG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting
++the environment variable @env{AV_LOG_FORCE_COLOR}.
+ The use of the environment variable @env{NO_COLOR} is deprecated and
+ will be dropped in a following Libav version.
+
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0003-doc-Replace-ffmpeg-references-in-avserver-config-fil.patch b/debian/patches/post-0.8b2/0003-doc-Replace-ffmpeg-references-in-avserver-config-fil.patch
new file mode 100644
index 0000000..249ae25
--- /dev/null
+++ b/debian/patches/post-0.8b2/0003-doc-Replace-ffmpeg-references-in-avserver-config-fil.patch
@@ -0,0 +1,51 @@
+From f1355dfcd6cf0a4d413d7b04c2c166b825d559ce Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Wed, 11 Jan 2012 10:50:35 +0100
+Subject: [PATCH 03/63] doc: Replace ffmpeg references in avserver config file
+ by avconv.
+
+---
+ doc/avserver.conf | 12 ++++++------
+ 1 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/doc/avserver.conf b/doc/avserver.conf
+index 2105ac5..1f21f4d 100644
+--- a/doc/avserver.conf
++++ b/doc/avserver.conf
+@@ -31,16 +31,16 @@ NoDaemon
+
+ ##################################################################
+ # Definition of the live feeds. Each live feed contains one video
+-# and/or audio sequence coming from an ffmpeg encoder or another
++# and/or audio sequence coming from an avconv encoder or another
+ # avserver. This sequence may be encoded simultaneously with several
+ # codecs at several resolutions.
+
+ <Feed feed1.ffm>
+
+-# You must use 'ffmpeg' to send a live feed to avserver. In this
++# You must use 'avconv' to send a live feed to avserver. In this
+ # example, you can type:
+ #
+-# ffmpeg http://localhost:8090/feed1.ffm
++# avconv http://localhost:8090/feed1.ffm
+
+ # avserver can also do time shifting. It means that it can stream any
+ # previously recorded live stream. The request should contain:
+@@ -55,10 +55,10 @@ FileMaxSize 200K
+ # ReadOnlyFile /saved/specialvideo.ffm
+ # This marks the file as readonly and it will not be deleted or updated.
+
+-# Specify launch in order to start ffmpeg automatically.
+-# First ffmpeg must be defined with an appropriate path if needed,
++# Specify launch in order to start avconv automatically.
++# First avconv must be defined with an appropriate path if needed,
+ # after that options can follow, but avoid adding the http:// field
+-#Launch ffmpeg
++#Launch avconv
+
+ # Only allow connections from localhost to the feed.
+ ACL allow 127.0.0.1
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0004-avcodec-add-GSM-parser.patch b/debian/patches/post-0.8b2/0004-avcodec-add-GSM-parser.patch
new file mode 100644
index 0000000..81c57cc
--- /dev/null
+++ b/debian/patches/post-0.8b2/0004-avcodec-add-GSM-parser.patch
@@ -0,0 +1,262 @@
+From 82390f57d1714fdc952c15ba91511d93f2e59bfc Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Sun, 8 Jan 2012 19:50:31 -0500
+Subject: [PATCH 04/63] avcodec: add GSM parser
+
+The WAVE demuxer returns packets with many blocks per frame, which needs to be
+parsed into single blocks. This has a side-effect of fixing the timestamps.
+---
+ Changelog | 5 +++
+ libavcodec/Makefile | 1 +
+ libavcodec/allcodecs.c | 1 +
+ libavcodec/gsm.h | 31 ++++++++++++++++
+ libavcodec/gsm_parser.c | 79 ++++++++++++++++++++++++++++++++++++++++++
+ libavcodec/gsmdec_data.h | 5 ---
+ libavcodec/gsmdec_template.c | 1 +
+ libavcodec/libgsm.c | 7 +---
+ libavcodec/msgsmdec.c | 1 +
+ libavcodec/version.h | 4 +-
+ 10 files changed, 123 insertions(+), 12 deletions(-)
+ create mode 100644 libavcodec/gsm.h
+ create mode 100644 libavcodec/gsm_parser.c
+
+diff --git a/Changelog b/Changelog
+index e69bde5..cbe61f5 100644
+--- a/Changelog
++++ b/Changelog
+@@ -2,6 +2,11 @@ Entries are sorted chronologically from oldest to youngest within each release,
+ releases are sorted from youngest to oldest.
+
+
++version <next>:
++
++- GSM audio parser
++
++
+ version 0.8_beta2:
+
+ - Automatic thread count based on detection number of (available) CPU cores
+diff --git a/libavcodec/Makefile b/libavcodec/Makefile
+index 741df91..1e8d09b 100644
+--- a/libavcodec/Makefile
++++ b/libavcodec/Makefile
+@@ -608,6 +608,7 @@ OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o
+ OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o
+ OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o
+ OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
++OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o
+ OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
+ OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
+ OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \
+diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
+index 3980982..5289692 100644
+--- a/libavcodec/allcodecs.c
++++ b/libavcodec/allcodecs.c
+@@ -399,6 +399,7 @@ void avcodec_register_all(void)
+ REGISTER_PARSER (DVBSUB, dvbsub);
+ REGISTER_PARSER (DVDSUB, dvdsub);
+ REGISTER_PARSER (FLAC, flac);
++ REGISTER_PARSER (GSM, gsm);
+ REGISTER_PARSER (H261, h261);
+ REGISTER_PARSER (H263, h263);
+ REGISTER_PARSER (H264, h264);
+diff --git a/libavcodec/gsm.h b/libavcodec/gsm.h
+new file mode 100644
+index 0000000..c7c3e22
+--- /dev/null
++++ b/libavcodec/gsm.h
+@@ -0,0 +1,31 @@
++/*
++ * GSM common header
++ *
++ * 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
++ */
++
++#ifndef AVCODEC_GSM_H
++#define AVCODEC_GSM_H
++
++/* bytes per block */
++#define GSM_BLOCK_SIZE 33
++#define GSM_MS_BLOCK_SIZE 65
++
++/* samples per block */
++#define GSM_FRAME_SIZE 160
++
++#endif /* AVCODEC_GSM_H */
+diff --git a/libavcodec/gsm_parser.c b/libavcodec/gsm_parser.c
+new file mode 100644
+index 0000000..a2965d3
+--- /dev/null
++++ b/libavcodec/gsm_parser.c
+@@ -0,0 +1,79 @@
++/*
++ * Copyright (c) 2012 Justin Ruggles
++ *
++ * 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
++ */
++
++/**
++ * @file
++ * GSM audio parser
++ *
++ * Splits packets into individual blocks.
++ */
++
++#include "parser.h"
++#include "gsm.h"
++
++typedef struct GSMParseContext {
++ ParseContext pc;
++ int block_size;
++ int remaining;
++} GSMParseContext;
++
++static int gsm_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
++ const uint8_t **poutbuf, int *poutbuf_size,
++ const uint8_t *buf, int buf_size)
++{
++ GSMParseContext *s = s1->priv_data;
++ ParseContext *pc = &s->pc;
++ int next;
++
++ if (!s->block_size) {
++ switch (avctx->codec_id) {
++ case CODEC_ID_GSM: s->block_size = GSM_BLOCK_SIZE; break;
++ case CODEC_ID_GSM_MS: s->block_size = GSM_MS_BLOCK_SIZE; break;
++ default:
++ return AVERROR(EINVAL);
++ }
++ }
++
++ if (!s->remaining)
++ s->remaining = s->block_size;
++ if (s->remaining <= buf_size) {
++ next = s->remaining;
++ s->remaining = 0;
++ } else {
++ next = END_NOT_FOUND;
++ s->remaining -= buf_size;
++ }
++
++ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
++ *poutbuf = NULL;
++ *poutbuf_size = 0;
++ return buf_size;
++ }
++ *poutbuf = buf;
++ *poutbuf_size = buf_size;
++ return next;
++}
++
++AVCodecParser ff_gsm_parser = {
++ .codec_ids = { CODEC_ID_GSM, CODEC_ID_GSM_MS },
++ .priv_data_size = sizeof(GSMParseContext),
++ .parser_parse = gsm_parse,
++ .parser_close = ff_parse_close,
++};
+diff --git a/libavcodec/gsmdec_data.h b/libavcodec/gsmdec_data.h
+index 21789f7..2ff2322 100644
+--- a/libavcodec/gsmdec_data.h
++++ b/libavcodec/gsmdec_data.h
+@@ -25,11 +25,6 @@
+ #include <stdint.h>
+ #include "avcodec.h"
+
+-// input and output sizes in byte
+-#define GSM_BLOCK_SIZE 33
+-#define GSM_MS_BLOCK_SIZE 65
+-#define GSM_FRAME_SIZE 160
+-
+ typedef struct {
+ AVFrame frame;
+ // Contains first 120 elements from the previous frame
+diff --git a/libavcodec/gsmdec_template.c b/libavcodec/gsmdec_template.c
+index 7e57c71..b5222af 100644
+--- a/libavcodec/gsmdec_template.c
++++ b/libavcodec/gsmdec_template.c
+@@ -25,6 +25,7 @@
+ */
+
+ #include "get_bits.h"
++#include "gsm.h"
+ #include "gsmdec_data.h"
+
+ static void apcm_dequant_add(GetBitContext *gb, int16_t *dst)
+diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c
+index 16d9972..1fa04cf 100644
+--- a/libavcodec/libgsm.c
++++ b/libavcodec/libgsm.c
+@@ -27,13 +27,10 @@
+
+ // The idiosyncrasies of GSM-in-WAV are explained at http://kbs.cs.tu-berlin.de/~jutta/toast.html
+
+-#include "avcodec.h"
+ #include <gsm/gsm.h>
+
+-// gsm.h misses some essential constants
+-#define GSM_BLOCK_SIZE 33
+-#define GSM_MS_BLOCK_SIZE 65
+-#define GSM_FRAME_SIZE 160
++#include "avcodec.h"
++#include "gsm.h"
+
+ static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
+ if (avctx->channels > 1) {
+diff --git a/libavcodec/msgsmdec.c b/libavcodec/msgsmdec.c
+index 1a288ee..52b0f5d 100644
+--- a/libavcodec/msgsmdec.c
++++ b/libavcodec/msgsmdec.c
+@@ -22,6 +22,7 @@
+ #define BITSTREAM_READER_LE
+ #include "avcodec.h"
+ #include "msgsmdec.h"
++#include "gsm.h"
+ #include "gsmdec_template.c"
+
+ int ff_msgsm_decode_block(AVCodecContext *avctx, int16_t *samples,
+diff --git a/libavcodec/version.h b/libavcodec/version.h
+index 1317ef0..87838c0 100644
+--- a/libavcodec/version.h
++++ b/libavcodec/version.h
+@@ -21,8 +21,8 @@
+ #define AVCODEC_VERSION_H
+
+ #define LIBAVCODEC_VERSION_MAJOR 53
+-#define LIBAVCODEC_VERSION_MINOR 32
+-#define LIBAVCODEC_VERSION_MICRO 2
++#define LIBAVCODEC_VERSION_MINOR 33
++#define LIBAVCODEC_VERSION_MICRO 0
+
+ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
+ LIBAVCODEC_VERSION_MINOR, \
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0005-gsm-demuxer-return-packets-with-only-1-gsm-block-at-.patch b/debian/patches/post-0.8b2/0005-gsm-demuxer-return-packets-with-only-1-gsm-block-at-.patch
new file mode 100644
index 0000000..dcbdc34
--- /dev/null
+++ b/debian/patches/post-0.8b2/0005-gsm-demuxer-return-packets-with-only-1-gsm-block-at-.patch
@@ -0,0 +1,45 @@
+From 467879eb54526d187847bbbd32723500ab0ab330 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Mon, 9 Jan 2012 13:48:46 -0500
+Subject: [PATCH 05/63] gsm demuxer: return packets with only 1 gsm block at a
+ time.
+
+fixes stream copy of raw gsm to mov.
+tested with QuickTime.
+---
+ libavformat/gsmdec.c | 5 ++---
+ 1 files changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c
+index 2360887..a23ce3b 100644
+--- a/libavformat/gsmdec.c
++++ b/libavformat/gsmdec.c
+@@ -37,7 +37,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)
+ {
+ int ret, size;
+
+- size = GSM_BLOCK_SIZE * 32;
++ size = GSM_BLOCK_SIZE;
+
+ pkt->pos = avio_tell(s->pb);
+ pkt->stream_index = 0;
+@@ -48,7 +48,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)
+ return ret < 0 ? ret : AVERROR(EIO);
+ }
+ pkt->size = ret;
+- pkt->duration = ret / GSM_BLOCK_SIZE;
++ pkt->duration = 1;
+ pkt->pts = pkt->pos / GSM_BLOCK_SIZE;
+
+ return 0;
+@@ -65,7 +65,6 @@ static int gsm_read_header(AVFormatContext *s, AVFormatParameters *ap)
+ st->codec->codec_id = s->iformat->value;
+ st->codec->channels = 1;
+ st->codec->sample_rate = c->sample_rate;
+- st->codec->block_align = GSM_BLOCK_SIZE;
+ st->codec->bit_rate = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES;
+
+ avpriv_set_pts_info(st, 64, GSM_BLOCK_SAMPLES, GSM_SAMPLE_RATE);
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0006-gsm-demuxer-use-generic-seeking-instead-of-a-gsm-spe.patch b/debian/patches/post-0.8b2/0006-gsm-demuxer-use-generic-seeking-instead-of-a-gsm-spe.patch
new file mode 100644
index 0000000..06c702a
--- /dev/null
+++ b/debian/patches/post-0.8b2/0006-gsm-demuxer-use-generic-seeking-instead-of-a-gsm-spe.patch
@@ -0,0 +1,68 @@
+From f01f6a847474755ee00a86c599cda3cbadef34fe Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Mon, 9 Jan 2012 13:49:52 -0500
+Subject: [PATCH 06/63] gsm demuxer: use generic seeking instead of a
+ gsm-specific function.
+
+Since packets all contain only a single block, the generic seek function can
+be used while still maintaining block-accuracy.
+---
+ libavformat/gsmdec.c | 35 +----------------------------------
+ 1 files changed, 1 insertions(+), 34 deletions(-)
+
+diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c
+index a23ce3b..443f820 100644
+--- a/libavformat/gsmdec.c
++++ b/libavformat/gsmdec.c
+@@ -72,39 +72,6 @@ static int gsm_read_header(AVFormatContext *s, AVFormatParameters *ap)
+ return 0;
+ }
+
+-static int gsm_read_seek2(AVFormatContext *s, int stream_index, int64_t min_ts,
+- int64_t ts, int64_t max_ts, int flags)
+-{
+- GSMDemuxerContext *c = s->priv_data;
+-
+- /* convert timestamps to file positions */
+- if (!(flags & AVSEEK_FLAG_BYTE)) {
+- if (stream_index < 0) {
+- AVRational bitrate_q = { GSM_BLOCK_SAMPLES, c->sample_rate * GSM_BLOCK_SIZE };
+- ts = av_rescale_q(ts, AV_TIME_BASE_Q, bitrate_q);
+- min_ts = av_rescale_q(min_ts, AV_TIME_BASE_Q, bitrate_q);
+- max_ts = av_rescale_q(max_ts, AV_TIME_BASE_Q, bitrate_q);
+- } else {
+- ts *= GSM_BLOCK_SIZE;
+- min_ts *= GSM_BLOCK_SIZE;
+- max_ts *= GSM_BLOCK_SIZE;
+- }
+- }
+- /* round to nearest block boundary */
+- ts = (ts + GSM_BLOCK_SIZE / 2) / GSM_BLOCK_SIZE * GSM_BLOCK_SIZE;
+- ts = FFMAX(0, ts);
+-
+- /* handle min/max */
+- while (ts < min_ts)
+- ts += GSM_BLOCK_SIZE;
+- while (ts > max_ts)
+- ts -= GSM_BLOCK_SIZE;
+- if (ts < min_ts || ts > max_ts)
+- return -1;
+-
+- return avio_seek(s->pb, ts, SEEK_SET);
+-}
+-
+ static const AVOption options[] = {
+ { "sample_rate", "", offsetof(GSMDemuxerContext, sample_rate),
+ AV_OPT_TYPE_INT, {.dbl = GSM_SAMPLE_RATE}, 1, INT_MAX / GSM_BLOCK_SIZE,
+@@ -125,7 +92,7 @@ AVInputFormat ff_gsm_demuxer = {
+ .priv_data_size = sizeof(GSMDemuxerContext),
+ .read_header = gsm_read_header,
+ .read_packet = gsm_read_packet,
+- .read_seek2 = gsm_read_seek2,
++ .flags = AVFMT_GENERIC_INDEX,
+ .extensions = "gsm",
+ .value = CODEC_ID_GSM,
+ .priv_class = &class,
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0007-pcmenc-set-frame_size-to-0.patch b/debian/patches/post-0.8b2/0007-pcmenc-set-frame_size-to-0.patch
new file mode 100644
index 0000000..c3583d7
--- /dev/null
+++ b/debian/patches/post-0.8b2/0007-pcmenc-set-frame_size-to-0.patch
@@ -0,0 +1,27 @@
+From 56f22b7e16006a4201ed4cf9d21e5ec26faea638 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Tue, 10 Jan 2012 15:17:39 -0500
+Subject: [PATCH 07/63] pcmenc: set frame_size to 0.
+
+This indicates that the actual frame size is based on the buf_size passed to
+avcodec_encode_audio().
+---
+ libavcodec/pcm.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
+index 76d5c10..3223112 100644
+--- a/libavcodec/pcm.c
++++ b/libavcodec/pcm.c
+@@ -33,7 +33,7 @@
+
+ static av_cold int pcm_encode_init(AVCodecContext *avctx)
+ {
+- avctx->frame_size = 1;
++ avctx->frame_size = 0;
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_ALAW:
+ pcm_alaw_tableinit();
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0008-fft-init-functions-with-INIT_XMM-YMM.patch b/debian/patches/post-0.8b2/0008-fft-init-functions-with-INIT_XMM-YMM.patch
new file mode 100644
index 0000000..36bba23
--- /dev/null
+++ b/debian/patches/post-0.8b2/0008-fft-init-functions-with-INIT_XMM-YMM.patch
@@ -0,0 +1,36 @@
+From e7d02b04dcfb65d1873b81bd3281442ac5ddec1d Mon Sep 17 00:00:00 2001
+From: Henrik Gramner <hengar-6 at student.ltu.se>
+Date: Wed, 11 Jan 2012 17:40:34 +0000
+Subject: [PATCH 08/63] fft: init functions with INIT_XMM/YMM.
+
+This is required to handle clobbering of XMM registers on Win64
+correctly. Fixes FFT and all tests depending on FFT on Win64.
+
+Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>
+Signed-off-by: Janne Grunau <janne-libav at jannau.net>
+---
+ libavcodec/x86/fft_mmx.asm | 3 +++
+ 1 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/x86/fft_mmx.asm b/libavcodec/x86/fft_mmx.asm
+index 27276a1..d6d07b8 100644
+--- a/libavcodec/x86/fft_mmx.asm
++++ b/libavcodec/x86/fft_mmx.asm
+@@ -639,11 +639,14 @@ cglobal fft_dispatch%3%2, 2,5,8, z, nbits
+ %endmacro ; DECL_FFT
+
+ %ifdef HAVE_AVX
++INIT_YMM
+ DECL_FFT 6, _avx
+ DECL_FFT 6, _avx, _interleave
+ %endif
++INIT_XMM
+ DECL_FFT 5, _sse
+ DECL_FFT 5, _sse, _interleave
++INIT_MMX
+ DECL_FFT 4, _3dn
+ DECL_FFT 4, _3dn, _interleave
+ DECL_FFT 4, _3dn2
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0009-latmdec-Check-AudioSpecificConfig-length-before-deco.patch b/debian/patches/post-0.8b2/0009-latmdec-Check-AudioSpecificConfig-length-before-deco.patch
new file mode 100644
index 0000000..3a933e1
--- /dev/null
+++ b/debian/patches/post-0.8b2/0009-latmdec-Check-AudioSpecificConfig-length-before-deco.patch
@@ -0,0 +1,30 @@
+From b5fc571e4f730579f328ae9cf77435cb7fddc53d Mon Sep 17 00:00:00 2001
+From: Alex Converse <alex.converse at gmail.com>
+Date: Wed, 11 Jan 2012 14:03:57 -0800
+Subject: [PATCH 09/63] latmdec: Check AudioSpecificConfig length before
+ decoding extradata.
+
+This is different than a normal get_bits() over read because
+decode_audio_specific_config() creates its own GetBitContext.
+
+Fixes Bug 170.
+---
+ libavcodec/aacdec.c | 2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
+index b2fc740..ca1a876 100644
+--- a/libavcodec/aacdec.c
++++ b/libavcodec/aacdec.c
+@@ -2363,6 +2363,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
+ "config not byte aligned.\n", 1);
+ return AVERROR_INVALIDDATA;
+ }
++ if (asclen <= 0)
++ return AVERROR_INVALIDDATA;
+ bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
+ gb->buffer + (config_start_bit / 8),
+ asclen, sync_extension);
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0010-rgb2rgb-rgb12tobgr12.patch b/debian/patches/post-0.8b2/0010-rgb2rgb-rgb12tobgr12.patch
new file mode 100644
index 0000000..5f6a6be
--- /dev/null
+++ b/debian/patches/post-0.8b2/0010-rgb2rgb-rgb12tobgr12.patch
@@ -0,0 +1,63 @@
+From f7f3563214a4deb4bf664057a4cce0c4bf0bdb02 Mon Sep 17 00:00:00 2001
+From: Paul B Mahol <onemda at gmail.com>
+Date: Wed, 11 Jan 2012 19:19:00 +0000
+Subject: [PATCH 10/63] rgb2rgb: rgb12tobgr12()
+
+Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>
+---
+ libswscale/rgb2rgb.c | 13 +++++++++++++
+ libswscale/rgb2rgb.h | 1 +
+ libswscale/swscale_unscaled.c | 1 +
+ 3 files changed, 15 insertions(+), 0 deletions(-)
+
+diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
+index 0f07e57..9fbb6cf 100644
+--- a/libswscale/rgb2rgb.c
++++ b/libswscale/rgb2rgb.c
+@@ -282,6 +282,19 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
+ }
+ }
+
++void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
++{
++ uint16_t *d = (uint16_t*)dst;
++ uint16_t *s = (uint16_t*)src;
++ int i;
++ int num_pixels = src_size >> 1;
++
++ for (i = 0; i < num_pixels; i++) {
++ unsigned rgb = s[i];
++ d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF;
++ }
++}
++
+ void bgr8torgb8(const uint8_t *src, uint8_t *dst, int src_size)
+ {
+ int i;
+diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h
+index 833a984..bfb85d7 100644
+--- a/libswscale/rgb2rgb.h
++++ b/libswscale/rgb2rgb.h
+@@ -62,6 +62,7 @@ void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size);
+ void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size);
+ void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size);
+ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size);
++void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size);
+ void bgr8torgb8(const uint8_t *src, uint8_t *dst, int src_size);
+
+ void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size);
+diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
+index 5769548..a1b7199 100644
+--- a/libswscale/swscale_unscaled.c
++++ b/libswscale/swscale_unscaled.c
+@@ -400,6 +400,7 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
+ } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
+ (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
+ switch (srcId | (dstId << 16)) {
++ case 0x000C000C: conv = rgb12tobgr12; break;
+ case 0x000F000F: conv = rgb15tobgr15; break;
+ case 0x000F0010: conv = rgb16tobgr15; break;
+ case 0x000F0018: conv = rgb24tobgr15; break;
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0011-vsrc_buffer-release-the-buffer-on-uninit.patch b/debian/patches/post-0.8b2/0011-vsrc_buffer-release-the-buffer-on-uninit.patch
new file mode 100644
index 0000000..3240841
--- /dev/null
+++ b/debian/patches/post-0.8b2/0011-vsrc_buffer-release-the-buffer-on-uninit.patch
@@ -0,0 +1,39 @@
+From 43fe6a29050fc34848731aa220292587f7ace5bd Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Fri, 30 Dec 2011 20:56:06 +0100
+Subject: [PATCH 11/63] vsrc_buffer: release the buffer on uninit.
+
+---
+ libavfilter/vsrc_buffer.c | 9 +++++++++
+ 1 files changed, 9 insertions(+), 0 deletions(-)
+
+diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
+index 178b3e6..e5b96a6 100644
+--- a/libavfilter/vsrc_buffer.c
++++ b/libavfilter/vsrc_buffer.c
+@@ -114,6 +114,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+ return 0;
+ }
+
++static av_cold void uninit(AVFilterContext *ctx)
++{
++ BufferSourceContext *s = ctx->priv;
++ if (s->buf)
++ avfilter_unref_buffer(s->buf);
++ s->buf = NULL;
++}
++
+ static int query_formats(AVFilterContext *ctx)
+ {
+ BufferSourceContext *c = ctx->priv;
+@@ -167,6 +175,7 @@ AVFilter avfilter_vsrc_buffer = {
+ .query_formats = query_formats,
+
+ .init = init,
++ .uninit = uninit,
+
+ .inputs = (AVFilterPad[]) {{ .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0012-lavfi-move-version-macros-to-a-new-installed-header-.patch b/debian/patches/post-0.8b2/0012-lavfi-move-version-macros-to-a-new-installed-header-.patch
new file mode 100644
index 0000000..1916617
--- /dev/null
+++ b/debian/patches/post-0.8b2/0012-lavfi-move-version-macros-to-a-new-installed-header-.patch
@@ -0,0 +1,120 @@
+From 3167dc9515810bbdd86d99d773bcf84657d2e72a Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Sat, 31 Dec 2011 16:20:10 +0100
+Subject: [PATCH 12/63] lavfi: move version macros to a new installed header
+ version.h
+
+---
+ doc/APIchanges | 3 +++
+ libavfilter/Makefile | 2 +-
+ libavfilter/avfilter.h | 14 ++------------
+ libavfilter/version.h | 43 +++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 49 insertions(+), 13 deletions(-)
+ create mode 100644 libavfilter/version.h
+
+diff --git a/doc/APIchanges b/doc/APIchanges
+index e94c656..751566a 100644
+--- a/doc/APIchanges
++++ b/doc/APIchanges
+@@ -13,6 +13,9 @@ libavutil: 2011-04-18
+
+ API changes, most recent first:
+
++2012-01-xx - xxxxxxx - lavfi 2.15.0
++ Add a new installed header -- libavfilter/version.h -- with version macros.
++
+ 2011-01-03 - b73ec05 - lavu 51.21.0
+ Add av_popcount64
+
+diff --git a/libavfilter/Makefile b/libavfilter/Makefile
+index 78c4692..09865c1 100644
+--- a/libavfilter/Makefile
++++ b/libavfilter/Makefile
+@@ -3,7 +3,7 @@ FFLIBS = avutil
+ FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
+ FFLIBS-$(CONFIG_SCALE_FILTER) += swscale
+
+-HEADERS = avfilter.h avfiltergraph.h buffersrc.h vsrc_buffer.h
++HEADERS = avfilter.h avfiltergraph.h buffersrc.h version.h vsrc_buffer.h
+
+ OBJS = allfilters.o \
+ avfilter.o \
+diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
+index cffcfca..068c50b 100644
+--- a/libavfilter/avfilter.h
++++ b/libavfilter/avfilter.h
+@@ -29,20 +29,10 @@
+ #include "libavutil/rational.h"
+ #include "libavcodec/avcodec.h"
+
+-#define LIBAVFILTER_VERSION_MAJOR 2
+-#define LIBAVFILTER_VERSION_MINOR 14
+-#define LIBAVFILTER_VERSION_MICRO 0
+-
+-#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
+- LIBAVFILTER_VERSION_MINOR, \
+- LIBAVFILTER_VERSION_MICRO)
+-#define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
+- LIBAVFILTER_VERSION_MINOR, \
+- LIBAVFILTER_VERSION_MICRO)
+-#define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
+-
+ #include <stddef.h>
+
++#include "libavfilter/version.h"
++
+ /**
+ * Return the LIBAVFILTER_VERSION_INT constant.
+ */
+diff --git a/libavfilter/version.h b/libavfilter/version.h
+new file mode 100644
+index 0000000..09d6700
+--- /dev/null
++++ b/libavfilter/version.h
+@@ -0,0 +1,43 @@
++/*
++ * Version macros.
++ *
++ * 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
++ */
++
++#ifndef AVFILTER_VERSION_H
++#define AVFILTER_VERSION_H
++
++/**
++ * @file
++ * Libavfilter version macros
++ */
++
++#include "libavutil/avutil.h"
++
++#define LIBAVFILTER_VERSION_MAJOR 2
++#define LIBAVFILTER_VERSION_MINOR 15
++#define LIBAVFILTER_VERSION_MICRO 0
++
++#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
++ LIBAVFILTER_VERSION_MINOR, \
++ LIBAVFILTER_VERSION_MICRO)
++#define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
++ LIBAVFILTER_VERSION_MINOR, \
++ LIBAVFILTER_VERSION_MICRO)
++#define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
++
++#endif // AVFILTER_VERSION_H
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0013-avconv-use-AVFrame.width-height-format-instead-of-co.patch b/debian/patches/post-0.8b2/0013-avconv-use-AVFrame.width-height-format-instead-of-co.patch
new file mode 100644
index 0000000..8ea641b
--- /dev/null
+++ b/debian/patches/post-0.8b2/0013-avconv-use-AVFrame.width-height-format-instead-of-co.patch
@@ -0,0 +1,54 @@
+From b2ce3b998b90c9ec8dcefe4b2c45fcf5b2f0a903 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Sat, 31 Dec 2011 17:15:50 +0100
+Subject: [PATCH 13/63] avconv: use AVFrame.width/height/format instead of
+ corresponding AVCodecContext fields
+
+---
+ avconv.c | 15 +++++++--------
+ 1 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/avconv.c b/avconv.c
+index c96cc73..817c0cf 100644
+--- a/avconv.c
++++ b/avconv.c
+@@ -1262,19 +1262,18 @@ static void do_video_resample(OutputStream *ost,
+ AVFrame **out_picture)
+ {
+ int resample_changed = 0;
+- AVCodecContext *dec = ist->st->codec;
+ *out_picture = in_picture;
+
+- resample_changed = ost->resample_width != dec->width ||
+- ost->resample_height != dec->height ||
+- ost->resample_pix_fmt != dec->pix_fmt;
++ resample_changed = ost->resample_width != in_picture->width ||
++ ost->resample_height != in_picture->height ||
++ ost->resample_pix_fmt != in_picture->format;
+
+ if (resample_changed) {
+ av_log(NULL, AV_LOG_INFO,
+ "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
+ ist->file_index, ist->st->index,
+ ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt),
+- dec->width , dec->height , av_get_pix_fmt_name(dec->pix_fmt));
++ in_picture->width, in_picture->height, av_get_pix_fmt_name(in_picture->format));
+ if (!ost->video_resample)
+ ost->video_resample = 1;
+ }
+@@ -1301,9 +1300,9 @@ static void do_video_resample(OutputStream *ost,
+ 0, ost->resample_height, (*out_picture)->data, (*out_picture)->linesize);
+ }
+ if (resample_changed) {
+- ost->resample_width = dec->width;
+- ost->resample_height = dec->height;
+- ost->resample_pix_fmt = dec->pix_fmt;
++ ost->resample_width = in_picture->width;
++ ost->resample_height = in_picture->height;
++ ost->resample_pix_fmt = in_picture->format;
+ }
+ }
+ #endif
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0014-rv34-DC-only-inverse-transform.patch b/debian/patches/post-0.8b2/0014-rv34-DC-only-inverse-transform.patch
new file mode 100644
index 0000000..36b0200
--- /dev/null
+++ b/debian/patches/post-0.8b2/0014-rv34-DC-only-inverse-transform.patch
@@ -0,0 +1,452 @@
+From 3faa303a47e0c3b59a53988e0f76018930c6cb1a Mon Sep 17 00:00:00 2001
+From: Christophe GISQUET <christophe.gisquet at gmail.com>
+Date: Sun, 1 Jan 2012 18:33:22 +0100
+Subject: [PATCH 14/63] rv34: DC-only inverse transform
+
+When decoding coefficients, detect whether the block is DC-only, and take
+advantage of this knowledge to perform DC-only inverse transform.
+
+This is achieved by:
+- first, changing the 108x4 element modulo_three_table into a 108 element
+ table (kind of base4), and accessing each value using mask and shifts.
+- then, checking low bits for 0 (as they represent the presence of higher
+ frequency coefficients)
+
+Also provide x86 SIMD code for the DC-only inverse transform.
+
+Signed-off-by: Kostya Shishkov <kostya.shishkov at gmail.com>
+---
+ libavcodec/rv34.c | 95 +++++++++++++++++++++++++----------------
+ libavcodec/rv34data.h | 44 +++++++------------
+ libavcodec/rv34dsp.c | 24 ++++++++++
+ libavcodec/rv34dsp.h | 2 +
+ libavcodec/x86/Makefile | 6 ++-
+ libavcodec/x86/rv34dsp.asm | 55 +++++++++++++++++++++++
+ libavcodec/x86/rv34dsp_init.c | 40 +++++++++++++++++
+ 7 files changed, 200 insertions(+), 66 deletions(-)
+ create mode 100644 libavcodec/x86/rv34dsp.asm
+ create mode 100644 libavcodec/x86/rv34dsp_init.c
+
+diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
+index ec826fd..6cfefa0 100644
+--- a/libavcodec/rv34.c
++++ b/libavcodec/rv34.c
+@@ -204,7 +204,7 @@ static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table)
+ }
+
+ for(i = 0; i < 4; i++){
+- t = modulo_three_table[code][i];
++ t = (modulo_three_table[code] >> (6 - 2*i)) & 3;
+ if(t == 1)
+ cbp |= cbp_masks[get_bits1(gb)] << i;
+ if(t == 2)
+@@ -238,41 +238,42 @@ static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *
+ */
+ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q)
+ {
+- int coeffs[4];
++ int flags = modulo_three_table[code];
+
+- coeffs[0] = modulo_three_table[code][0];
+- coeffs[1] = modulo_three_table[code][1];
+- coeffs[2] = modulo_three_table[code][2];
+- coeffs[3] = modulo_three_table[code][3];
+- decode_coeff(dst , coeffs[0], 3, gb, vlc, q);
++ decode_coeff( dst+0, (flags >> 6) , 3, gb, vlc, q);
+ if(is_block2){
+- decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q);
+- decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q);
++ decode_coeff(dst+8, (flags >> 4) & 3, 2, gb, vlc, q);
++ decode_coeff(dst+1, (flags >> 2) & 3, 2, gb, vlc, q);
+ }else{
+- decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q);
+- decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q);
++ decode_coeff(dst+1, (flags >> 4) & 3, 2, gb, vlc, q);
++ decode_coeff(dst+8, (flags >> 2) & 3, 2, gb, vlc, q);
+ }
+- decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q);
++ decode_coeff( dst+9, (flags >> 0) & 3, 2, gb, vlc, q);
++}
++
++/**
++ * Decode a single coefficient.
++ */
++static inline void decode_subblock1(DCTELEM *dst, int code, GetBitContext *gb, VLC *vlc, int q)
++{
++ int coeff = modulo_three_table[code] >> 6;
++ decode_coeff(dst, coeff, 3, gb, vlc, q);
+ }
+
+ static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc,
+ int q_dc, int q_ac1, int q_ac2)
+ {
+- int coeffs[4];
++ int flags = modulo_three_table[code];
+
+- coeffs[0] = modulo_three_table[code][0];
+- coeffs[1] = modulo_three_table[code][1];
+- coeffs[2] = modulo_three_table[code][2];
+- coeffs[3] = modulo_three_table[code][3];
+- decode_coeff(dst , coeffs[0], 3, gb, vlc, q_dc);
++ decode_coeff( dst+0, (flags >> 6) , 3, gb, vlc, q_dc);
+ if(is_block2){
+- decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q_ac1);
+- decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q_ac1);
++ decode_coeff(dst+8, (flags >> 4) & 3, 2, gb, vlc, q_ac1);
++ decode_coeff(dst+1, (flags >> 2) & 3, 2, gb, vlc, q_ac1);
+ }else{
+- decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q_ac1);
+- decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q_ac1);
++ decode_coeff(dst+1, (flags >> 4) & 3, 2, gb, vlc, q_ac1);
++ decode_coeff(dst+8, (flags >> 2) & 3, 2, gb, vlc, q_ac1);
+ }
+- decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q_ac2);
++ decode_coeff( dst+9, (flags >> 0) & 3, 2, gb, vlc, q_ac2);
+ }
+
+ /**
+@@ -286,16 +287,24 @@ static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2,
+ * o--o
+ */
+
+-static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2)
++static inline int rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2)
+ {
+- int code, pattern;
++ int code, pattern, has_ac = 1;
+
+ code = get_vlc2(gb, rvlc->first_pattern[fc].table, 9, 2);
+
+ pattern = code & 0x7;
+
+ code >>= 3;
+- decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2);
++
++ if (modulo_three_table[code] & 0x3F) {
++ decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2);
++ } else {
++ decode_subblock1(dst, code, gb, &rvlc->coefficient, q_dc);
++ if (!pattern)
++ return 0;
++ has_ac = 0;
++ }
+
+ if(pattern & 4){
+ code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2);
+@@ -309,7 +318,7 @@ static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *r
+ code = get_vlc2(gb, rvlc->third_pattern[sc].table, 9, 2);
+ decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient, q_ac2);
+ }
+-
++ return has_ac || pattern;
+ }
+
+ /**
+@@ -1118,7 +1127,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
+ MpegEncContext *s = &r->s;
+ GetBitContext *gb = &s->gb;
+ int cbp, cbp2;
+- int q_dc, q_ac;
++ int q_dc, q_ac, has_ac;
+ int i, blknum, blkoff;
+ LOCAL_ALIGNED_16(DCTELEM, block16, [64]);
+ int luma_dc_quant;
+@@ -1157,33 +1166,45 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
+ if(r->is16){
+ q_dc = rv34_qscale_tab[luma_dc_quant];
+ q_ac = rv34_qscale_tab[s->qscale];
+- memset(block16, 0, 64 * sizeof(*block16));
+- rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
+- r->rdsp.rv34_inv_transform_tab[1](block16);
++ s->dsp.clear_block(block16);
++ if (rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac))
++ r->rdsp.rv34_inv_transform_tab[1](block16);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[1](block16);
+ }
+
+ q_ac = rv34_qscale_tab[s->qscale];
+ for(i = 0; i < 16; i++, cbp >>= 1){
++ DCTELEM *ptr;
+ if(!r->is16 && !(cbp & 1)) continue;
+ blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
+ blkoff = ((i & 1) << 2) + ((i & 4) << 3);
++ ptr = s->block[blknum] + blkoff;
+ if(cbp & 1)
+- rv34_decode_block(s->block[blknum] + blkoff, gb,
+- r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ else
++ has_ac = 0;
+ if(r->is16) //FIXME: optimize
+- s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)];
+- r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
++ ptr[0] = block16[(i & 3) | ((i & 0xC) << 1)];
++ if(has_ac)
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
+ }
+ if(r->block_type == RV34_MB_P_MIX16x16)
+ r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1);
+ q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
+ q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
+ for(; i < 24; i++, cbp >>= 1){
++ DCTELEM *ptr;
+ if(!(cbp & 1)) continue;
+ blknum = ((i & 4) >> 2) + 4;
+ blkoff = ((i & 1) << 2) + ((i & 2) << 4);
+- rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac);
+- r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
++ ptr = s->block[blknum] + blkoff;
++ if (rv34_decode_block(ptr, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac))
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
+ }
+ if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos]))
+ rv34_output_macroblock(r, intra_types, cbp2, r->is16);
+diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h
+index fa41a88..41c5b20 100644
+--- a/libavcodec/rv34data.h
++++ b/libavcodec/rv34data.h
+@@ -50,34 +50,22 @@ static const uint8_t rv34_cbp_code[16] = {
+ * A lot of four-tuples in RV40 are represented as c0*27+c1*9+c2*3+c3.
+ * This table allows conversion from a value back to a vector.
+ */
+-static const uint8_t modulo_three_table[108][4] = {
+- { 0, 0, 0, 0 }, { 0, 0, 0, 1 }, { 0, 0, 0, 2 }, { 0, 0, 1, 0 },
+- { 0, 0, 1, 1 }, { 0, 0, 1, 2 }, { 0, 0, 2, 0 }, { 0, 0, 2, 1 },
+- { 0, 0, 2, 2 }, { 0, 1, 0, 0 }, { 0, 1, 0, 1 }, { 0, 1, 0, 2 },
+- { 0, 1, 1, 0 }, { 0, 1, 1, 1 }, { 0, 1, 1, 2 }, { 0, 1, 2, 0 },
+- { 0, 1, 2, 1 }, { 0, 1, 2, 2 }, { 0, 2, 0, 0 }, { 0, 2, 0, 1 },
+- { 0, 2, 0, 2 }, { 0, 2, 1, 0 }, { 0, 2, 1, 1 }, { 0, 2, 1, 2 },
+- { 0, 2, 2, 0 }, { 0, 2, 2, 1 }, { 0, 2, 2, 2 }, { 1, 0, 0, 0 },
+- { 1, 0, 0, 1 }, { 1, 0, 0, 2 }, { 1, 0, 1, 0 }, { 1, 0, 1, 1 },
+- { 1, 0, 1, 2 }, { 1, 0, 2, 0 }, { 1, 0, 2, 1 }, { 1, 0, 2, 2 },
+- { 1, 1, 0, 0 }, { 1, 1, 0, 1 }, { 1, 1, 0, 2 }, { 1, 1, 1, 0 },
+- { 1, 1, 1, 1 }, { 1, 1, 1, 2 }, { 1, 1, 2, 0 }, { 1, 1, 2, 1 },
+- { 1, 1, 2, 2 }, { 1, 2, 0, 0 }, { 1, 2, 0, 1 }, { 1, 2, 0, 2 },
+- { 1, 2, 1, 0 }, { 1, 2, 1, 1 }, { 1, 2, 1, 2 }, { 1, 2, 2, 0 },
+- { 1, 2, 2, 1 }, { 1, 2, 2, 2 }, { 2, 0, 0, 0 }, { 2, 0, 0, 1 },
+- { 2, 0, 0, 2 }, { 2, 0, 1, 0 }, { 2, 0, 1, 1 }, { 2, 0, 1, 2 },
+- { 2, 0, 2, 0 }, { 2, 0, 2, 1 }, { 2, 0, 2, 2 }, { 2, 1, 0, 0 },
+- { 2, 1, 0, 1 }, { 2, 1, 0, 2 }, { 2, 1, 1, 0 }, { 2, 1, 1, 1 },
+- { 2, 1, 1, 2 }, { 2, 1, 2, 0 }, { 2, 1, 2, 1 }, { 2, 1, 2, 2 },
+- { 2, 2, 0, 0 }, { 2, 2, 0, 1 }, { 2, 2, 0, 2 }, { 2, 2, 1, 0 },
+- { 2, 2, 1, 1 }, { 2, 2, 1, 2 }, { 2, 2, 2, 0 }, { 2, 2, 2, 1 },
+- { 2, 2, 2, 2 }, { 3, 0, 0, 0 }, { 3, 0, 0, 1 }, { 3, 0, 0, 2 },
+- { 3, 0, 1, 0 }, { 3, 0, 1, 1 }, { 3, 0, 1, 2 }, { 3, 0, 2, 0 },
+- { 3, 0, 2, 1 }, { 3, 0, 2, 2 }, { 3, 1, 0, 0 }, { 3, 1, 0, 1 },
+- { 3, 1, 0, 2 }, { 3, 1, 1, 0 }, { 3, 1, 1, 1 }, { 3, 1, 1, 2 },
+- { 3, 1, 2, 0 }, { 3, 1, 2, 1 }, { 3, 1, 2, 2 }, { 3, 2, 0, 0 },
+- { 3, 2, 0, 1 }, { 3, 2, 0, 2 }, { 3, 2, 1, 0 }, { 3, 2, 1, 1 },
+- { 3, 2, 1, 2 }, { 3, 2, 2, 0 }, { 3, 2, 2, 1 }, { 3, 2, 2, 2 },
++static const uint8_t modulo_three_table[108] = {
++ 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x08, 0x09, 0x0A,
++ 0x10, 0x11, 0x12, 0x14, 0x15, 0x16, 0x18, 0x19, 0x1A,
++ 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A,
++
++ 0x40, 0x41, 0x42, 0x44, 0x45, 0x46, 0x48, 0x49, 0x4A,
++ 0x50, 0x51, 0x52, 0x54, 0x55, 0x56, 0x58, 0x59, 0x5A,
++ 0x60, 0x61, 0x62, 0x64, 0x65, 0x66, 0x68, 0x69, 0x6A,
++
++ 0x80, 0x81, 0x82, 0x84, 0x85, 0x86, 0x88, 0x89, 0x8A,
++ 0x90, 0x91, 0x92, 0x94, 0x95, 0x96, 0x98, 0x99, 0x9A,
++ 0xA0, 0xA1, 0xA2, 0xA4, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA,
++
++ 0xC0, 0xC1, 0xC2, 0xC4, 0xC5, 0xC6, 0xC8, 0xC9, 0xCA,
++ 0xD0, 0xD1, 0xD2, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA,
++ 0xE0, 0xE1, 0xE2, 0xE4, 0xE5, 0xE6, 0xE8, 0xE9, 0xEA,
+ };
+
+ /**
+diff --git a/libavcodec/rv34dsp.c b/libavcodec/rv34dsp.c
+index 1f4cea8..1767be4 100644
+--- a/libavcodec/rv34dsp.c
++++ b/libavcodec/rv34dsp.c
+@@ -97,13 +97,37 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){
+ }
+ }
+
++static void rv34_inv_transform_dc_c(DCTELEM *block)
++{
++ DCTELEM dc = (13 * 13 * block[0] + 0x200) >> 10;
++ int i, j;
++
++ for (i = 0; i < 4; i++, block += 8)
++ for (j = 0; j < 4; j++)
++ block[j] = dc;
++}
++
++static void rv34_inv_transform_dc_noround_c(DCTELEM *block)
++{
++ DCTELEM dc = (13 * 13 * 3 * block[0]) >> 11;
++ int i, j;
++
++ for (i = 0; i < 4; i++, block += 8)
++ for (j = 0; j < 4; j++)
++ block[j] = dc;
++}
++
+ /** @} */ // transform
+
+
+ av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
+ c->rv34_inv_transform_tab[0] = rv34_inv_transform_c;
+ c->rv34_inv_transform_tab[1] = rv34_inv_transform_noround_c;
++ c->rv34_inv_transform_dc_tab[0] = rv34_inv_transform_dc_c;
++ c->rv34_inv_transform_dc_tab[1] = rv34_inv_transform_dc_noround_c;
+
+ if (HAVE_NEON)
+ ff_rv34dsp_init_neon(c, dsp);
++ if (HAVE_MMX)
++ ff_rv34dsp_init_x86(c, dsp);
+ }
+diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h
+index f2bc20e..6f53a09 100644
+--- a/libavcodec/rv34dsp.h
++++ b/libavcodec/rv34dsp.h
+@@ -56,6 +56,7 @@ typedef struct RV34DSPContext {
+ h264_chroma_mc_func avg_chroma_pixels_tab[3];
+ rv40_weight_func rv40_weight_pixels_tab[2];
+ rv34_inv_transform_func rv34_inv_transform_tab[2];
++ void (*rv34_inv_transform_dc_tab[2])(DCTELEM *block);
+ rv40_weak_loop_filter_func rv40_weak_loop_filter[2];
+ rv40_strong_loop_filter_func rv40_strong_loop_filter[2];
+ rv40_loop_filter_strength_func rv40_loop_filter_strength[2];
+@@ -66,6 +67,7 @@ void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp);
+ void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp);
+
+ void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext *dsp);
++void ff_rv34dsp_init_x86(RV34DSPContext *c, DSPContext *dsp);
+
+ void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp);
+ void ff_rv40dsp_init_neon(RV34DSPContext *c, DSPContext *dsp);
+diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
+index 2abe4fb..1e88e4a 100644
+--- a/libavcodec/x86/Makefile
++++ b/libavcodec/x86/Makefile
+@@ -24,7 +24,11 @@ YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o \
+ x86/h264_intrapred_10bit.o
+ MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
+
+-MMX-OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp.o \
++MMX-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o
++YASM-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp.o
++MMX-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp_init.o \
++ x86/rv40dsp.o
++YASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp.o
+
+ YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_yasm.o
+
+diff --git a/libavcodec/x86/rv34dsp.asm b/libavcodec/x86/rv34dsp.asm
+new file mode 100644
+index 0000000..58f1af0
+--- /dev/null
++++ b/libavcodec/x86/rv34dsp.asm
+@@ -0,0 +1,55 @@
++;******************************************************************************
++;* MMX/SSE2-optimized functions for the RV30 and RV40 decoders
++;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet at gmail.com>
++;*
++;* 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 "x86inc.asm"
++%include "x86util.asm"
++
++SECTION .text
++
++%macro IDCT_DC_NOROUND 1
++ imul %1, 13*13*3
++ sar %1, 11
++%endmacro
++
++%macro IDCT_DC_ROUND 1
++ imul %1, 13*13
++ add %1, 0x200
++ sar %1, 10
++%endmacro
++
++%macro rv34_idct_dequant4x4_dc 1
++cglobal rv34_idct_dequant4x4_%1_mmx2, 1, 2, 0
++ movsx r1, word [r0]
++ IDCT_DC r1
++ movd mm0, r1
++ pshufw mm0, mm0, 0
++ movq [r0+ 0], mm0
++ movq [r0+16], mm0
++ movq [r0+32], mm0
++ movq [r0+48], mm0
++ REP_RET
++%endmacro
++
++INIT_MMX
++%define IDCT_DC IDCT_DC_ROUND
++rv34_idct_dequant4x4_dc dc
++%define IDCT_DC IDCT_DC_NOROUND
++rv34_idct_dequant4x4_dc dc_noround
+diff --git a/libavcodec/x86/rv34dsp_init.c b/libavcodec/x86/rv34dsp_init.c
+new file mode 100644
+index 0000000..4317e9b
+--- /dev/null
++++ b/libavcodec/x86/rv34dsp_init.c
+@@ -0,0 +1,40 @@
++/*
++ * RV30/40 MMX/SSE2 optimizations
++ * Copyright (C) 2012 Christophe Gisquet <christophe.gisquet at gmail.com>
++ *
++ * 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 "libavutil/cpu.h"
++#include "libavutil/x86_cpu.h"
++#include "libavcodec/dsputil.h"
++#include "libavcodec/rv34dsp.h"
++
++void ff_rv34_idct_dequant4x4_dc_mmx2(DCTELEM *block);
++void ff_rv34_idct_dequant4x4_dc_noround_mmx2(DCTELEM *block);
++
++av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp)
++{
++#if HAVE_YASM
++ int mm_flags = av_get_cpu_flags();
++
++ if (mm_flags & AV_CPU_FLAG_MMX2) {
++ c->rv34_inv_transform_dc_tab[0] = ff_rv34_idct_dequant4x4_dc_mmx2;
++ c->rv34_inv_transform_dc_tab[1] = ff_rv34_idct_dequant4x4_dc_noround_mmx2;
++ }
++#endif
++}
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0015-indeo4-add-some-missing-static-and-const-qualifiers.patch b/debian/patches/post-0.8b2/0015-indeo4-add-some-missing-static-and-const-qualifiers.patch
new file mode 100644
index 0000000..2616e33
--- /dev/null
+++ b/debian/patches/post-0.8b2/0015-indeo4-add-some-missing-static-and-const-qualifiers.patch
@@ -0,0 +1,79 @@
+From 08bab32cf1dff7dc25dab4f010c42c13ba9627c7 Mon Sep 17 00:00:00 2001
+From: Kostya Shishkov <kostya.shishkov at gmail.com>
+Date: Thu, 12 Jan 2012 10:01:33 +0100
+Subject: [PATCH 15/63] indeo4: add some missing static and const qualifiers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From the patch by Reimar Döffinger.
+---
+ libavcodec/indeo4.c | 2 +-
+ libavcodec/indeo4data.h | 10 +++++-----
+ 2 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
+index dd8e5b1..573718e 100644
+--- a/libavcodec/indeo4.c
++++ b/libavcodec/indeo4.c
+@@ -94,7 +94,7 @@ typedef struct {
+ } IVI4DecContext;
+
+
+-struct {
++static const struct {
+ InvTransformPtr *inv_trans;
+ DCTransformPtr *dc_trans;
+ int is_2d_trans;
+diff --git a/libavcodec/indeo4data.h b/libavcodec/indeo4data.h
+index affd9c6..9b8945a 100644
+--- a/libavcodec/indeo4data.h
++++ b/libavcodec/indeo4data.h
+@@ -86,7 +86,7 @@ static const uint8_t *scan_index_to_tab[15] = {
+ /**
+ * Indeo 4 dequant tables
+ */
+-static uint16_t ivi4_quant_8x8_intra[9][64] = {
++static const uint16_t ivi4_quant_8x8_intra[9][64] = {
+ {
+ 43, 342, 385, 470, 555, 555, 598, 726,
+ 342, 342, 470, 513, 555, 598, 726, 769,
+@@ -179,7 +179,7 @@ static uint16_t ivi4_quant_8x8_intra[9][64] = {
+ }
+ };
+
+-static uint16_t ivi4_quant_8x8_inter[9][64] = {
++static const uint16_t ivi4_quant_8x8_inter[9][64] = {
+ {
+ 427, 427, 470, 427, 427, 427, 470, 470,
+ 427, 427, 470, 427, 427, 427, 470, 470,
+@@ -272,7 +272,7 @@ static uint16_t ivi4_quant_8x8_inter[9][64] = {
+ }
+ };
+
+-static uint16_t ivi4_quant_4x4_intra[5][16] = {
++static const uint16_t ivi4_quant_4x4_intra[5][16] = {
+ {
+ 22, 214, 257, 299,
+ 214, 257, 299, 342,
+@@ -305,7 +305,7 @@ static uint16_t ivi4_quant_4x4_intra[5][16] = {
+ }
+ };
+
+-static uint16_t ivi4_quant_4x4_inter[5][16] = {
++static const uint16_t ivi4_quant_4x4_inter[5][16] = {
+ {
+ 107, 214, 257, 299,
+ 214, 257, 299, 299,
+@@ -342,7 +342,7 @@ static uint16_t ivi4_quant_4x4_inter[5][16] = {
+ * Table for mapping quant matrix index from the bitstream
+ * into internal quant table number.
+ */
+-static uint8_t quant_index_to_tab[22] = {
++static const uint8_t quant_index_to_tab[22] = {
+ 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
+ 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes
+ };
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0016-riff-remove-references-to-sonic-codec-ids.patch b/debian/patches/post-0.8b2/0016-riff-remove-references-to-sonic-codec-ids.patch
new file mode 100644
index 0000000..7106848
--- /dev/null
+++ b/debian/patches/post-0.8b2/0016-riff-remove-references-to-sonic-codec-ids.patch
@@ -0,0 +1,26 @@
+From 0fd88d398896353074fee153259dbf3530ca423f Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:12:59 +0100
+Subject: [PATCH 16/63] riff: remove references to sonic codec ids
+
+They are deprecated and will be purged on next major bump.
+---
+ libavformat/riff.c | 2 --
+ 1 files changed, 0 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/riff.c b/libavformat/riff.c
+index 8489bc7..4caac80 100644
+--- a/libavformat/riff.c
++++ b/libavformat/riff.c
+@@ -327,8 +327,6 @@ const AVCodecTag ff_codec_wav_tags[] = {
+ { CODEC_ID_AAC_LATM, 0x1602 },
+ { CODEC_ID_AC3, 0x2000 },
+ { CODEC_ID_DTS, 0x2001 },
+- { CODEC_ID_SONIC, 0x2048 },
+- { CODEC_ID_SONIC_LS, 0x2048 },
+ { CODEC_ID_PCM_MULAW, 0x6c75 },
+ { CODEC_ID_AAC, 0x706d },
+ { CODEC_ID_AAC, 0x4143 },
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0017-mpegvideo_enc-ifdef-out-replace-references-to-deprec.patch b/debian/patches/post-0.8b2/0017-mpegvideo_enc-ifdef-out-replace-references-to-deprec.patch
new file mode 100644
index 0000000..fb541c1
--- /dev/null
+++ b/debian/patches/post-0.8b2/0017-mpegvideo_enc-ifdef-out-replace-references-to-deprec.patch
@@ -0,0 +1,71 @@
+From 0c71cc65266469253d531e8101a211ce8f26387c Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:25:05 +0100
+Subject: [PATCH 17/63] mpegvideo_enc: ifdef out/replace references to
+ deprecated codec flags.
+
+---
+ libavcodec/mpegvideo_enc.c | 20 ++++++++++++++------
+ 1 files changed, 14 insertions(+), 6 deletions(-)
+
+diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
+index 84a5cda..08484a7 100644
+--- a/libavcodec/mpegvideo_enc.c
++++ b/libavcodec/mpegvideo_enc.c
+@@ -498,8 +498,11 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
+ return -1;
+ }
+
+- if ((s->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME |
+- CODEC_FLAG_ALT_SCAN)) &&
++ if ((s->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME
++#if FF_API_MPEGVIDEO_GLOBAL_OPTS
++ | CODEC_FLAG_ALT_SCAN
++#endif
++ )) &&
+ s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG2VIDEO) {
+ av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
+ return -1;
+@@ -531,12 +534,14 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
+ return -1;
+ }
+
++#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+ if ((s->flags2 & CODEC_FLAG2_INTRA_VLC) &&
+ s->codec_id != CODEC_ID_MPEG2VIDEO) {
+ av_log(avctx, AV_LOG_ERROR,
+ "intra vlc table not supported by codec\n");
+ return -1;
+ }
++#endif
+
+ if (s->flags & CODEC_FLAG_LOW_DELAY) {
+ if (s->codec_id != CODEC_ID_MPEG2VIDEO) {
+@@ -570,8 +575,11 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
+ s->codec_id != CODEC_ID_MPEG4 &&
+ s->codec_id != CODEC_ID_MPEG1VIDEO &&
+ s->codec_id != CODEC_ID_MPEG2VIDEO &&
+- (s->codec_id != CODEC_ID_H263P ||
+- !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))) {
++ (s->codec_id != CODEC_ID_H263P
++#if FF_API_MPEGVIDEO_GLOBAL_OPTS
++ || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT)
++#endif
++ )) {
+ av_log(avctx, AV_LOG_ERROR,
+ "multi threaded encoding not supported by codec\n");
+ return -1;
+@@ -810,8 +818,8 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
+
+ s->progressive_frame =
+ s->progressive_sequence = !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT |
+- CODEC_FLAG_INTERLACED_ME |
+- CODEC_FLAG_ALT_SCAN));
++ CODEC_FLAG_INTERLACED_ME) ||
++ s->alternate_scan);
+
+ /* init */
+ if (MPV_common_init(s) < 0)
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0018-nellymoserdec-SAMPLE_FMT-AV_SAMPLE_FMT.patch b/debian/patches/post-0.8b2/0018-nellymoserdec-SAMPLE_FMT-AV_SAMPLE_FMT.patch
new file mode 100644
index 0000000..67ea893
--- /dev/null
+++ b/debian/patches/post-0.8b2/0018-nellymoserdec-SAMPLE_FMT-AV_SAMPLE_FMT.patch
@@ -0,0 +1,25 @@
+From d54f1e640790b9690cdb4f543f374016615ec000 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:26:11 +0100
+Subject: [PATCH 18/63] nellymoserdec: SAMPLE_FMT -> AV_SAMPLE_FMT
+
+---
+ libavcodec/nellymoserdec.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
+index 7f585e4..69c1b86 100644
+--- a/libavcodec/nellymoserdec.c
++++ b/libavcodec/nellymoserdec.c
+@@ -187,7 +187,7 @@ static int decode_tag(AVCodecContext *avctx, void *data,
+ samples_flt = (float *)s->frame.data[0];
+
+ for (i=0 ; i<blocks ; i++) {
+- if (avctx->sample_fmt == SAMPLE_FMT_FLT) {
++ if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
+ nelly_decode_block(s, buf, samples_flt);
+ samples_flt += NELLY_SAMPLES;
+ } else {
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0019-lavc-ifdef-out-parse_only-AVOption.patch b/debian/patches/post-0.8b2/0019-lavc-ifdef-out-parse_only-AVOption.patch
new file mode 100644
index 0000000..36ae4e8
--- /dev/null
+++ b/debian/patches/post-0.8b2/0019-lavc-ifdef-out-parse_only-AVOption.patch
@@ -0,0 +1,26 @@
+From a29c25a9b27456367c7550364d5ba5d7e3798323 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:28:15 +0100
+Subject: [PATCH 19/63] lavc: ifdef out parse_only AVOption
+
+---
+ libavcodec/options.c | 2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/options.c b/libavcodec/options.c
+index a99aed7..00d80e0 100644
+--- a/libavcodec/options.c
++++ b/libavcodec/options.c
+@@ -215,7 +215,9 @@ static const AVOption options[]={
+ {"explode", "abort decoding on minor error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, V|D, "err_filter"},
+ {"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
+ {"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
++#if FF_API_PARSE_FRAME
+ {"parse_only", NULL, OFFSET(parse_only), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
++#endif
+ {"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
+ {"stats_out", NULL, OFFSET(stats_out), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX},
+ {"stats_in", NULL, OFFSET(stats_in), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX},
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0020-lavc-replace-some-remaining-FF_I_TYPE-with-AV_PICTUR.patch b/debian/patches/post-0.8b2/0020-lavc-replace-some-remaining-FF_I_TYPE-with-AV_PICTUR.patch
new file mode 100644
index 0000000..422ba7f
--- /dev/null
+++ b/debian/patches/post-0.8b2/0020-lavc-replace-some-remaining-FF_I_TYPE-with-AV_PICTUR.patch
@@ -0,0 +1,54 @@
+From f3d02a8b280e189bb59db0f194d224bffd4db573 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:29:43 +0100
+Subject: [PATCH 20/63] lavc: replace some remaining FF_I_TYPE with
+ AV_PICTURE_TYPE_I
+
+---
+ libavcodec/v410dec.c | 2 +-
+ libavcodec/v410enc.c | 2 +-
+ libavcodec/vble.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/v410dec.c b/libavcodec/v410dec.c
+index 54c9595..a6f236b 100644
+--- a/libavcodec/v410dec.c
++++ b/libavcodec/v410dec.c
+@@ -68,7 +68,7 @@ static int v410_decode_frame(AVCodecContext *avctx, void *data,
+ }
+
+ pic->key_frame = 1;
+- pic->pict_type = FF_I_TYPE;
++ pic->pict_type = AV_PICTURE_TYPE_I;
+
+ y = (uint16_t *)pic->data[0];
+ u = (uint16_t *)pic->data[1];
+diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
+index 11c6abc..a6b3ddb 100644
+--- a/libavcodec/v410enc.c
++++ b/libavcodec/v410enc.c
+@@ -57,7 +57,7 @@ static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf,
+
+ avctx->coded_frame->reference = 0;
+ avctx->coded_frame->key_frame = 1;
+- avctx->coded_frame->pict_type = FF_I_TYPE;
++ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+
+ y = (uint16_t *)pic->data[0];
+ u = (uint16_t *)pic->data[1];
+diff --git a/libavcodec/vble.c b/libavcodec/vble.c
+index fa205f5..574582a 100644
+--- a/libavcodec/vble.c
++++ b/libavcodec/vble.c
+@@ -135,7 +135,7 @@ static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+
+ /* Set flags */
+ pic->key_frame = 1;
+- pic->pict_type = FF_I_TYPE;
++ pic->pict_type = AV_PICTURE_TYPE_I;
+
+ /* Version should always be 1 */
+ version = AV_RL32(src);
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0021-avserver-remove-code-using-deprecated-CODEC_CAP_PARS.patch b/debian/patches/post-0.8b2/0021-avserver-remove-code-using-deprecated-CODEC_CAP_PARS.patch
new file mode 100644
index 0000000..388e9ae
--- /dev/null
+++ b/debian/patches/post-0.8b2/0021-avserver-remove-code-using-deprecated-CODEC_CAP_PARS.patch
@@ -0,0 +1,51 @@
+From e01a29a461ec15aad745fa89e510a92918d872aa Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:33:16 +0100
+Subject: [PATCH 21/63] avserver: remove code using deprecated
+ CODEC_CAP_PARSE_ONLY.
+
+---
+ avserver.c | 20 --------------------
+ 1 files changed, 0 insertions(+), 20 deletions(-)
+
+diff --git a/avserver.c b/avserver.c
+index 9016d1f..15fa64c 100644
+--- a/avserver.c
++++ b/avserver.c
+@@ -2112,22 +2112,6 @@ static void compute_status(HTTPContext *c)
+ c->buffer_end = c->pb_buffer + len;
+ }
+
+-/* check if the parser needs to be opened for stream i */
+-static void open_parser(AVFormatContext *s, int i)
+-{
+- AVStream *st = s->streams[i];
+- AVCodec *codec;
+-
+- if (!st->codec->codec) {
+- codec = avcodec_find_decoder(st->codec->codec_id);
+- if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) {
+- st->codec->parse_only = 1;
+- if (avcodec_open2(st->codec, codec, NULL) < 0)
+- st->codec->parse_only = 0;
+- }
+- }
+-}
+-
+ static int open_input_stream(HTTPContext *c, const char *info)
+ {
+ char buf[128];
+@@ -2173,10 +2157,6 @@ static int open_input_stream(HTTPContext *c, const char *info)
+ return -1;
+ }
+
+- /* open each parser */
+- for(i=0;i<s->nb_streams;i++)
+- open_parser(s, i);
+-
+ /* choose stream as clock source (we favorize video stream if
+ present) for packet sending */
+ c->pts_stream_index = 0;
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0022-lavf-undeprecate-read_seek.patch b/debian/patches/post-0.8b2/0022-lavf-undeprecate-read_seek.patch
new file mode 100644
index 0000000..6c596dc
--- /dev/null
+++ b/debian/patches/post-0.8b2/0022-lavf-undeprecate-read_seek.patch
@@ -0,0 +1,53 @@
+From e5c708151e3dbf09c9564051c432b1b83a1674d0 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:36:11 +0100
+Subject: [PATCH 22/63] lavf: undeprecate read_seek().
+
+The "new seeking API" was never finished and nobody is working on it.
+---
+ libavformat/avformat.h | 7 +++----
+ libavformat/version.h | 3 ---
+ 2 files changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/libavformat/avformat.h b/libavformat/avformat.h
+index 89b9eda..fff911a 100644
+--- a/libavformat/avformat.h
++++ b/libavformat/avformat.h
+@@ -503,7 +503,6 @@ typedef struct AVInputFormat {
+ */
+ int (*read_close)(struct AVFormatContext *);
+
+-#if FF_API_READ_SEEK
+ /**
+ * Seek to a given timestamp relative to the frames in
+ * stream component stream_index.
+@@ -512,9 +511,9 @@ typedef struct AVInputFormat {
+ * match is available.
+ * @return >= 0 on success (but not necessarily the new offset)
+ */
+- attribute_deprecated int (*read_seek)(struct AVFormatContext *,
+- int stream_index, int64_t timestamp, int flags);
+-#endif
++ int (*read_seek)(struct AVFormatContext *,
++ int stream_index, int64_t timestamp, int flags);
++
+ /**
+ * Get the next timestamp in stream[stream_index].time_base units.
+ * @return the timestamp or AV_NOPTS_VALUE if an error occurred
+diff --git a/libavformat/version.h b/libavformat/version.h
+index e113a24..fb5a1eb 100644
+--- a/libavformat/version.h
++++ b/libavformat/version.h
+@@ -50,9 +50,6 @@
+ #ifndef FF_API_OLD_METADATA2
+ #define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54)
+ #endif
+-#ifndef FF_API_READ_SEEK
+-#define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54)
+-#endif
+ #ifndef FF_API_OLD_AVIO
+ #define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 54)
+ #endif
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0023-ffmenc-remove-references-to-deprecated-AVFormatConte.patch b/debian/patches/post-0.8b2/0023-ffmenc-remove-references-to-deprecated-AVFormatConte.patch
new file mode 100644
index 0000000..8a79346
--- /dev/null
+++ b/debian/patches/post-0.8b2/0023-ffmenc-remove-references-to-deprecated-AVFormatConte.patch
@@ -0,0 +1,35 @@
+From 44bcab5883fcfdc9e9b1cc5315e994fd33391deb Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:38:13 +0100
+Subject: [PATCH 23/63] ffmenc: remove references to deprecated
+ AVFormatContext.timestamp.
+
+---
+ libavformat/ffmenc.c | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
+index d304f57..b8d3d31 100644
+--- a/libavformat/ffmenc.c
++++ b/libavformat/ffmenc.c
+@@ -205,7 +205,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
+ uint8_t header[FRAME_HEADER_SIZE+4];
+ int header_size = FRAME_HEADER_SIZE;
+
+- dts = s->timestamp + pkt->dts;
++ dts = pkt->dts;
+ /* packet size & key_frame */
+ header[0] = pkt->stream_index;
+ header[1] = 0;
+@@ -213,7 +213,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
+ header[1] |= FLAG_KEY_FRAME;
+ AV_WB24(header+2, pkt->size);
+ AV_WB24(header+5, pkt->duration);
+- AV_WB64(header+8, s->timestamp + pkt->pts);
++ AV_WB64(header+8, pkt->pts);
+ if (pkt->pts != pkt->dts) {
+ header[1] |= FLAG_DTS;
+ AV_WB32(header+16, pkt->pts - pkt->dts);
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0024-avprobe-use-avio_size-instead-of-deprecated-AVFormat.patch b/debian/patches/post-0.8b2/0024-avprobe-use-avio_size-instead-of-deprecated-AVFormat.patch
new file mode 100644
index 0000000..9baea20
--- /dev/null
+++ b/debian/patches/post-0.8b2/0024-avprobe-use-avio_size-instead-of-deprecated-AVFormat.patch
@@ -0,0 +1,37 @@
+From 136ee32da3c728fb4e3490393efb947cc7c4e898 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Thu, 12 Jan 2012 09:45:13 +0100
+Subject: [PATCH 24/63] avprobe: use avio_size() instead of deprecated
+ AVFormatContext.file_size.
+
+---
+ avprobe.c | 6 ++++--
+ 1 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/avprobe.c b/avprobe.c
+index de9657b..4d2ed67 100644
+--- a/avprobe.c
++++ b/avprobe.c
+@@ -243,6 +243,7 @@ static void show_format(AVFormatContext *fmt_ctx)
+ {
+ AVDictionaryEntry *tag = NULL;
+ char val_str[128];
++ int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
+
+ printf("[FORMAT]\n");
+
+@@ -254,8 +255,9 @@ static void show_format(AVFormatContext *fmt_ctx)
+ &AV_TIME_BASE_Q));
+ printf("duration=%s\n", time_value_string(val_str, sizeof(val_str), fmt_ctx->duration,
+ &AV_TIME_BASE_Q));
+- printf("size=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->file_size,
+- unit_byte_str));
++ printf("size=%s\n", size >= 0 ? value_string(val_str, sizeof(val_str),
++ size, unit_byte_str)
++ : "unknown");
+ printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,
+ unit_bit_per_second_str));
+
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0025-rv34-NEON-optimised-dc-only-inverse-transform.patch b/debian/patches/post-0.8b2/0025-rv34-NEON-optimised-dc-only-inverse-transform.patch
new file mode 100644
index 0000000..86954ed
--- /dev/null
+++ b/debian/patches/post-0.8b2/0025-rv34-NEON-optimised-dc-only-inverse-transform.patch
@@ -0,0 +1,72 @@
+From e1e369049e3d2f88eed6ed38eb3dd704681c7f1a Mon Sep 17 00:00:00 2001
+From: Janne Grunau <janne-libav at jannau.net>
+Date: Thu, 12 Jan 2012 17:21:48 +0100
+Subject: [PATCH 25/63] rv34: NEON optimised dc only inverse transform
+
+30-50% faster than the C implementation, 0.5% overall speedup on
+bourne.rmvb.
+---
+ libavcodec/arm/rv34dsp_init_neon.c | 9 +++++++--
+ libavcodec/arm/rv34dsp_neon.S | 29 +++++++++++++++++++++++++++++
+ 2 files changed, 36 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/arm/rv34dsp_init_neon.c b/libavcodec/arm/rv34dsp_init_neon.c
+index 9a09fde..16bda46 100644
+--- a/libavcodec/arm/rv34dsp_init_neon.c
++++ b/libavcodec/arm/rv34dsp_init_neon.c
+@@ -26,8 +26,13 @@
+ void ff_rv34_inv_transform_neon(DCTELEM *block);
+ void ff_rv34_inv_transform_noround_neon(DCTELEM *block);
+
++void ff_rv34_inv_transform_dc_neon(DCTELEM *block);
++void ff_rv34_inv_transform_noround_dc_neon(DCTELEM *block);
++
+ void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp)
+ {
+- c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon;
+- c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon;
++ c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon;
++ c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon;
++ c->rv34_inv_transform_dc_tab[0] = ff_rv34_inv_transform_dc_neon;
++ c->rv34_inv_transform_dc_tab[1] = ff_rv34_inv_transform_noround_dc_neon;
+ }
+diff --git a/libavcodec/arm/rv34dsp_neon.S b/libavcodec/arm/rv34dsp_neon.S
+index f700f5c..e776af0 100644
+--- a/libavcodec/arm/rv34dsp_neon.S
++++ b/libavcodec/arm/rv34dsp_neon.S
+@@ -107,3 +107,32 @@ function ff_rv34_inv_transform_noround_neon, export=1
+ vst4.16 {d0[3], d1[3], d2[3], d3[3]}, [r2,:64], r1
+ bx lr
+ endfunc
++
++/* void rv34_inv_transform_dc_c(DCTELEM *block) */
++function ff_rv34_inv_transform_dc_neon, export=1
++ vld1.16 d28[], [r0:16] @ block[0]
++ vmov.i16 d4, #169
++ mov r1, #16
++ vmull.s16 q3, d28, d4
++ vrshrn.s32 d0, q3, #10
++ vst1.16 {d0}, [r0:64], r1
++ vst1.16 {d0}, [r0:64], r1
++ vst1.16 {d0}, [r0:64], r1
++ vst1.16 {d0}, [r0:64], r1
++ bx lr
++endfunc
++
++/* void rv34_inv_transform_dc_noround_c(DCTELEM *block) */
++function ff_rv34_inv_transform_noround_dc_neon, export=1
++ vld1.16 d28[], [r0:16] @ block[0]
++ vmov.i16 d4, #251
++ vorr.s16 d4, #256 @ 13^2 * 3
++ mov r1, #16
++ vmull.s16 q3, d28, d4
++ vshrn.s32 d0, q3, #11
++ vst1.64 {d0}, [r0:64], r1
++ vst1.64 {d0}, [r0:64], r1
++ vst1.64 {d0}, [r0:64], r1
++ vst1.64 {d0}, [r0:64], r1
++ bx lr
++endfunc
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0026-rv34-fix-and-optimise-frame-dependency-checking.patch b/debian/patches/post-0.8b2/0026-rv34-fix-and-optimise-frame-dependency-checking.patch
new file mode 100644
index 0000000..cbb898f
--- /dev/null
+++ b/debian/patches/post-0.8b2/0026-rv34-fix-and-optimise-frame-dependency-checking.patch
@@ -0,0 +1,40 @@
+From 3547f8e8f8418af0c578eba0de62ecba08e460c2 Mon Sep 17 00:00:00 2001
+From: Janne Grunau <janne-libav at jannau.net>
+Date: Wed, 11 Jan 2012 20:10:23 +0100
+Subject: [PATCH 26/63] rv34: fix and optimise frame dependency checking
+
+The sporadic threading errors during fate-rv30 were caused by calling
+ff_thread_await_progress with mb row -1 as argument. That returns
+immediately since progress is initialized to -1. Not yet computed
+motion vectors from the reference could be used for the first
+macroblocks.
+---
+ libavcodec/rv34.c | 5 +++--
+ 1 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
+index 6cfefa0..48b5193 100644
+--- a/libavcodec/rv34.c
++++ b/libavcodec/rv34.c
+@@ -685,7 +685,8 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
+
+ if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
+ /* wait for the referenced mb row to be finished */
+- int mb_row = FFMIN(s->mb_height - 1, s->mb_y + ((yoff + my + 21) >> 4));
++ int mb_row = FFMIN(s->mb_height - 1,
++ s->mb_y + ((yoff + my + 5 + 8 * height) >> 4));
+ AVFrame *f = dir ? &s->next_picture_ptr->f : &s->last_picture_ptr->f;
+ ff_thread_await_progress(f, mb_row, 0);
+ }
+@@ -847,7 +848,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type)
+ //surprisingly, it uses motion scheme from next reference frame
+ /* wait for the current mb row to be finished */
+ if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
+- ff_thread_await_progress(&s->next_picture_ptr->f, s->mb_y - 1, 0);
++ ff_thread_await_progress(&s->next_picture_ptr->f, FFMAX(0, s->mb_y-1), 0);
+
+ next_bt = s->next_picture_ptr->f.mb_type[s->mb_x + s->mb_y * s->mb_stride];
+ if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0027-avio-Fix-the-value-of-the-deprecated-URL_FLAG_NONBLO.patch b/debian/patches/post-0.8b2/0027-avio-Fix-the-value-of-the-deprecated-URL_FLAG_NONBLO.patch
new file mode 100644
index 0000000..4516349
--- /dev/null
+++ b/debian/patches/post-0.8b2/0027-avio-Fix-the-value-of-the-deprecated-URL_FLAG_NONBLO.patch
@@ -0,0 +1,36 @@
+From 6b9e4eea839b9f75dc4cad628c923d5c70d704d1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Thu, 12 Jan 2012 17:06:04 +0200
+Subject: [PATCH 27/63] avio: Fix the value of the deprecated
+ URL_FLAG_NONBLOCK
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This isn't used in practice anywhere within libav at the moment,
+but change it for consistency until it is removed.
+URL_RDONLY/WRONLY were fixed in commit 5b81e295931 (after the
+values that actually were used were changed at the major bump,
+in commit cbea3ac8), but this flag was unintentionally left unfixed.
+
+Signed-off-by: Martin Storsjö <martin at martin.st>
+---
+ libavformat/avio.h | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavformat/avio.h b/libavformat/avio.h
+index e73264f..78935d9 100644
+--- a/libavformat/avio.h
++++ b/libavformat/avio.h
+@@ -204,7 +204,7 @@ attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
+ * Warning: non-blocking protocols is work-in-progress; this flag may be
+ * silently ignored.
+ */
+-#define URL_FLAG_NONBLOCK 4
++#define URL_FLAG_NONBLOCK 8
+
+ typedef int URLInterruptCB(void);
+ extern URLInterruptCB *url_interrupt_cb;
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0028-ARM-rv34-fix-asm-syntax-in-dc-transform-functions.patch b/debian/patches/post-0.8b2/0028-ARM-rv34-fix-asm-syntax-in-dc-transform-functions.patch
new file mode 100644
index 0000000..ebc2d9d
--- /dev/null
+++ b/debian/patches/post-0.8b2/0028-ARM-rv34-fix-asm-syntax-in-dc-transform-functions.patch
@@ -0,0 +1,59 @@
+From 81dc6a2a3cefc1f1bbbc249052b3374e524d1ea0 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans at mansr.com>
+Date: Thu, 12 Jan 2012 19:37:31 +0000
+Subject: [PATCH 28/63] ARM: rv34: fix asm syntax in dc transform functions
+
+Signed-off-by: Mans Rullgard <mans at mansr.com>
+Signed-off-by: Janne Grunau <janne-libav at jannau.net>
+---
+ libavcodec/arm/rv34dsp_neon.S | 22 +++++++++++-----------
+ 1 files changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/libavcodec/arm/rv34dsp_neon.S b/libavcodec/arm/rv34dsp_neon.S
+index e776af0..1e8d4b4 100644
+--- a/libavcodec/arm/rv34dsp_neon.S
++++ b/libavcodec/arm/rv34dsp_neon.S
+@@ -110,29 +110,29 @@ endfunc
+
+ /* void rv34_inv_transform_dc_c(DCTELEM *block) */
+ function ff_rv34_inv_transform_dc_neon, export=1
+- vld1.16 d28[], [r0:16] @ block[0]
++ vld1.16 {d28[]}, [r0,:16] @ block[0]
+ vmov.i16 d4, #169
+ mov r1, #16
+ vmull.s16 q3, d28, d4
+ vrshrn.s32 d0, q3, #10
+- vst1.16 {d0}, [r0:64], r1
+- vst1.16 {d0}, [r0:64], r1
+- vst1.16 {d0}, [r0:64], r1
+- vst1.16 {d0}, [r0:64], r1
++ vst1.16 {d0}, [r0,:64], r1
++ vst1.16 {d0}, [r0,:64], r1
++ vst1.16 {d0}, [r0,:64], r1
++ vst1.16 {d0}, [r0,:64], r1
+ bx lr
+ endfunc
+
+ /* void rv34_inv_transform_dc_noround_c(DCTELEM *block) */
+ function ff_rv34_inv_transform_noround_dc_neon, export=1
+- vld1.16 d28[], [r0:16] @ block[0]
++ vld1.16 {d28[]}, [r0,:16] @ block[0]
+ vmov.i16 d4, #251
+- vorr.s16 d4, #256 @ 13^2 * 3
++ vorr.s16 d4, #256 @ 13^2 * 3
+ mov r1, #16
+ vmull.s16 q3, d28, d4
+ vshrn.s32 d0, q3, #11
+- vst1.64 {d0}, [r0:64], r1
+- vst1.64 {d0}, [r0:64], r1
+- vst1.64 {d0}, [r0:64], r1
+- vst1.64 {d0}, [r0:64], r1
++ vst1.64 {d0}, [r0,:64], r1
++ vst1.64 {d0}, [r0,:64], r1
++ vst1.64 {d0}, [r0,:64], r1
++ vst1.64 {d0}, [r0,:64], r1
+ bx lr
+ endfunc
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0029-utils-Check-for-extradata-size-overflows.patch b/debian/patches/post-0.8b2/0029-utils-Check-for-extradata-size-overflows.patch
new file mode 100644
index 0000000..19c3067
--- /dev/null
+++ b/debian/patches/post-0.8b2/0029-utils-Check-for-extradata-size-overflows.patch
@@ -0,0 +1,61 @@
+From 4df30f71147b7bedd4457bcfa0e4efe01085af9f Mon Sep 17 00:00:00 2001
+From: Alex Converse <alex.converse at gmail.com>
+Date: Thu, 12 Jan 2012 11:12:24 -0800
+Subject: [PATCH 29/63] utils: Check for extradata size overflows.
+
+---
+ libavcodec/internal.h | 7 +++++++
+ libavcodec/utils.c | 3 +++
+ libavformat/utils.c | 4 +++-
+ 3 files changed, 13 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/internal.h b/libavcodec/internal.h
+index b5a0454..1c2d0da 100644
+--- a/libavcodec/internal.h
++++ b/libavcodec/internal.h
+@@ -94,4 +94,11 @@ unsigned int avpriv_toupper4(unsigned int x);
+ int avpriv_lock_avformat(void);
+ int avpriv_unlock_avformat(void);
+
++/**
++ * Maximum size in bytes of extradata.
++ * This value was chosen such that every bit of the buffer is
++ * addressable by a 32-bit signed integer as used by get_bits.
++ */
++#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE)
++
+ #endif /* AVCODEC_INTERNAL_H */
+diff --git a/libavcodec/utils.c b/libavcodec/utils.c
+index 2bc1dcf..6f4d7e6 100644
+--- a/libavcodec/utils.c
++++ b/libavcodec/utils.c
+@@ -610,6 +610,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
+ int ret = 0;
+ AVDictionary *tmp = NULL;
+
++ if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
++ return AVERROR(EINVAL);
++
+ if (options)
+ av_dict_copy(&tmp, *options, 0);
+
+diff --git a/libavformat/utils.c b/libavformat/utils.c
+index a796658..373f068 100644
+--- a/libavformat/utils.c
++++ b/libavformat/utils.c
+@@ -2442,9 +2442,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
+ }
+ if(st->parser && st->parser->parser->split && !st->codec->extradata){
+ int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
+- if(i){
++ if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
+ st->codec->extradata_size= i;
+ st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
++ if (!st->codec->extradata)
++ return AVERROR(ENOMEM);
+ memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
+ memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0030-cabac-Remove-ff_h264_lps_state-array.patch b/debian/patches/post-0.8b2/0030-cabac-Remove-ff_h264_lps_state-array.patch
new file mode 100644
index 0000000..c281100
--- /dev/null
+++ b/debian/patches/post-0.8b2/0030-cabac-Remove-ff_h264_lps_state-array.patch
@@ -0,0 +1,46 @@
+From 64d779f2f7607070a87b0a70edeba5e51834ce85 Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Thu, 12 Jan 2012 21:11:27 +0100
+Subject: [PATCH 30/63] cabac: Remove ff_h264_lps_state array.
+
+It was only ever used in the cabac test program, but never initialized.
+---
+ libavcodec/cabac.c | 2 --
+ libavcodec/cabac.h | 1 -
+ 2 files changed, 0 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
+index 54414fa..1de4584 100644
+--- a/libavcodec/cabac.c
++++ b/libavcodec/cabac.c
+@@ -51,7 +51,6 @@ static const uint8_t lps_range[64][4]= {
+
+ uint8_t ff_h264_mlps_state[4*64];
+ uint8_t ff_h264_lps_range[4*2*64];
+-uint8_t ff_h264_lps_state[2*64];
+ uint8_t ff_h264_mps_state[2*64];
+
+ static const uint8_t mps_state[64]= {
+@@ -196,7 +195,6 @@ static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
+ }else{
+ c->low += c->range - RangeLPS;
+ c->range = RangeLPS;
+- *state= ff_h264_lps_state[*state];
+ }
+
+ renorm_cabac_encoder(c);
+diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
+index dda6348..f7d169a 100644
+--- a/libavcodec/cabac.h
++++ b/libavcodec/cabac.h
+@@ -50,7 +50,6 @@ typedef struct CABACContext{
+ extern uint8_t ff_h264_mlps_state[4*64];
+ extern uint8_t ff_h264_lps_range[4*2*64]; ///< rangeTabLPS
+ extern uint8_t ff_h264_mps_state[2*64]; ///< transIdxMPS
+-extern uint8_t ff_h264_lps_state[2*64]; ///< transIdxLPS
+ extern const uint8_t ff_h264_norm_shift[512];
+
+ #if ARCH_X86
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0031-cabac-Mark-ff_h264_mps_state-array-as-static-it-is-o.patch b/debian/patches/post-0.8b2/0031-cabac-Mark-ff_h264_mps_state-array-as-static-it-is-o.patch
new file mode 100644
index 0000000..87be293
--- /dev/null
+++ b/debian/patches/post-0.8b2/0031-cabac-Mark-ff_h264_mps_state-array-as-static-it-is-o.patch
@@ -0,0 +1,60 @@
+From 0a60780c7fe72e2f9cc41efc152b3807954b7820 Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Thu, 12 Jan 2012 21:35:34 +0100
+Subject: [PATCH 31/63] cabac: Mark ff_h264_mps_state array as static, it is
+ only used within cabac.c.
+
+---
+ libavcodec/cabac.c | 8 ++++----
+ libavcodec/cabac.h | 1 -
+ 2 files changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
+index 1de4584..11971f5 100644
+--- a/libavcodec/cabac.c
++++ b/libavcodec/cabac.c
+@@ -51,7 +51,7 @@ static const uint8_t lps_range[64][4]= {
+
+ uint8_t ff_h264_mlps_state[4*64];
+ uint8_t ff_h264_lps_range[4*2*64];
+-uint8_t ff_h264_mps_state[2*64];
++static uint8_t h264_mps_state[2 * 64];
+
+ static const uint8_t mps_state[64]= {
+ 1, 2, 3, 4, 5, 6, 7, 8,
+@@ -140,9 +140,9 @@ void ff_init_cabac_states(CABACContext *c){
+ }
+
+ ff_h264_mlps_state[128+2*i+0]=
+- ff_h264_mps_state[2*i+0]= 2*mps_state[i]+0;
++ h264_mps_state[2 * i + 0] = 2 * mps_state[i] + 0;
+ ff_h264_mlps_state[128+2*i+1]=
+- ff_h264_mps_state[2*i+1]= 2*mps_state[i]+1;
++ h264_mps_state[2 * i + 1] = 2 * mps_state[i] + 1;
+
+ if( i ){
+ ff_h264_mlps_state[128-2*i-1]= 2*lps_state[i]+0;
+@@ -191,7 +191,7 @@ static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
+
+ if(bit == ((*state)&1)){
+ c->range -= RangeLPS;
+- *state= ff_h264_mps_state[*state];
++ *state = h264_mps_state[*state];
+ }else{
+ c->low += c->range - RangeLPS;
+ c->range = RangeLPS;
+diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
+index f7d169a..ab835f9 100644
+--- a/libavcodec/cabac.h
++++ b/libavcodec/cabac.h
+@@ -49,7 +49,6 @@ typedef struct CABACContext{
+
+ extern uint8_t ff_h264_mlps_state[4*64];
+ extern uint8_t ff_h264_lps_range[4*2*64]; ///< rangeTabLPS
+-extern uint8_t ff_h264_mps_state[2*64]; ///< transIdxMPS
+ extern const uint8_t ff_h264_norm_shift[512];
+
+ #if ARCH_X86
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0032-cabac-split-cabac.h-into-declarations-and-function-d.patch b/debian/patches/post-0.8b2/0032-cabac-split-cabac.h-into-declarations-and-function-d.patch
new file mode 100644
index 0000000..9baaeb8
--- /dev/null
+++ b/debian/patches/post-0.8b2/0032-cabac-split-cabac.h-into-declarations-and-function-d.patch
@@ -0,0 +1,402 @@
+From 55b9ef18e4a139fc24a3b695cb3c176f3ced09b8 Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Thu, 12 Jan 2012 21:56:02 +0100
+Subject: [PATCH 32/63] cabac: split cabac.h into declarations and function
+ definitions
+
+This fixes standalone compilation of some decoders with --disable-optimizations.
+cabac.h defines some inline functions that use symbols from cabac.c. Without
+optimizations these inline functions are not eliminated and linking fails with
+references to non-existing symbols.
+
+Splitting the inline functions off into their own header and only #including
+it in the places where the inline functions are used allows #including cabac.h
+from anywhere without ill effects.
+---
+ libavcodec/cabac.c | 1 +
+ libavcodec/cabac.h | 131 +----------------------------------
+ libavcodec/cabac_functions.h | 160 ++++++++++++++++++++++++++++++++++++++++++
+ libavcodec/h264.c | 4 +-
+ libavcodec/h264_cabac.c | 4 +-
+ 5 files changed, 167 insertions(+), 133 deletions(-)
+ create mode 100644 libavcodec/cabac_functions.h
+
+diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
+index 11971f5..4afcafb 100644
+--- a/libavcodec/cabac.c
++++ b/libavcodec/cabac.c
+@@ -29,6 +29,7 @@
+ #include "libavutil/common.h"
+ #include "get_bits.h"
+ #include "cabac.h"
++#include "cabac_functions.h"
+
+ static const uint8_t lps_range[64][4]= {
+ {128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
+diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
+index ab835f9..5a99f0b 100644
+--- a/libavcodec/cabac.h
++++ b/libavcodec/cabac.h
+@@ -27,13 +27,10 @@
+ #ifndef AVCODEC_CABAC_H
+ #define AVCODEC_CABAC_H
+
+-#include <stddef.h>
++#include <stdint.h>
+
+ #include "put_bits.h"
+
+-//#undef NDEBUG
+-#include <assert.h>
+-
+ #define CABAC_BITS 16
+ #define CABAC_MASK ((1<<CABAC_BITS)-1)
+
+@@ -47,134 +44,8 @@ typedef struct CABACContext{
+ PutBitContext pb;
+ }CABACContext;
+
+-extern uint8_t ff_h264_mlps_state[4*64];
+-extern uint8_t ff_h264_lps_range[4*2*64]; ///< rangeTabLPS
+-extern const uint8_t ff_h264_norm_shift[512];
+-
+-#if ARCH_X86
+-# include "x86/cabac.h"
+-#endif
+-
+ void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size);
+ void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
+ void ff_init_cabac_states(CABACContext *c);
+
+-
+-static void refill(CABACContext *c){
+-#if CABAC_BITS == 16
+- c->low+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
+-#else
+- c->low+= c->bytestream[0]<<1;
+-#endif
+- c->low -= CABAC_MASK;
+- c->bytestream+= CABAC_BITS/8;
+-}
+-
+-static inline void renorm_cabac_decoder_once(CABACContext *c){
+- int shift= (uint32_t)(c->range - 0x100)>>31;
+- c->range<<= shift;
+- c->low <<= shift;
+- if(!(c->low & CABAC_MASK))
+- refill(c);
+-}
+-
+-#ifndef get_cabac_inline
+-static void refill2(CABACContext *c){
+- int i, x;
+-
+- x= c->low ^ (c->low-1);
+- i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
+-
+- x= -CABAC_MASK;
+-
+-#if CABAC_BITS == 16
+- x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
+-#else
+- x+= c->bytestream[0]<<1;
+-#endif
+-
+- c->low += x<<i;
+- c->bytestream+= CABAC_BITS/8;
+-}
+-
+-static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){
+- int s = *state;
+- int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s];
+- int bit, lps_mask;
+-
+- c->range -= RangeLPS;
+- lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31;
+-
+- c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask;
+- c->range += (RangeLPS - c->range) & lps_mask;
+-
+- s^=lps_mask;
+- *state= (ff_h264_mlps_state+128)[s];
+- bit= s&1;
+-
+- lps_mask= ff_h264_norm_shift[c->range];
+- c->range<<= lps_mask;
+- c->low <<= lps_mask;
+- if(!(c->low & CABAC_MASK))
+- refill2(c);
+- return bit;
+-}
+-#endif
+-
+-static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){
+- return get_cabac_inline(c,state);
+-}
+-
+-static int av_unused get_cabac(CABACContext *c, uint8_t * const state){
+- return get_cabac_inline(c,state);
+-}
+-
+-static int av_unused get_cabac_bypass(CABACContext *c){
+- int range;
+- c->low += c->low;
+-
+- if(!(c->low & CABAC_MASK))
+- refill(c);
+-
+- range= c->range<<(CABAC_BITS+1);
+- if(c->low < range){
+- return 0;
+- }else{
+- c->low -= range;
+- return 1;
+- }
+-}
+-
+-
+-#ifndef get_cabac_bypass_sign
+-static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
+- int range, mask;
+- c->low += c->low;
+-
+- if(!(c->low & CABAC_MASK))
+- refill(c);
+-
+- range= c->range<<(CABAC_BITS+1);
+- c->low -= range;
+- mask= c->low >> 31;
+- range &= mask;
+- c->low += range;
+- return (val^mask)-mask;
+-}
+-#endif
+-
+-/**
+- *
+- * @return the number of bytes read or 0 if no end
+- */
+-static int av_unused get_cabac_terminate(CABACContext *c){
+- c->range -= 2;
+- if(c->low < c->range<<(CABAC_BITS+1)){
+- renorm_cabac_decoder_once(c);
+- return 0;
+- }else{
+- return c->bytestream - c->bytestream_start;
+- }
+-}
+-
+ #endif /* AVCODEC_CABAC_H */
+diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
+new file mode 100644
+index 0000000..b150aab
+--- /dev/null
++++ b/libavcodec/cabac_functions.h
+@@ -0,0 +1,160 @@
++/*
++ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
++ * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
++ *
++ * 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
++ */
++
++/**
++ * @file
++ * Context Adaptive Binary Arithmetic Coder inline functions
++ */
++
++#ifndef AVCODEC_CABAC_FUNCTIONS_H
++#define AVCODEC_CABAC_FUNCTIONS_H
++
++#include <stdint.h>
++
++#include "cabac.h"
++#include "config.h"
++
++#if ARCH_X86
++# include "x86/cabac.h"
++#endif
++
++extern const uint8_t ff_h264_norm_shift[512];
++extern uint8_t ff_h264_mlps_state[4*64];
++extern uint8_t ff_h264_lps_range[4*2*64]; ///< rangeTabLPS
++
++static void refill(CABACContext *c){
++#if CABAC_BITS == 16
++ c->low+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
++#else
++ c->low+= c->bytestream[0]<<1;
++#endif
++ c->low -= CABAC_MASK;
++ c->bytestream+= CABAC_BITS/8;
++}
++
++static inline void renorm_cabac_decoder_once(CABACContext *c){
++ int shift= (uint32_t)(c->range - 0x100)>>31;
++ c->range<<= shift;
++ c->low <<= shift;
++ if(!(c->low & CABAC_MASK))
++ refill(c);
++}
++
++#ifndef get_cabac_inline
++static void refill2(CABACContext *c){
++ int i, x;
++
++ x= c->low ^ (c->low-1);
++ i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
++
++ x= -CABAC_MASK;
++
++#if CABAC_BITS == 16
++ x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
++#else
++ x+= c->bytestream[0]<<1;
++#endif
++
++ c->low += x<<i;
++ c->bytestream+= CABAC_BITS/8;
++}
++
++static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){
++ int s = *state;
++ int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s];
++ int bit, lps_mask;
++
++ c->range -= RangeLPS;
++ lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31;
++
++ c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask;
++ c->range += (RangeLPS - c->range) & lps_mask;
++
++ s^=lps_mask;
++ *state= (ff_h264_mlps_state+128)[s];
++ bit= s&1;
++
++ lps_mask= ff_h264_norm_shift[c->range];
++ c->range<<= lps_mask;
++ c->low <<= lps_mask;
++ if(!(c->low & CABAC_MASK))
++ refill2(c);
++ return bit;
++}
++#endif
++
++static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){
++ return get_cabac_inline(c,state);
++}
++
++static int av_unused get_cabac(CABACContext *c, uint8_t * const state){
++ return get_cabac_inline(c,state);
++}
++
++static int av_unused get_cabac_bypass(CABACContext *c){
++ int range;
++ c->low += c->low;
++
++ if(!(c->low & CABAC_MASK))
++ refill(c);
++
++ range= c->range<<(CABAC_BITS+1);
++ if(c->low < range){
++ return 0;
++ }else{
++ c->low -= range;
++ return 1;
++ }
++}
++
++
++#ifndef get_cabac_bypass_sign
++static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
++ int range, mask;
++ c->low += c->low;
++
++ if(!(c->low & CABAC_MASK))
++ refill(c);
++
++ range= c->range<<(CABAC_BITS+1);
++ c->low -= range;
++ mask= c->low >> 31;
++ range &= mask;
++ c->low += range;
++ return (val^mask)-mask;
++}
++#endif
++
++/**
++ *
++ * @return the number of bytes read or 0 if no end
++ */
++static int av_unused get_cabac_terminate(CABACContext *c){
++ c->range -= 2;
++ if(c->low < c->range<<(CABAC_BITS+1)){
++ renorm_cabac_decoder_once(c);
++ return 0;
++ }else{
++ return c->bytestream - c->bytestream_start;
++ }
++}
++
++#endif /* AVCODEC_CABAC_FUNCTIONS_H */
+diff --git a/libavcodec/h264.c b/libavcodec/h264.c
+index cee16e7..581848b 100644
+--- a/libavcodec/h264.c
++++ b/libavcodec/h264.c
+@@ -27,6 +27,8 @@
+
+ #include "libavutil/imgutils.h"
+ #include "internal.h"
++#include "cabac.h"
++#include "cabac_functions.h"
+ #include "dsputil.h"
+ #include "avcodec.h"
+ #include "mpegvideo.h"
+@@ -40,8 +42,6 @@
+ #include "vdpau_internal.h"
+ #include "libavutil/avassert.h"
+
+-#include "cabac.h"
+-
+ //#undef NDEBUG
+ #include <assert.h>
+
+diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
+index feadf49..a49ac6d 100644
+--- a/libavcodec/h264_cabac.c
++++ b/libavcodec/h264_cabac.c
+@@ -27,6 +27,9 @@
+
+ #define CABAC 1
+
++#include "config.h"
++#include "cabac.h"
++#include "cabac_functions.h"
+ #include "internal.h"
+ #include "dsputil.h"
+ #include "avcodec.h"
+@@ -35,7 +38,6 @@
+ #include "h264_mvpred.h"
+ #include "golomb.h"
+
+-#include "cabac.h"
+ #if ARCH_X86
+ #include "x86/h264_i386.h"
+ #endif
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0033-swscale-fix-invalid-conversions-and-memory-problems.patch b/debian/patches/post-0.8b2/0033-swscale-fix-invalid-conversions-and-memory-problems.patch
new file mode 100644
index 0000000..4187f46
--- /dev/null
+++ b/debian/patches/post-0.8b2/0033-swscale-fix-invalid-conversions-and-memory-problems.patch
@@ -0,0 +1,105 @@
+From e7843db3df0224cafcc1af9da103a3a7286ae2ba Mon Sep 17 00:00:00 2001
+From: "Ronald S. Bultje" <rsbultje at gmail.com>
+Date: Thu, 12 Jan 2012 15:37:58 -0800
+Subject: [PATCH 33/63] swscale: fix invalid conversions and memory problems.
+
+Fixes problems where rgbToRgbWrapper() is called even though it doesn't
+support this particular conversion (e.g. converting from RGB444 to
+anything). Thirdly, fixes issues where rgbToRgbWrapper() is called for
+non-native endiannness conversions (e.g. RGB555BE on a LE system).
+Fourthly, fixes crashes when converting from e.g. monowhite to
+monowhite, which calls planarCopyWrapper() and overwrites/reads because
+n_bytes != n_pixels.
+---
+ libswscale/swscale_unscaled.c | 49 ++++++++++++++++++++++++----------------
+ 1 files changed, 29 insertions(+), 20 deletions(-)
+
+diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
+index a1b7199..e497fef 100644
+--- a/libswscale/swscale_unscaled.c
++++ b/libswscale/swscale_unscaled.c
+@@ -352,17 +352,22 @@ static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
+ )
+
+ /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
+-static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
+- int srcSliceY, int srcSliceH, uint8_t *dst[],
+- int dstStride[])
++typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
++static rgbConvFn findRgbConvFn(SwsContext *c)
+ {
+ const enum PixelFormat srcFormat = c->srcFormat;
+ const enum PixelFormat dstFormat = c->dstFormat;
+- const int srcBpp = (c->srcFormatBpp + 7) >> 3;
+- const int dstBpp = (c->dstFormatBpp + 7) >> 3;
+ const int srcId = c->srcFormatBpp;
+ const int dstId = c->dstFormatBpp;
+- void (*conv)(const uint8_t *src, uint8_t *dst, int src_size) = NULL;
++ rgbConvFn conv = NULL;
++
++#define IS_NOT_NE(bpp, fmt) \
++ (((bpp + 7) >> 3) == 2 && \
++ (!(av_pix_fmt_descriptors[fmt].flags & PIX_FMT_BE) != !HAVE_BIGENDIAN))
++
++ /* if this is non-native rgb444/555/565, don't handle it here. */
++ if (IS_NOT_NE(srcId, srcFormat) || IS_NOT_NE(dstId, dstFormat))
++ return NULL;
+
+ #define CONV_IS(src, dst) (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)
+
+@@ -419,6 +424,21 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
+ }
+ }
+
++ return conv;
++}
++
++/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
++static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
++ int srcSliceY, int srcSliceH, uint8_t *dst[],
++ int dstStride[])
++
++{
++ const enum PixelFormat srcFormat = c->srcFormat;
++ const enum PixelFormat dstFormat = c->dstFormat;
++ const int srcBpp = (c->srcFormatBpp + 7) >> 3;
++ const int dstBpp = (c->dstFormatBpp + 7) >> 3;
++ rgbConvFn conv = findRgbConvFn(c);
++
+ if (!conv) {
+ av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
+ sws_format_name(srcFormat), sws_format_name(dstFormat));
+@@ -716,6 +736,8 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
+ } else {
+ if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
+ length *= 2;
++ else if (!av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1)
++ length >>= 3; // monowhite/black
+ for (i = 0; i < height; i++) {
+ memcpy(dstPtr, srcPtr, length);
+ srcPtr += srcStride[plane];
+@@ -770,20 +792,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
+ c->swScale = bgr24ToYv12Wrapper;
+
+ /* RGB/BGR -> RGB/BGR (no dither needed forms) */
+- if ( isAnyRGB(srcFormat)
+- && isAnyRGB(dstFormat)
+- && srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8
+- && srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8
+- && srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4
+- && srcFormat != PIX_FMT_RGB4 && dstFormat != PIX_FMT_RGB4
+- && srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE
+- && srcFormat != PIX_FMT_RGB4_BYTE && dstFormat != PIX_FMT_RGB4_BYTE
+- && srcFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_MONOBLACK
+- && srcFormat != PIX_FMT_MONOWHITE && dstFormat != PIX_FMT_MONOWHITE
+- && srcFormat != PIX_FMT_RGB48LE && dstFormat != PIX_FMT_RGB48LE
+- && srcFormat != PIX_FMT_RGB48BE && dstFormat != PIX_FMT_RGB48BE
+- && srcFormat != PIX_FMT_BGR48LE && dstFormat != PIX_FMT_BGR48LE
+- && srcFormat != PIX_FMT_BGR48BE && dstFormat != PIX_FMT_BGR48BE
++ if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
+ && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))
+ c->swScale= rgbToRgbWrapper;
+
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0034-swscale-test-fix-stack-overread.patch b/debian/patches/post-0.8b2/0034-swscale-test-fix-stack-overread.patch
new file mode 100644
index 0000000..c186961
--- /dev/null
+++ b/debian/patches/post-0.8b2/0034-swscale-test-fix-stack-overread.patch
@@ -0,0 +1,29 @@
+From 06b0246da07e7c9d95476b35275a63cd6dbc300c Mon Sep 17 00:00:00 2001
+From: "Ronald S. Bultje" <rsbultje at gmail.com>
+Date: Thu, 12 Jan 2012 15:38:37 -0800
+Subject: [PATCH 34/63] swscale-test: fix stack overread.
+
+Fixes problems in swscale-test where it gives a 3-member array to a
+function expecting a 4-member array.
+---
+ libswscale/swscale-test.c | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c
+index 7ea01a6..3497dff 100644
+--- a/libswscale/swscale-test.c
++++ b/libswscale/swscale-test.c
+@@ -337,8 +337,8 @@ int main(int argc, char **argv)
+ enum PixelFormat srcFormat = PIX_FMT_NONE;
+ enum PixelFormat dstFormat = PIX_FMT_NONE;
+ uint8_t *rgb_data = av_malloc(W * H * 4);
+- uint8_t *rgb_src[3] = { rgb_data, NULL, NULL };
+- int rgb_stride[3] = { 4 * W, 0, 0 };
++ uint8_t *rgb_src[4] = { rgb_data, NULL, NULL, NULL };
++ int rgb_stride[4] = { 4 * W, 0, 0, 0 };
+ uint8_t *data = av_malloc(4 * W * H);
+ uint8_t *src[4] = { data, data + W * H, data + W * H * 2, data + W * H * 3 };
+ int stride[4] = { W, W, W, W };
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0035-rgb2rgb-rgb12to15.patch b/debian/patches/post-0.8b2/0035-rgb2rgb-rgb12to15.patch
new file mode 100644
index 0000000..e47c003
--- /dev/null
+++ b/debian/patches/post-0.8b2/0035-rgb2rgb-rgb12to15.patch
@@ -0,0 +1,69 @@
+From 0cc1a86dc34b020d857f946e47edf9e425274330 Mon Sep 17 00:00:00 2001
+From: Paul B Mahol <onemda at gmail.com>
+Date: Thu, 12 Jan 2012 20:28:47 +0000
+Subject: [PATCH 35/63] rgb2rgb: rgb12to15()
+
+Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>
+---
+ libswscale/rgb2rgb.c | 19 +++++++++++++++++++
+ libswscale/rgb2rgb.h | 1 +
+ libswscale/swscale_unscaled.c | 1 +
+ 3 files changed, 21 insertions(+), 0 deletions(-)
+
+diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
+index 9fbb6cf..47b06f5 100644
+--- a/libswscale/rgb2rgb.c
++++ b/libswscale/rgb2rgb.c
+@@ -183,6 +183,25 @@ void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
+ }
+ }
+
++void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
++{
++ const uint16_t *end;
++ uint16_t *d = (uint16_t *)dst;
++ const uint16_t *s = (const uint16_t *)src;
++ uint16_t rgb, r, g, b;
++ end = s + src_size / 2;
++ while (s < end) {
++ rgb = *s++;
++ r = rgb & 0xF00;
++ g = rgb & 0x0F0;
++ b = rgb & 0x00F;
++ r = (r << 3) | ((r & 0x800) >> 1);
++ g = (g << 2) | ((g & 0x080) >> 2);
++ b = (b << 1) | ( b >> 3);
++ *d++ = r | g | b;
++ }
++}
++
+ void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
+ {
+ const uint16_t *end;
+diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h
+index bfb85d7..42f468f 100644
+--- a/libswscale/rgb2rgb.h
++++ b/libswscale/rgb2rgb.h
+@@ -63,6 +63,7 @@ void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size);
+ void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size);
+ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size);
+ void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size);
++void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size);
+ void bgr8torgb8(const uint8_t *src, uint8_t *dst, int src_size);
+
+ void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size);
+diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
+index e497fef..5fe2b14 100644
+--- a/libswscale/swscale_unscaled.c
++++ b/libswscale/swscale_unscaled.c
+@@ -389,6 +389,7 @@ static rgbConvFn findRgbConvFn(SwsContext *c)
+ if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
+ (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
+ switch (srcId | (dstId << 16)) {
++ case 0x000F000C: conv = rgb12to15; break;
+ case 0x000F0010: conv = rgb16to15; break;
+ case 0x000F0018: conv = rgb24to15; break;
+ case 0x000F0020: conv = rgb32to15; break;
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0036-ARM-4-byte-align-start-of-all-asm-functions.patch b/debian/patches/post-0.8b2/0036-ARM-4-byte-align-start-of-all-asm-functions.patch
new file mode 100644
index 0000000..2cbb9ae
--- /dev/null
+++ b/debian/patches/post-0.8b2/0036-ARM-4-byte-align-start-of-all-asm-functions.patch
@@ -0,0 +1,32 @@
+From 5c5e1ea3cdccc5af0b2d3de15a9c3739c30ec88c Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans at mansr.com>
+Date: Fri, 13 Jan 2012 18:56:36 +0000
+Subject: [PATCH 36/63] ARM: 4-byte align start of all asm functions
+
+Due to apprent bugs in the GNU assembler and/or linker, relocations
+can be incorrectly processed if the alignment of a Thumb instruction
+is changed in the output file compared to the input object.
+
+This fixes crashes in h264 decoding with Thumb enabled. No effect in
+ARM mode since everything is 4-byte aligned there.
+
+Signed-off-by: Mans Rullgard <mans at mansr.com>
+---
+ libavcodec/arm/asm.S | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/arm/asm.S b/libavcodec/arm/asm.S
+index aaf497e..3b495a2 100644
+--- a/libavcodec/arm/asm.S
++++ b/libavcodec/arm/asm.S
+@@ -68,6 +68,7 @@ ELF .size \name, . - \name
+ .purgem endfunc
+ .endm
+ .text
++ .align 2
+ .if \export
+ .global EXTERN_ASM\name
+ EXTERN_ASM\name:
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0037-ARM-fix-Thumb-mode-simple_idct_arm.patch b/debian/patches/post-0.8b2/0037-ARM-fix-Thumb-mode-simple_idct_arm.patch
new file mode 100644
index 0000000..8a8ed3c
--- /dev/null
+++ b/debian/patches/post-0.8b2/0037-ARM-fix-Thumb-mode-simple_idct_arm.patch
@@ -0,0 +1,31 @@
+From 71b3a63e9c87057a1cc1431ac1edd6854e1e4e44 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans at mansr.com>
+Date: Fri, 13 Jan 2012 19:03:14 +0000
+Subject: [PATCH 37/63] ARM: fix Thumb-mode simple_idct_arm
+
+The alignment directive must obviously precede the label.
+This was never noticed in ARM mode since the location is
+already aligned there.
+
+Signed-off-by: Mans Rullgard <mans at mansr.com>
+---
+ libavcodec/arm/simple_idct_arm.S | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/arm/simple_idct_arm.S b/libavcodec/arm/simple_idct_arm.S
+index 1490f53..a9c3095 100644
+--- a/libavcodec/arm/simple_idct_arm.S
++++ b/libavcodec/arm/simple_idct_arm.S
+@@ -491,8 +491,8 @@ __end_bef_a_evaluation:
+ bal __end_a_evaluation
+
+
+-__constant_ptr__: @@ see #defines at the beginning of the source code for values.
+ .align
++__constant_ptr__: @@ see #defines at the beginning of the source code for values.
+ .word W1
+ .word W2
+ .word W3
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0038-FATE-add-tests-for-targa.patch b/debian/patches/post-0.8b2/0038-FATE-add-tests-for-targa.patch
new file mode 100644
index 0000000..a9c36cc
--- /dev/null
+++ b/debian/patches/post-0.8b2/0038-FATE-add-tests-for-targa.patch
@@ -0,0 +1,130 @@
+From 68d6012c723bb520daac5336dcb046c0a5dd3826 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Wed, 11 Jan 2012 20:06:46 -0500
+Subject: [PATCH 38/63] FATE: add tests for targa
+
+Based on a patch by Oana Stratulat <oanaandreeastratulat at gmail.com>
+---
+ tests/fate/image.mak | 28 ++++++++++++++++++++++++++++
+ tests/ref/fate/targa-conformance-CBW8 | 1 +
+ tests/ref/fate/targa-conformance-CTC16 | 1 +
+ tests/ref/fate/targa-conformance-CTC24 | 1 +
+ tests/ref/fate/targa-conformance-CTC32 | 1 +
+ tests/ref/fate/targa-conformance-UBW8 | 1 +
+ tests/ref/fate/targa-conformance-UTC16 | 1 +
+ tests/ref/fate/targa-conformance-UTC24 | 1 +
+ tests/ref/fate/targa-conformance-UTC32 | 1 +
+ tests/ref/fate/targa-top-to-bottom | 1 +
+ 10 files changed, 37 insertions(+), 0 deletions(-)
+ create mode 100644 tests/ref/fate/targa-conformance-CBW8
+ create mode 100644 tests/ref/fate/targa-conformance-CTC16
+ create mode 100644 tests/ref/fate/targa-conformance-CTC24
+ create mode 100644 tests/ref/fate/targa-conformance-CTC32
+ create mode 100644 tests/ref/fate/targa-conformance-UBW8
+ create mode 100644 tests/ref/fate/targa-conformance-UTC16
+ create mode 100644 tests/ref/fate/targa-conformance-UTC24
+ create mode 100644 tests/ref/fate/targa-conformance-UTC32
+ create mode 100644 tests/ref/fate/targa-top-to-bottom
+
+diff --git a/tests/fate/image.mak b/tests/fate/image.mak
+index 9c5106f..153a4f3 100644
+--- a/tests/fate/image.mak
++++ b/tests/fate/image.mak
+@@ -30,3 +30,31 @@ fate-sunraster-24bit-raw: CMD = framecrc -i $(SAMPLES)/sunraster/lena-24bit-raw.
+
+ FATE_TESTS += fate-sunraster-24bit-rle
+ fate-sunraster-24bit-rle: CMD = framecrc -i $(SAMPLES)/sunraster/lena-24bit-rle.sun
++
++FATE_TARGA = CBW8 \
++ CTC16 \
++ CTC24 \
++ CTC32 \
++ UBW8 \
++ UTC16 \
++ UTC24 \
++ UTC32
++
++FATE_TARGA := $(FATE_TARGA:%=fate-targa-conformance-%) \
++ fate-targa-top-to-bottom
++
++FATE_TESTS += $(FATE_TARGA)
++fate-targa: $(FATE_TARGA)
++
++fate-targa-conformance-CBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CBW8.TGA
++# fate-targa-conformance-CCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CCM8.TGA
++fate-targa-conformance-CTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC16.TGA
++fate-targa-conformance-CTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC24.TGA
++fate-targa-conformance-CTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC32.TGA
++fate-targa-conformance-UBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UBW8.TGA
++# fate-targa-conformance-UCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UCM8.TGA
++fate-targa-conformance-UTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC16.TGA
++fate-targa-conformance-UTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC24.TGA
++fate-targa-conformance-UTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC32.TGA
++
++fate-targa-top-to-bottom: CMD = framecrc -i $(SAMPLES)/targa/lena-top-to-bottom.tga
+diff --git a/tests/ref/fate/targa-conformance-CBW8 b/tests/ref/fate/targa-conformance-CBW8
+new file mode 100644
+index 0000000..4ff3a9d
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-CBW8
+@@ -0,0 +1 @@
++0, 0, 16384, 0x267e21ef
+diff --git a/tests/ref/fate/targa-conformance-CTC16 b/tests/ref/fate/targa-conformance-CTC16
+new file mode 100644
+index 0000000..d2c75f6
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-CTC16
+@@ -0,0 +1 @@
++0, 0, 32768, 0xa6b3d20d
+diff --git a/tests/ref/fate/targa-conformance-CTC24 b/tests/ref/fate/targa-conformance-CTC24
+new file mode 100644
+index 0000000..42e1271
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-CTC24
+@@ -0,0 +1 @@
++0, 0, 49152, 0xaca4bc29
+diff --git a/tests/ref/fate/targa-conformance-CTC32 b/tests/ref/fate/targa-conformance-CTC32
+new file mode 100644
+index 0000000..acc3068
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-CTC32
+@@ -0,0 +1 @@
++0, 0, 65536, 0xcf98bc29
+diff --git a/tests/ref/fate/targa-conformance-UBW8 b/tests/ref/fate/targa-conformance-UBW8
+new file mode 100644
+index 0000000..4ff3a9d
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-UBW8
+@@ -0,0 +1 @@
++0, 0, 16384, 0x267e21ef
+diff --git a/tests/ref/fate/targa-conformance-UTC16 b/tests/ref/fate/targa-conformance-UTC16
+new file mode 100644
+index 0000000..d2c75f6
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-UTC16
+@@ -0,0 +1 @@
++0, 0, 32768, 0xa6b3d20d
+diff --git a/tests/ref/fate/targa-conformance-UTC24 b/tests/ref/fate/targa-conformance-UTC24
+new file mode 100644
+index 0000000..42e1271
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-UTC24
+@@ -0,0 +1 @@
++0, 0, 49152, 0xaca4bc29
+diff --git a/tests/ref/fate/targa-conformance-UTC32 b/tests/ref/fate/targa-conformance-UTC32
+new file mode 100644
+index 0000000..acc3068
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-UTC32
+@@ -0,0 +1 @@
++0, 0, 65536, 0xcf98bc29
+diff --git a/tests/ref/fate/targa-top-to-bottom b/tests/ref/fate/targa-top-to-bottom
+new file mode 100644
+index 0000000..e9d53bb
+--- /dev/null
++++ b/tests/ref/fate/targa-top-to-bottom
+@@ -0,0 +1 @@
++0, 0, 196608, 0xb29ec51a
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0039-FATE-fix-targa-tests-on-big-endian-systems.patch b/debian/patches/post-0.8b2/0039-FATE-fix-targa-tests-on-big-endian-systems.patch
new file mode 100644
index 0000000..47848ac
--- /dev/null
+++ b/debian/patches/post-0.8b2/0039-FATE-fix-targa-tests-on-big-endian-systems.patch
@@ -0,0 +1,34 @@
+From e1a7af6f290489812ed47359eaff0edac2f5df95 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Fri, 13 Jan 2012 16:14:48 -0500
+Subject: [PATCH 39/63] FATE: fix targa tests on big-endian systems
+
+---
+ tests/fate/image.mak | 8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tests/fate/image.mak b/tests/fate/image.mak
+index 153a4f3..7fdbdc4 100644
+--- a/tests/fate/image.mak
++++ b/tests/fate/image.mak
+@@ -48,13 +48,13 @@ fate-targa: $(FATE_TARGA)
+
+ fate-targa-conformance-CBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CBW8.TGA
+ # fate-targa-conformance-CCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CCM8.TGA
+-fate-targa-conformance-CTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC16.TGA
++fate-targa-conformance-CTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC16.TGA -pix_fmt rgb555le
+ fate-targa-conformance-CTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC24.TGA
+-fate-targa-conformance-CTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC32.TGA
++fate-targa-conformance-CTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC32.TGA -pix_fmt bgra
+ fate-targa-conformance-UBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UBW8.TGA
+ # fate-targa-conformance-UCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UCM8.TGA
+-fate-targa-conformance-UTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC16.TGA
++fate-targa-conformance-UTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC16.TGA -pix_fmt rgb555le
+ fate-targa-conformance-UTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC24.TGA
+-fate-targa-conformance-UTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC32.TGA
++fate-targa-conformance-UTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC32.TGA -pix_fmt bgra
+
+ fate-targa-top-to-bottom: CMD = framecrc -i $(SAMPLES)/targa/lena-top-to-bottom.tga
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0040-targa-add-support-for-rgb555-palette.patch b/debian/patches/post-0.8b2/0040-targa-add-support-for-rgb555-palette.patch
new file mode 100644
index 0000000..0e3f459
--- /dev/null
+++ b/debian/patches/post-0.8b2/0040-targa-add-support-for-rgb555-palette.patch
@@ -0,0 +1,80 @@
+From faaebcdf6bd67880f50e7ec180f24870e7bd8cef Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Mon, 2 Jan 2012 15:17:12 -0500
+Subject: [PATCH 40/63] targa: add support for rgb555 palette
+
+---
+ libavcodec/targa.c | 39 +++++++++++++++++++++++++++++----------
+ 1 files changed, 29 insertions(+), 10 deletions(-)
+
+diff --git a/libavcodec/targa.c b/libavcodec/targa.c
+index b821d74..00da758 100644
+--- a/libavcodec/targa.c
++++ b/libavcodec/targa.c
+@@ -22,6 +22,7 @@
+ #include "libavutil/intreadwrite.h"
+ #include "libavutil/imgutils.h"
+ #include "avcodec.h"
++#include "bytestream.h"
+ #include "targa.h"
+
+ typedef struct TargaContext {
+@@ -172,27 +173,45 @@ static int decode_frame(AVCodecContext *avctx,
+ }
+
+ if(colors){
+- size_t pal_size;
++ int pal_size, pal_sample_size;
+ if((colors + first_clr) > 256){
+ av_log(avctx, AV_LOG_ERROR, "Incorrect palette: %i colors with offset %i\n", colors, first_clr);
+ return -1;
+ }
+- if(csize != 24){
++ switch (csize) {
++ case 24: pal_sample_size = 3; break;
++ case 16:
++ case 15: pal_sample_size = 2; break;
++ default:
+ av_log(avctx, AV_LOG_ERROR, "Palette entry size %i bits is not supported\n", csize);
+ return -1;
+ }
+- pal_size = colors * ((csize + 1) >> 3);
++ pal_size = colors * pal_sample_size;
+ CHECK_BUFFER_SIZE(buf, buf_end, pal_size, "color table");
+ if(avctx->pix_fmt != PIX_FMT_PAL8)//should not occur but skip palette anyway
+ buf += pal_size;
+ else{
+- int r, g, b, t;
+- int32_t *pal = ((int32_t*)p->data[1]) + first_clr;
+- for(t = 0; t < colors; t++){
+- r = *buf++;
+- g = *buf++;
+- b = *buf++;
+- *pal++ = (b << 16) | (g << 8) | r;
++ int t;
++ uint32_t *pal = ((uint32_t *)p->data[1]) + first_clr;
++
++ switch (pal_sample_size) {
++ case 3:
++ /* RGB24 */
++ for (t = 0; t < colors; t++)
++ *pal++ = bytestream_get_le24(&buf);
++ break;
++ case 2:
++ /* RGB555 */
++ for (t = 0; t < colors; t++) {
++ uint32_t v = bytestream_get_le16(&buf);
++ v = ((v & 0x7C00) << 9) |
++ ((v & 0x03E0) << 6) |
++ ((v & 0x001F) << 3);
++ /* left bit replication */
++ v |= (v & 0xE0E0E0U) >> 5;
++ *pal++ = v;
++ }
++ break;
+ }
+ p->palette_has_changed = 1;
+ }
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0041-FATE-enable-the-2-remaining-targa-conformance-suite-.patch b/debian/patches/post-0.8b2/0041-FATE-enable-the-2-remaining-targa-conformance-suite-.patch
new file mode 100644
index 0000000..bc6d6a9
--- /dev/null
+++ b/debian/patches/post-0.8b2/0041-FATE-enable-the-2-remaining-targa-conformance-suite-.patch
@@ -0,0 +1,45 @@
+From 9c2f9b0e2dd5bd570e571890bdfb6e77190c4c55 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Fri, 13 Jan 2012 16:41:15 -0500
+Subject: [PATCH 41/63] FATE: enable the 2 remaining targa conformance suite
+ tests
+
+---
+ tests/fate/image.mak | 6 ++++--
+ 1 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/tests/fate/image.mak b/tests/fate/image.mak
+index 7fdbdc4..df0603f 100644
+--- a/tests/fate/image.mak
++++ b/tests/fate/image.mak
+@@ -32,10 +32,12 @@ FATE_TESTS += fate-sunraster-24bit-rle
+ fate-sunraster-24bit-rle: CMD = framecrc -i $(SAMPLES)/sunraster/lena-24bit-rle.sun
+
+ FATE_TARGA = CBW8 \
++ CCM8 \
+ CTC16 \
+ CTC24 \
+ CTC32 \
+ UBW8 \
++ UCM8 \
+ UTC16 \
+ UTC24 \
+ UTC32
+@@ -47,12 +49,12 @@ FATE_TESTS += $(FATE_TARGA)
+ fate-targa: $(FATE_TARGA)
+
+ fate-targa-conformance-CBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CBW8.TGA
+-# fate-targa-conformance-CCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CCM8.TGA
++fate-targa-conformance-CCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CCM8.TGA
+ fate-targa-conformance-CTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC16.TGA -pix_fmt rgb555le
+ fate-targa-conformance-CTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC24.TGA
+ fate-targa-conformance-CTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC32.TGA -pix_fmt bgra
+ fate-targa-conformance-UBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UBW8.TGA
+-# fate-targa-conformance-UCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UCM8.TGA
++fate-targa-conformance-UCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UCM8.TGA
+ fate-targa-conformance-UTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC16.TGA -pix_fmt rgb555le
+ fate-targa-conformance-UTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC24.TGA
+ fate-targa-conformance-UTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC32.TGA -pix_fmt bgra
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0042-fate-add-missing-reference-files-for-targa-tests-in-.patch b/debian/patches/post-0.8b2/0042-fate-add-missing-reference-files-for-targa-tests-in-.patch
new file mode 100644
index 0000000..daceaa3
--- /dev/null
+++ b/debian/patches/post-0.8b2/0042-fate-add-missing-reference-files-for-targa-tests-in-.patch
@@ -0,0 +1,31 @@
+From 502bf3b462e40ae64d088c3246ef48fa618e4572 Mon Sep 17 00:00:00 2001
+From: Janne Grunau <janne-libav at jannau.net>
+Date: Fri, 13 Jan 2012 23:52:59 +0100
+Subject: [PATCH 42/63] fate: add missing reference files for targa tests in
+ 9c2f9b0e2
+
+Fixes fate-targa-conformance-CCM8 and fate-targa-conformance-UCM8.
+---
+ tests/ref/fate/targa-conformance-CCM8 | 1 +
+ tests/ref/fate/targa-conformance-UCM8 | 1 +
+ 2 files changed, 2 insertions(+), 0 deletions(-)
+ create mode 100644 tests/ref/fate/targa-conformance-CCM8
+ create mode 100644 tests/ref/fate/targa-conformance-UCM8
+
+diff --git a/tests/ref/fate/targa-conformance-CCM8 b/tests/ref/fate/targa-conformance-CCM8
+new file mode 100644
+index 0000000..3f6be24
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-CCM8
+@@ -0,0 +1 @@
++0, 0, 17408, 0x2bc2e306
+diff --git a/tests/ref/fate/targa-conformance-UCM8 b/tests/ref/fate/targa-conformance-UCM8
+new file mode 100644
+index 0000000..3f6be24
+--- /dev/null
++++ b/tests/ref/fate/targa-conformance-UCM8
+@@ -0,0 +1 @@
++0, 0, 17408, 0x2bc2e306
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0043-FATE-convert-output-to-rgba-for-the-targa-tests-whic.patch b/debian/patches/post-0.8b2/0043-FATE-convert-output-to-rgba-for-the-targa-tests-whic.patch
new file mode 100644
index 0000000..8f3e873
--- /dev/null
+++ b/debian/patches/post-0.8b2/0043-FATE-convert-output-to-rgba-for-the-targa-tests-whic.patch
@@ -0,0 +1,49 @@
+From 4c82c6d9932bfdb1a9eb288d566ded9d40ca5e24 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Fri, 13 Jan 2012 18:40:12 -0500
+Subject: [PATCH 43/63] FATE: convert output to rgba for the targa tests which
+ currently output pal8
+
+fixes the tests on big-endian systems
+---
+ tests/fate/image.mak | 4 ++--
+ tests/ref/fate/targa-conformance-CCM8 | 2 +-
+ tests/ref/fate/targa-conformance-UCM8 | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tests/fate/image.mak b/tests/fate/image.mak
+index df0603f..9714cd8 100644
+--- a/tests/fate/image.mak
++++ b/tests/fate/image.mak
+@@ -49,12 +49,12 @@ FATE_TESTS += $(FATE_TARGA)
+ fate-targa: $(FATE_TARGA)
+
+ fate-targa-conformance-CBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CBW8.TGA
+-fate-targa-conformance-CCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CCM8.TGA
++fate-targa-conformance-CCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/CCM8.TGA -pix_fmt rgba
+ fate-targa-conformance-CTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC16.TGA -pix_fmt rgb555le
+ fate-targa-conformance-CTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC24.TGA
+ fate-targa-conformance-CTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/CTC32.TGA -pix_fmt bgra
+ fate-targa-conformance-UBW8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UBW8.TGA
+-fate-targa-conformance-UCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UCM8.TGA
++fate-targa-conformance-UCM8: CMD = framecrc -i $(SAMPLES)/targa-conformance/UCM8.TGA -pix_fmt rgba
+ fate-targa-conformance-UTC16: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC16.TGA -pix_fmt rgb555le
+ fate-targa-conformance-UTC24: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC24.TGA
+ fate-targa-conformance-UTC32: CMD = framecrc -i $(SAMPLES)/targa-conformance/UTC32.TGA -pix_fmt bgra
+diff --git a/tests/ref/fate/targa-conformance-CCM8 b/tests/ref/fate/targa-conformance-CCM8
+index 3f6be24..acc3068 100644
+--- a/tests/ref/fate/targa-conformance-CCM8
++++ b/tests/ref/fate/targa-conformance-CCM8
+@@ -1 +1 @@
+-0, 0, 17408, 0x2bc2e306
++0, 0, 65536, 0xcf98bc29
+diff --git a/tests/ref/fate/targa-conformance-UCM8 b/tests/ref/fate/targa-conformance-UCM8
+index 3f6be24..acc3068 100644
+--- a/tests/ref/fate/targa-conformance-UCM8
++++ b/tests/ref/fate/targa-conformance-UCM8
+@@ -1 +1 @@
+-0, 0, 17408, 0x2bc2e306
++0, 0, 65536, 0xcf98bc29
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0044-libx264-Don-t-leave-max_b_frames-as-1-if-the-user-di.patch b/debian/patches/post-0.8b2/0044-libx264-Don-t-leave-max_b_frames-as-1-if-the-user-di.patch
new file mode 100644
index 0000000..7ccec84
--- /dev/null
+++ b/debian/patches/post-0.8b2/0044-libx264-Don-t-leave-max_b_frames-as-1-if-the-user-di.patch
@@ -0,0 +1,42 @@
+From 57facb73ab940b1117c22ef9b70a6e5ec237112d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Fri, 13 Jan 2012 23:41:16 +0200
+Subject: [PATCH 44/63] libx264: Don't leave max_b_frames as -1 if the user
+ didn't set it
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+max_b_frames is initialized to -1 for libx264, to allow
+distinguishing between an explicit user set 0 and a default not
+touched 0 (see bb73cda2).
+
+If max_b_frames is left as -1, this affects dts generation (where
+expressions like max_b_frames != 0 are used), so make sure it is
+left at the default 0 after the libx264 init function returns.
+
+This avoids unnecessarily producing dts != pts when using
+profile=baseline.
+
+Signed-off-by: Martin Storsjö <martin at martin.st>
+---
+ libavcodec/libx264.c | 3 +++
+ 1 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
+index 9b34795..b3581f1 100644
+--- a/libavcodec/libx264.c
++++ b/libavcodec/libx264.c
+@@ -448,6 +448,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
+ // update AVCodecContext with x264 parameters
+ avctx->has_b_frames = x4->params.i_bframe ?
+ x4->params.i_bframe_pyramid ? 2 : 1 : 0;
++ if (avctx->max_b_frames < 0)
++ avctx->max_b_frames = 0;
++
+ avctx->bit_rate = x4->params.rc.i_bitrate*1000;
+ #if FF_API_X264_GLOBAL_OPTS
+ avctx->crf = x4->params.rc.f_rf_constant;
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0045-swscale-change-yuv2yuvX-code-to-use-cpuflag.patch b/debian/patches/post-0.8b2/0045-swscale-change-yuv2yuvX-code-to-use-cpuflag.patch
new file mode 100644
index 0000000..fb791c7
--- /dev/null
+++ b/debian/patches/post-0.8b2/0045-swscale-change-yuv2yuvX-code-to-use-cpuflag.patch
@@ -0,0 +1,241 @@
+From 3c172a41065dd3fe1d11af9f0eb16d789d08daf2 Mon Sep 17 00:00:00 2001
+From: "Ronald S. Bultje" <rsbultje at gmail.com>
+Date: Fri, 13 Jan 2012 11:21:15 -0800
+Subject: [PATCH 45/63] swscale: change yuv2yuvX code to use cpuflag().
+
+---
+ libswscale/x86/output.asm | 117 ++++++++++++++++++++++-----------------------
+ 1 files changed, 58 insertions(+), 59 deletions(-)
+
+diff --git a/libswscale/x86/output.asm b/libswscale/x86/output.asm
+index 0ec2038..ae2929c 100644
+--- a/libswscale/x86/output.asm
++++ b/libswscale/x86/output.asm
+@@ -56,7 +56,7 @@ SECTION .text
+ ; of 2. $offset is either 0 or 3. $dither holds 8 values.
+ ;-----------------------------------------------------------------------------
+
+-%macro yuv2planeX_fn 4
++%macro yuv2planeX_fn 3
+
+ %ifdef ARCH_X86_32
+ %define cntr_reg r1
+@@ -66,12 +66,12 @@ SECTION .text
+ %define movsx movsxd
+ %endif
+
+-cglobal yuv2planeX_%2_%1, %4, 7, %3
+-%if %2 == 8 || %2 == 9 || %2 == 10
++cglobal yuv2planeX_%1, %3, 7, %2
++%if %1 == 8 || %1 == 9 || %1 == 10
+ pxor m6, m6
+-%endif ; %2 == 8/9/10
++%endif ; %1 == 8/9/10
+
+-%if %2 == 8
++%if %1 == 8
+ %ifdef ARCH_X86_32
+ %assign pad 0x2c - (stack_offset & 15)
+ SUB rsp, pad
+@@ -120,7 +120,7 @@ cglobal yuv2planeX_%2_%1, %4, 7, %3
+ mova [rsp+16], m3
+ mova [rsp+24], m_dith
+ %endif ; mmsize == 8/16
+-%endif ; %2 == 8
++%endif ; %1 == 8
+
+ xor r5, r5
+
+@@ -130,11 +130,11 @@ cglobal yuv2planeX_%2_%1, %4, 7, %3
+ ; 8 pixels but we can only handle 2 pixels per register, and thus 4
+ ; pixels per iteration. In order to not have to keep track of where
+ ; we are w.r.t. dithering, we unroll the mmx/8bit loop x2.
+-%if %2 == 8
++%if %1 == 8
+ %rep 16/mmsize
+-%endif ; %2 == 8
++%endif ; %1 == 8
+
+-%if %2 == 8
++%if %1 == 8
+ %ifdef ARCH_X86_32
+ mova m2, [rsp+mmsize*(0+%%i)]
+ mova m1, [rsp+mmsize*(1+%%i)]
+@@ -142,31 +142,31 @@ cglobal yuv2planeX_%2_%1, %4, 7, %3
+ mova m2, m8
+ mova m1, m_dith
+ %endif ; x86-32/64
+-%else ; %2 == 9/10/16
+- mova m1, [yuv2yuvX_%2_start]
++%else ; %1 == 9/10/16
++ mova m1, [yuv2yuvX_%1_start]
+ mova m2, m1
+-%endif ; %2 == 8/9/10/16
++%endif ; %1 == 8/9/10/16
+ movsx cntr_reg, r1m
+ .filterloop_ %+ %%i:
+ ; input pixels
+ mov r6, [r2+gprsize*cntr_reg-2*gprsize]
+-%if %2 == 16
++%if %1 == 16
+ mova m3, [r6+r5*4]
+ mova m5, [r6+r5*4+mmsize]
+-%else ; %2 == 8/9/10
++%else ; %1 == 8/9/10
+ mova m3, [r6+r5*2]
+-%endif ; %2 == 8/9/10/16
++%endif ; %1 == 8/9/10/16
+ mov r6, [r2+gprsize*cntr_reg-gprsize]
+-%if %2 == 16
++%if %1 == 16
+ mova m4, [r6+r5*4]
+ mova m6, [r6+r5*4+mmsize]
+-%else ; %2 == 8/9/10
++%else ; %1 == 8/9/10
+ mova m4, [r6+r5*2]
+-%endif ; %2 == 8/9/10/16
++%endif ; %1 == 8/9/10/16
+
+ ; coefficients
+ movd m0, [r0+2*cntr_reg-4]; coeff[0], coeff[1]
+-%if %2 == 16
++%if %1 == 16
+ pshuflw m7, m0, 0 ; coeff[0]
+ pshuflw m0, m0, 0x55 ; coeff[1]
+ pmovsxwd m7, m7 ; word -> dword
+@@ -181,7 +181,7 @@ cglobal yuv2planeX_%2_%1, %4, 7, %3
+ paddd m1, m5
+ paddd m2, m4
+ paddd m1, m6
+-%else ; %2 == 10/9/8
++%else ; %1 == 10/9/8
+ punpcklwd m5, m3, m4
+ punpckhwd m3, m4
+ SPLATD m0, m0
+@@ -191,84 +191,83 @@ cglobal yuv2planeX_%2_%1, %4, 7, %3
+
+ paddd m2, m5
+ paddd m1, m3
+-%endif ; %2 == 8/9/10/16
++%endif ; %1 == 8/9/10/16
+
+ sub cntr_reg, 2
+ jg .filterloop_ %+ %%i
+
+-%if %2 == 16
+- psrad m2, 31 - %2
+- psrad m1, 31 - %2
+-%else ; %2 == 10/9/8
+- psrad m2, 27 - %2
+- psrad m1, 27 - %2
+-%endif ; %2 == 8/9/10/16
++%if %1 == 16
++ psrad m2, 31 - %1
++ psrad m1, 31 - %1
++%else ; %1 == 10/9/8
++ psrad m2, 27 - %1
++ psrad m1, 27 - %1
++%endif ; %1 == 8/9/10/16
+
+-%if %2 == 8
++%if %1 == 8
+ packssdw m2, m1
+ packuswb m2, m2
+ movh [r3+r5*1], m2
+-%else ; %2 == 9/10/16
+-%if %2 == 16
++%else ; %1 == 9/10/16
++%if %1 == 16
+ packssdw m2, m1
+ paddw m2, [minshort]
+-%else ; %2 == 9/10
+-%ifidn %1, sse4
+- packusdw m2, m1
+-%elifidn %1, avx
++%else ; %1 == 9/10
++%if cpuflag(sse4)
+ packusdw m2, m1
+ %else ; mmx2/sse2
+ packssdw m2, m1
+ pmaxsw m2, m6
+ %endif ; mmx2/sse2/sse4/avx
+- pminsw m2, [yuv2yuvX_%2_upper]
+-%endif ; %2 == 9/10/16
++ pminsw m2, [yuv2yuvX_%1_upper]
++%endif ; %1 == 9/10/16
+ mova [r3+r5*2], m2
+-%endif ; %2 == 8/9/10/16
++%endif ; %1 == 8/9/10/16
+
+ add r5, mmsize/2
+ sub r4d, mmsize/2
+-%if %2 == 8
++%if %1 == 8
+ %assign %%i %%i+2
+ %endrep
+-%endif ; %2 == 8
++%endif ; %1 == 8
+ jg .pixelloop
+
+-%if %2 == 8
++%if %1 == 8
+ %ifdef ARCH_X86_32
+ ADD rsp, pad
+ RET
+ %else ; x86-64
+ REP_RET
+ %endif ; x86-32/64
+-%else ; %2 == 9/10/16
++%else ; %1 == 9/10/16
+ REP_RET
+-%endif ; %2 == 8/9/10/16
++%endif ; %1 == 8/9/10/16
+ %endmacro
+
+ %define PALIGNR PALIGNR_MMX
+ %ifdef ARCH_X86_32
+-INIT_MMX
+-yuv2planeX_fn mmx2, 8, 0, 7
+-yuv2planeX_fn mmx2, 9, 0, 5
+-yuv2planeX_fn mmx2, 10, 0, 5
++INIT_MMX mmx2
++yuv2planeX_fn 8, 0, 7
++yuv2planeX_fn 9, 0, 5
++yuv2planeX_fn 10, 0, 5
+ %endif
+
+-INIT_XMM
+-yuv2planeX_fn sse2, 8, 10, 7
+-yuv2planeX_fn sse2, 9, 7, 5
+-yuv2planeX_fn sse2, 10, 7, 5
++INIT_XMM sse2
++yuv2planeX_fn 8, 10, 7
++yuv2planeX_fn 9, 7, 5
++yuv2planeX_fn 10, 7, 5
+
+ %define PALIGNR PALIGNR_SSSE3
+-yuv2planeX_fn sse4, 8, 10, 7
+-yuv2planeX_fn sse4, 9, 7, 5
+-yuv2planeX_fn sse4, 10, 7, 5
+-yuv2planeX_fn sse4, 16, 8, 5
+-
+-INIT_AVX
+-yuv2planeX_fn avx, 8, 10, 7
+-yuv2planeX_fn avx, 9, 7, 5
+-yuv2planeX_fn avx, 10, 7, 5
++INIT_XMM sse4
++yuv2planeX_fn 8, 10, 7
++yuv2planeX_fn 9, 7, 5
++yuv2planeX_fn 10, 7, 5
++yuv2planeX_fn 16, 8, 5
++
++INIT_XMM avx
++yuv2planeX_fn 8, 10, 7
++yuv2planeX_fn 9, 7, 5
++yuv2planeX_fn 10, 7, 5
+
+ ; %1=outout-bpc, %2=alignment (u/a)
+ %macro yuv2plane1_mainloop 2
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0046-configure-provide-libavfilter-version.h-header-to-ge.patch b/debian/patches/post-0.8b2/0046-configure-provide-libavfilter-version.h-header-to-ge.patch
new file mode 100644
index 0000000..aa083ff
--- /dev/null
+++ b/debian/patches/post-0.8b2/0046-configure-provide-libavfilter-version.h-header-to-ge.patch
@@ -0,0 +1,30 @@
+From b5c2b5af6a2f5baade1d0688703b3e46fa2f6cf2 Mon Sep 17 00:00:00 2001
+From: Stefano Sabatini <stefasab at gmail.com>
+Date: Fri, 13 Jan 2012 16:23:55 +0100
+Subject: [PATCH 46/63] configure: provide libavfilter/version.h header to
+ get_version()
+
+Fix libavfilter library version numbers generation, which was broken in
+3167dc9515810bbdd86d99d773bcf84657d2e72a.
+
+Signed-off-by: Anton Khirnov <anton at khirnov.net>
+---
+ configure | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/configure b/configure
+index 3146641..93b98a9 100755
+--- a/configure
++++ b/configure
+@@ -3361,7 +3361,7 @@ get_version(){
+
+ get_version LIBAVCODEC libavcodec/version.h
+ get_version LIBAVDEVICE libavdevice/avdevice.h
+-get_version LIBAVFILTER libavfilter/avfilter.h
++get_version LIBAVFILTER libavfilter/version.h
+ get_version LIBAVFORMAT libavformat/version.h
+ get_version LIBAVUTIL libavutil/avutil.h
+ get_version LIBPOSTPROC libpostproc/postprocess.h
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0047-cosmetics-Move-static-and-inline-attributes-to-more-.patch b/debian/patches/post-0.8b2/0047-cosmetics-Move-static-and-inline-attributes-to-more-.patch
new file mode 100644
index 0000000..ab3a144
--- /dev/null
+++ b/debian/patches/post-0.8b2/0047-cosmetics-Move-static-and-inline-attributes-to-more-.patch
@@ -0,0 +1,163 @@
+From e44c11e9fa505da3c54738ae2d21123338a28ca6 Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Fri, 13 Jan 2012 16:35:54 +0100
+Subject: [PATCH 47/63] cosmetics: Move static and inline attributes to more
+ standard places.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Fixes several "‘static’ is not at beginning of declaration" warnings.
+---
+ libavcodec/g722.c | 2 +-
+ libavcodec/h264_loopfilter.c | 51 +++++++++++++++++++++++++++++++++++------
+ libavfilter/vf_fade.c | 2 +-
+ libswscale/utils.c | 2 +-
+ 4 files changed, 46 insertions(+), 11 deletions(-)
+
+diff --git a/libavcodec/g722.c b/libavcodec/g722.c
+index 7b9ff72..a911bc7 100644
+--- a/libavcodec/g722.c
++++ b/libavcodec/g722.c
+@@ -129,7 +129,7 @@ static void do_adaptive_prediction(struct G722Band *band, const int cur_diff)
+ band->prev_qtzd_reconst = cur_qtzd_reconst;
+ }
+
+-static int inline linear_scale_factor(const int log_factor)
++static inline int linear_scale_factor(const int log_factor)
+ {
+ const int wd1 = inv_log2_table[(log_factor >> 6) & 31];
+ const int shift = log_factor >> 11;
+diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
+index 64b07e9..be750ca 100644
+--- a/libavcodec/h264_loopfilter.c
++++ b/libavcodec/h264_loopfilter.c
+@@ -101,7 +101,11 @@ static const uint8_t tc0_table[52*3][4] = {
+ };
+
+ /* intra: 0 if this loopfilter call is guaranteed to be inter (bS < 4), 1 if it might be intra (bS == 4) */
+-static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
++static av_always_inline void filter_mb_edgev(uint8_t *pix, int stride,
++ const int16_t bS[4],
++ unsigned int qp, int a, int b,
++ H264Context *h, int intra)
++{
+ const unsigned int index_a = qp + a;
+ const int alpha = alpha_table[index_a];
+ const int beta = beta_table[qp + b];
+@@ -118,7 +122,12 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const in
+ h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
+ }
+ }
+-static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
++
++static av_always_inline void filter_mb_edgecv(uint8_t *pix, int stride,
++ const int16_t bS[4],
++ unsigned int qp, int a, int b,
++ H264Context *h, int intra)
++{
+ const unsigned int index_a = qp + a;
+ const int alpha = alpha_table[index_a];
+ const int beta = beta_table[qp + b];
+@@ -136,7 +145,12 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const i
+ }
+ }
+
+-static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) {
++static av_always_inline void filter_mb_mbaff_edgev(H264Context *h, uint8_t *pix,
++ int stride,
++ const int16_t bS[7], int bsi,
++ int qp, int a, int b,
++ int intra)
++{
+ const unsigned int index_a = qp + a;
+ const int alpha = alpha_table[index_a];
+ const int beta = beta_table[qp + b];
+@@ -153,7 +167,13 @@ static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix
+ h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
+ }
+ }
+-static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) {
++
++static av_always_inline void filter_mb_mbaff_edgecv(H264Context *h,
++ uint8_t *pix, int stride,
++ const int16_t bS[7],
++ int bsi, int qp, int a,
++ int b, int intra)
++{
+ const unsigned int index_a = qp + a;
+ const int alpha = alpha_table[index_a];
+ const int beta = beta_table[qp + b];
+@@ -171,7 +191,11 @@ static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pi
+ }
+ }
+
+-static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
++static av_always_inline void filter_mb_edgeh(uint8_t *pix, int stride,
++ const int16_t bS[4],
++ unsigned int qp, int a, int b,
++ H264Context *h, int intra)
++{
+ const unsigned int index_a = qp + a;
+ const int alpha = alpha_table[index_a];
+ const int beta = beta_table[qp + b];
+@@ -189,7 +213,11 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const in
+ }
+ }
+
+-static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
++static av_always_inline void filter_mb_edgech(uint8_t *pix, int stride,
++ const int16_t bS[4],
++ unsigned int qp, int a, int b,
++ H264Context *h, int intra)
++{
+ const unsigned int index_a = qp + a;
+ const int alpha = alpha_table[index_a];
+ const int beta = beta_table[qp + b];
+@@ -207,8 +235,15 @@ static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const i
+ }
+ }
+
+-static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
+- unsigned int linesize, unsigned int uvlinesize, int pixel_shift) {
++static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
++ int mb_x, int mb_y,
++ uint8_t *img_y,
++ uint8_t *img_cb,
++ uint8_t *img_cr,
++ unsigned int linesize,
++ unsigned int uvlinesize,
++ int pixel_shift)
++{
+ MpegEncContext * const s = &h->s;
+ int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
+ int chroma444 = CHROMA444;
+diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
+index 0c8668c..9f748b8 100644
+--- a/libavfilter/vf_fade.c
++++ b/libavfilter/vf_fade.c
+@@ -69,7 +69,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+
+ static int query_formats(AVFilterContext *ctx)
+ {
+- const static enum PixelFormat pix_fmts[] = {
++ static const enum PixelFormat pix_fmts[] = {
+ PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
+ PIX_FMT_YUV411P, PIX_FMT_YUV410P,
+ PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
+diff --git a/libswscale/utils.c b/libswscale/utils.c
+index d252f2e..b49f924 100644
+--- a/libswscale/utils.c
++++ b/libswscale/utils.c
+@@ -69,7 +69,7 @@ typedef struct FormatEntry {
+ int is_supported_in, is_supported_out;
+ } FormatEntry;
+
+-const static FormatEntry format_entries[PIX_FMT_NB] = {
++static const FormatEntry format_entries[PIX_FMT_NB] = {
+ [PIX_FMT_YUV420P] = { 1 , 1 },
+ [PIX_FMT_YUYV422] = { 1 , 1 },
+ [PIX_FMT_RGB24] = { 1 , 1 },
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0048-sgidec-Use-bytestream2-functions-to-prevent-buffer-o.patch b/debian/patches/post-0.8b2/0048-sgidec-Use-bytestream2-functions-to-prevent-buffer-o.patch
new file mode 100644
index 0000000..2d994de
--- /dev/null
+++ b/debian/patches/post-0.8b2/0048-sgidec-Use-bytestream2-functions-to-prevent-buffer-o.patch
@@ -0,0 +1,283 @@
+From 4cd0bdae9a62d1f0366e60603222762af31e5289 Mon Sep 17 00:00:00 2001
+From: Aneesh Dogra <lionaneesh at gmail.com>
+Date: Fri, 13 Jan 2012 23:05:57 +0530
+Subject: [PATCH 48/63] sgidec: Use bytestream2 functions to prevent buffer
+ overreads.
+
+The patch also adds several bytestream macros to deal with native endian.
+
+Signed-off-by: Justin Ruggles <justin.ruggles at gmail.com>
+---
+ libavcodec/bytestream.h | 36 ++++++++++++++++
+ libavcodec/sgidec.c | 103 +++++++++++++++++++++++------------------------
+ 2 files changed, 87 insertions(+), 52 deletions(-)
+
+diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h
+index 9ec74cf..503598a 100644
+--- a/libavcodec/bytestream.h
++++ b/libavcodec/bytestream.h
+@@ -75,6 +75,42 @@ DEF (byte, 1, AV_RB8 , AV_WB8 )
+ #undef DEF64
+ #undef DEF_T
+
++#if HAVE_BIGENDIAN
++# define bytestream2_get_ne16 bytestream2_get_be16
++# define bytestream2_get_ne24 bytestream2_get_be24
++# define bytestream2_get_ne32 bytestream2_get_be32
++# define bytestream2_get_ne64 bytestream2_get_be64
++# define bytestream2_get_ne16u bytestream2_get_be16u
++# define bytestream2_get_ne24u bytestream2_get_be24u
++# define bytestream2_get_ne32u bytestream2_get_be32u
++# define bytestream2_get_ne64u bytestream2_get_be64u
++# define bytestream2_put_ne16 bytestream2_put_be16
++# define bytestream2_put_ne24 bytestream2_put_be24
++# define bytestream2_put_ne32 bytestream2_put_be32
++# define bytestream2_put_ne64 bytestream2_put_be64
++# define bytestream2_peek_ne16 bytestream2_peek_be16
++# define bytestream2_peek_ne24 bytestream2_peek_be24
++# define bytestream2_peek_ne32 bytestream2_peek_be32
++# define bytestream2_peek_ne64 bytestream2_peek_be64
++#else
++# define bytestream2_get_ne16 bytestream2_get_le16
++# define bytestream2_get_ne24 bytestream2_get_le24
++# define bytestream2_get_ne32 bytestream2_get_le32
++# define bytestream2_get_ne64 bytestream2_get_le64
++# define bytestream2_get_ne16u bytestream2_get_le16u
++# define bytestream2_get_ne24u bytestream2_get_le24u
++# define bytestream2_get_ne32u bytestream2_get_le32u
++# define bytestream2_get_ne64u bytestream2_get_le64u
++# define bytestream2_put_ne16 bytestream2_put_le16
++# define bytestream2_put_ne24 bytestream2_put_le24
++# define bytestream2_put_ne32 bytestream2_put_le32
++# define bytestream2_put_ne64 bytestream2_put_le64
++# define bytestream2_peek_ne16 bytestream2_peek_le16
++# define bytestream2_peek_ne24 bytestream2_peek_le24
++# define bytestream2_peek_ne32 bytestream2_peek_le32
++# define bytestream2_peek_ne64 bytestream2_peek_le64
++#endif
++
+ static av_always_inline void bytestream2_init(GetByteContext *g,
+ const uint8_t *buf, int buf_size)
+ {
+diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
+index e5b3c59..dfa00ed 100644
+--- a/libavcodec/sgidec.c
++++ b/libavcodec/sgidec.c
+@@ -31,26 +31,27 @@ typedef struct SgiState {
+ unsigned int depth;
+ unsigned int bytes_per_channel;
+ int linesize;
++ GetByteContext g;
+ } SgiState;
+
+ /**
+ * Expand an RLE row into a channel.
+- * @param in_buf input buffer
+- * @param in_end end of input buffer
++ * @param s the current image state
+ * @param out_buf Points to one line after the output buffer.
+ * @param out_end end of line in output buffer
+ * @param pixelstride pixel stride of input buffer
+ * @return size of output in bytes, -1 if buffer overflows
+ */
+-static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,
+- unsigned char *out_buf, uint8_t* out_end, int pixelstride)
++static int expand_rle_row(SgiState *s, uint8_t *out_buf,
++ uint8_t *out_end, int pixelstride)
+ {
+ unsigned char pixel, count;
+ unsigned char *orig = out_buf;
+
+ while (1) {
+- if(in_buf + 1 > in_end) return -1;
+- pixel = bytestream_get_byte(&in_buf);
++ if (bytestream2_get_bytes_left(&s->g) < 1)
++ return AVERROR_INVALIDDATA;
++ pixel = bytestream2_get_byteu(&s->g);
+ if (!(count = (pixel & 0x7f))) {
+ return (out_buf - orig) / pixelstride;
+ }
+@@ -60,11 +61,11 @@ static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,
+
+ if (pixel & 0x80) {
+ while (count--) {
+- *out_buf = bytestream_get_byte(&in_buf);
++ *out_buf = bytestream2_get_byte(&s->g);
+ out_buf += pixelstride;
+ }
+ } else {
+- pixel = bytestream_get_byte(&in_buf);
++ pixel = bytestream2_get_byte(&s->g);
+
+ while (count--) {
+ *out_buf = pixel;
+@@ -77,37 +78,32 @@ static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,
+ /**
+ * Read a run length encoded SGI image.
+ * @param out_buf output buffer
+- * @param in_buf input buffer
+- * @param in_end end of input buffer
+ * @param s the current image state
+ * @return 0 if no error, else return error number.
+ */
+-static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf,
+- const uint8_t *in_end, SgiState* s)
++static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
+ {
+ uint8_t *dest_row;
+ unsigned int len = s->height * s->depth * 4;
+- const uint8_t *start_table = in_buf;
++ GetByteContext g_table = s->g;
+ unsigned int y, z;
+ unsigned int start_offset;
+
+ /* size of RLE offset and length tables */
+- if(len * 2 > in_end - in_buf) {
++ if (len * 2 > bytestream2_get_bytes_left(&s->g)) {
+ return AVERROR_INVALIDDATA;
+ }
+
+- in_buf -= SGI_HEADER_SIZE;
+ for (z = 0; z < s->depth; z++) {
+ dest_row = out_buf;
+ for (y = 0; y < s->height; y++) {
+ dest_row -= s->linesize;
+- start_offset = bytestream_get_be32(&start_table);
+- if(start_offset > in_end - in_buf) {
++ start_offset = bytestream2_get_be32(&g_table);
++ bytestream2_seek(&s->g, start_offset, SEEK_SET);
++ if (expand_rle_row(s, dest_row + z, dest_row + FFABS(s->linesize),
++ s->depth) != s->width) {
+ return AVERROR_INVALIDDATA;
+ }
+- if (expand_rle_row(in_buf + start_offset, in_end, dest_row + z,
+- dest_row + FFABS(s->linesize), s->depth) != s->width)
+- return AVERROR_INVALIDDATA;
+ }
+ }
+ return 0;
+@@ -117,32 +113,37 @@ static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf,
+ * Read an uncompressed SGI image.
+ * @param out_buf output buffer
+ * @param out_end end ofoutput buffer
+- * @param in_buf input buffer
+- * @param in_end end of input buffer
+ * @param s the current image state
+ * @return 0 if read success, otherwise return -1.
+ */
+ static int read_uncompressed_sgi(unsigned char* out_buf, uint8_t* out_end,
+- const uint8_t *in_buf, const uint8_t *in_end, SgiState* s)
++ SgiState *s)
+ {
+ int x, y, z;
+- const uint8_t *ptr;
+ unsigned int offset = s->height * s->width * s->bytes_per_channel;
++ GetByteContext gp[4];
+
+ /* Test buffer size. */
+- if (offset * s->depth > in_end - in_buf) {
+- return -1;
++ if (offset * s->depth > bytestream2_get_bytes_left(&s->g))
++ return AVERROR_INVALIDDATA;
++
++ /* Create a reader for each plane */
++ for (z = 0; z < s->depth; z++) {
++ gp[z] = s->g;
++ bytestream2_skip(&gp[z], z * offset);
+ }
+
+ for (y = s->height - 1; y >= 0; y--) {
+ out_end = out_buf + (y * s->linesize);
+- for (x = s->width; x > 0; x--) {
+- ptr = in_buf += s->bytes_per_channel;
+- for(z = 0; z < s->depth; z ++) {
+- memcpy(out_end, ptr, s->bytes_per_channel);
+- out_end += s->bytes_per_channel;
+- ptr += offset;
+- }
++ if (s->bytes_per_channel == 1) {
++ for (x = s->width; x > 0; x--)
++ for (z = 0; z < s->depth; z++)
++ *out_end++ = bytestream2_get_byteu(&gp[z]);
++ } else {
++ uint16_t *out16 = (uint16_t *)out_end;
++ for (x = s->width; x > 0; x--)
++ for (z = 0; z < s->depth; z++)
++ *out16++ = bytestream2_get_ne16u(&gp[z]);
+ }
+ }
+ return 0;
+@@ -152,33 +153,31 @@ static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+ {
+- const uint8_t *in_buf = avpkt->data;
+- int buf_size = avpkt->size;
+ SgiState *s = avctx->priv_data;
+ AVFrame *picture = data;
+ AVFrame *p = &s->picture;
+- const uint8_t *in_end = in_buf + buf_size;
+ unsigned int dimension, rle;
+ int ret = 0;
+ uint8_t *out_buf, *out_end;
+
+- if (buf_size < SGI_HEADER_SIZE){
+- av_log(avctx, AV_LOG_ERROR, "buf_size too small (%d)\n", buf_size);
+- return -1;
++ bytestream2_init(&s->g, avpkt->data, avpkt->size);
++ if (bytestream2_get_bytes_left(&s->g) < SGI_HEADER_SIZE) {
++ av_log(avctx, AV_LOG_ERROR, "buf_size too small (%d)\n", avpkt->size);
++ return AVERROR_INVALIDDATA;
+ }
+
+ /* Test for SGI magic. */
+- if (bytestream_get_be16(&in_buf) != SGI_MAGIC) {
++ if (bytestream2_get_be16(&s->g) != SGI_MAGIC) {
+ av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+
+- rle = bytestream_get_byte(&in_buf);
+- s->bytes_per_channel = bytestream_get_byte(&in_buf);
+- dimension = bytestream_get_be16(&in_buf);
+- s->width = bytestream_get_be16(&in_buf);
+- s->height = bytestream_get_be16(&in_buf);
+- s->depth = bytestream_get_be16(&in_buf);
++ rle = bytestream2_get_byte(&s->g);
++ s->bytes_per_channel = bytestream2_get_byte(&s->g);
++ dimension = bytestream2_get_be16(&s->g);
++ s->width = bytestream2_get_be16(&s->g);
++ s->height = bytestream2_get_be16(&s->g);
++ s->depth = bytestream2_get_be16(&s->g);
+
+ if (s->bytes_per_channel != 1 && (s->bytes_per_channel != 2 || rle)) {
+ av_log(avctx, AV_LOG_ERROR, "wrong channel number\n");
+@@ -224,19 +223,19 @@ static int decode_frame(AVCodecContext *avctx,
+ s->linesize = p->linesize[0];
+
+ /* Skip header. */
+- in_buf += SGI_HEADER_SIZE - 12;
++ bytestream2_seek(&s->g, SGI_HEADER_SIZE, SEEK_SET);
+ if (rle) {
+- ret = read_rle_sgi(out_end, in_buf, in_end, s);
++ ret = read_rle_sgi(out_end, s);
+ } else {
+- ret = read_uncompressed_sgi(out_buf, out_end, in_buf, in_end, s);
++ ret = read_uncompressed_sgi(out_buf, out_end, s);
+ }
+
+ if (ret == 0) {
+ *picture = s->picture;
+ *data_size = sizeof(AVPicture);
+- return buf_size;
++ return avpkt->size;
+ } else {
+- return -1;
++ return ret;
+ }
+ }
+
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0049-vb-Use-bytestream2-functions.patch b/debian/patches/post-0.8b2/0049-vb-Use-bytestream2-functions.patch
new file mode 100644
index 0000000..2e94bba
--- /dev/null
+++ b/debian/patches/post-0.8b2/0049-vb-Use-bytestream2-functions.patch
@@ -0,0 +1,206 @@
+From 4fccc7c46c52e6ba6801ef90b9ac386330876655 Mon Sep 17 00:00:00 2001
+From: Laurentiu Ion <ionlaurentiucristian at gmail.com>
+Date: Sat, 14 Jan 2012 21:04:59 +0200
+Subject: [PATCH 49/63] vb: Use bytestream2 functions
+
+Signed-off-by: Justin Ruggles <justin.ruggles at gmail.com>
+---
+ libavcodec/vb.c | 75 +++++++++++++++++++-----------------------------------
+ 1 files changed, 27 insertions(+), 48 deletions(-)
+
+diff --git a/libavcodec/vb.c b/libavcodec/vb.c
+index 96387b6..a1052ef 100644
+--- a/libavcodec/vb.c
++++ b/libavcodec/vb.c
+@@ -44,7 +44,7 @@ typedef struct VBDecContext {
+
+ uint8_t *frame, *prev_frame;
+ uint32_t pal[AVPALETTE_COUNT];
+- const uint8_t *stream;
++ GetByteContext stream;
+ } VBDecContext;
+
+ static const uint16_t vb_patterns[64] = {
+@@ -62,8 +62,8 @@ static void vb_decode_palette(VBDecContext *c, int data_size)
+ {
+ int start, size, i;
+
+- start = bytestream_get_byte(&c->stream);
+- size = (bytestream_get_byte(&c->stream) - 1) & 0xFF;
++ start = bytestream2_get_byte(&c->stream);
++ size = (bytestream2_get_byte(&c->stream) - 1) & 0xFF;
+ if(start + size > 255){
+ av_log(c->avctx, AV_LOG_ERROR, "Palette change runs beyond entry 256\n");
+ return;
+@@ -73,7 +73,7 @@ static void vb_decode_palette(VBDecContext *c, int data_size)
+ return;
+ }
+ for(i = start; i <= start + size; i++)
+- c->pal[i] = bytestream_get_be24(&c->stream);
++ c->pal[i] = bytestream2_get_be24(&c->stream);
+ }
+
+ static inline int check_pixel(uint8_t *buf, uint8_t *start, uint8_t *end)
+@@ -86,10 +86,10 @@ static inline int check_line(uint8_t *buf, uint8_t *start, uint8_t *end)
+ return buf >= start && (buf + 4) <= end;
+ }
+
+-static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_size, int offset)
++static int vb_decode_framedata(VBDecContext *c, int offset)
+ {
++ GetByteContext g;
+ uint8_t *prev, *cur;
+- const uint8_t* data_end = buf + data_size;
+ int blk, blocks, t, blk2;
+ int blocktypes = 0;
+ int x, y, a, b;
+@@ -98,6 +98,8 @@ static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_siz
+ uint8_t *pstart = c->prev_frame;
+ uint8_t *pend = c->prev_frame + width*c->avctx->height;
+
++ g = c->stream;
++
+ prev = c->prev_frame + offset;
+ cur = c->frame;
+
+@@ -105,11 +107,7 @@ static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_siz
+ blk2 = 0;
+ for(blk = 0; blk < blocks; blk++){
+ if(!(blk & 3)) {
+- if(buf >= data_end){
+- av_log(c->avctx, AV_LOG_ERROR, "Data pointer out of bounds\n");
+- return -1;
+- }
+- blocktypes = bytestream_get_byte(&buf);
++ blocktypes = bytestream2_get_byte(&g);
+ }
+ switch(blocktypes & 0xC0){
+ case 0x00: //skip
+@@ -120,15 +118,14 @@ static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_siz
+ memset(cur + y*width, 0, 4);
+ break;
+ case 0x40:
+- t = bytestream_get_byte(&buf);
++ t = bytestream2_get_byte(&g);
+ if(!t){ //raw block
+- if(buf + 16 > data_end){
++ if (bytestream2_get_bytes_left(&g) < 16) {
+ av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n");
+ return -1;
+ }
+ for(y = 0; y < 4; y++)
+- memcpy(cur + y*width, buf + y*4, 4);
+- buf += 16;
++ bytestream2_get_buffer(&g, cur + y * width, 4);
+ }else{ // motion compensation
+ x = ((t & 0xF)^8) - 8;
+ y = ((t >> 4) ^8) - 8;
+@@ -141,22 +138,18 @@ static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_siz
+ }
+ break;
+ case 0x80: // fill
+- t = bytestream_get_byte(&buf);
++ t = bytestream2_get_byte(&g);
+ for(y = 0; y < 4; y++)
+ memset(cur + y*width, t, 4);
+ break;
+ case 0xC0: // pattern fill
+- if(buf + 2 > data_end){
+- av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n");
+- return -1;
+- }
+- t = bytestream_get_byte(&buf);
++ t = bytestream2_get_byte(&g);
+ pattype = t >> 6;
+ pattern = vb_patterns[t & 0x3F];
+ switch(pattype){
+ case 0:
+- a = bytestream_get_byte(&buf);
+- b = bytestream_get_byte(&buf);
++ a = bytestream2_get_byte(&g);
++ b = bytestream2_get_byte(&g);
+ for(y = 0; y < 4; y++)
+ for(x = 0; x < 4; x++, pattern >>= 1)
+ cur[x + y*width] = (pattern & 1) ? b : a;
+@@ -164,7 +157,7 @@ static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_siz
+ case 1:
+ pattern = ~pattern;
+ case 2:
+- a = bytestream_get_byte(&buf);
++ a = bytestream2_get_byte(&g);
+ for(y = 0; y < 4; y++)
+ for(x = 0; x < 4; x++, pattern >>= 1)
+ if(pattern & 1 && check_pixel(prev + x + y*width, pstart, pend))
+@@ -193,16 +186,15 @@ static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_siz
+
+ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
+ {
+- const uint8_t *buf = avpkt->data;
+- int buf_size = avpkt->size;
+ VBDecContext * const c = avctx->priv_data;
+ uint8_t *outptr, *srcptr;
+ int i, j;
+ int flags;
+ uint32_t size;
+- int rest = buf_size;
+ int offset = 0;
+
++ bytestream2_init(&c->stream, avpkt->data, avpkt->size);
++
+ if(c->pic.data[0])
+ avctx->release_buffer(avctx, &c->pic);
+ c->pic.reference = 1;
+@@ -211,34 +203,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
+ return -1;
+ }
+
+- c->stream = buf;
+- flags = bytestream_get_le16(&c->stream);
+- rest -= 2;
++ flags = bytestream2_get_le16(&c->stream);
+
+ if(flags & VB_HAS_GMC){
+- i = (int16_t)bytestream_get_le16(&c->stream);
+- j = (int16_t)bytestream_get_le16(&c->stream);
++ i = (int16_t)bytestream2_get_le16(&c->stream);
++ j = (int16_t)bytestream2_get_le16(&c->stream);
+ offset = i + j * avctx->width;
+- rest -= 4;
+ }
+ if(flags & VB_HAS_VIDEO){
+- size = bytestream_get_le32(&c->stream);
+- if(size > rest){
+- av_log(avctx, AV_LOG_ERROR, "Frame size is too big\n");
+- return -1;
+- }
+- vb_decode_framedata(c, c->stream, size, offset);
+- c->stream += size - 4;
+- rest -= size;
++ size = bytestream2_get_le32(&c->stream);
++ vb_decode_framedata(c, offset);
++ bytestream2_skip(&c->stream, size - 4);
+ }
+ if(flags & VB_HAS_PALETTE){
+- size = bytestream_get_le32(&c->stream);
+- if(size > rest){
+- av_log(avctx, AV_LOG_ERROR, "Palette size is too big\n");
+- return -1;
+- }
++ size = bytestream2_get_le32(&c->stream);
+ vb_decode_palette(c, size);
+- rest -= size;
+ }
+
+ memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE);
+@@ -259,7 +238,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
+ *(AVFrame*)data = c->pic;
+
+ /* always report that the buffer was completely consumed */
+- return buf_size;
++ return avpkt->size;
+ }
+
+ static av_cold int decode_init(AVCodecContext *avctx)
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0050-wavpack-fix-clipping-for-32-bit-lossy-mode.patch b/debian/patches/post-0.8b2/0050-wavpack-fix-clipping-for-32-bit-lossy-mode.patch
new file mode 100644
index 0000000..b1fece1
--- /dev/null
+++ b/debian/patches/post-0.8b2/0050-wavpack-fix-clipping-for-32-bit-lossy-mode.patch
@@ -0,0 +1,90 @@
+From e6e7bfc11e93fe3499c576fa9466cb2e913b5965 Mon Sep 17 00:00:00 2001
+From: Kostya Shishkov <kostya.shishkov at gmail.com>
+Date: Sun, 15 Jan 2012 14:23:28 +0100
+Subject: [PATCH 50/63] wavpack: fix clipping for 32-bit lossy mode
+
+Reference decoder clips data before shifting it to final range and also
+forces 32-bit lossy mode to be actually 24-bit lossy mode in order to be
+able to perform proper clipping.
+---
+ libavcodec/wavpack.c | 27 +++++++++++++++++++--------
+ 1 files changed, 19 insertions(+), 8 deletions(-)
+
+diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
+index 6896877..1098873 100644
+--- a/libavcodec/wavpack.c
++++ b/libavcodec/wavpack.c
+@@ -112,7 +112,8 @@ typedef struct WavpackFrameContext {
+ int extra_bits;
+ int and, or, shift;
+ int post_shift;
+- int hybrid, hybrid_bitrate, hybrid_maxclip;
++ int hybrid, hybrid_bitrate;
++ int hybrid_maxclip, hybrid_minclip;
+ int float_flag;
+ int float_shift;
+ int float_max_exp;
+@@ -412,12 +413,12 @@ static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc,
+ }
+
+ bit = (S & s->and) | s->or;
+- bit = (((S + bit) << s->shift) - bit) << s->post_shift;
++ bit = ((S + bit) << s->shift) - bit;
+
+ if (s->hybrid)
+- bit = av_clip(bit, -s->hybrid_maxclip - 1, s->hybrid_maxclip);
++ bit = av_clip(bit, s->hybrid_minclip, s->hybrid_maxclip);
+
+- return bit;
++ return bit << s->post_shift;
+ }
+
+ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S)
+@@ -763,7 +764,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
+ const uint8_t *orig_buf = buf;
+ const uint8_t *buf_end = buf + buf_size;
+ int i, j, id, size, ssize, weights, t;
+- int bpp, chan, chmask;
++ int bpp, chan, chmask, orig_bpp;
+
+ if (buf_size == 0) {
+ *got_frame_ptr = 0;
+@@ -799,15 +800,16 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
+ s->frame_flags = AV_RL32(buf); buf += 4;
+ bpp = av_get_bytes_per_sample(avctx->sample_fmt);
+ samples = (uint8_t*)samples + bpp * wc->ch_offset;
++ orig_bpp = ((s->frame_flags & 0x03) + 1) << 3;
+
+ s->stereo = !(s->frame_flags & WV_MONO);
+ s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
+ s->joint = s->frame_flags & WV_JOINT_STEREO;
+ s->hybrid = s->frame_flags & WV_HYBRID_MODE;
+ s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE;
+- s->hybrid_maxclip = (1LL << ((((s->frame_flags & 0x03) + 1) << 3) - 1)) - 1;
+- s->post_shift = 8 * (bpp - 1 - (s->frame_flags & 0x03)) +
+- ((s->frame_flags >> 13) & 0x1f);
++ s->post_shift = bpp * 8 - orig_bpp + ((s->frame_flags >> 13) & 0x1f);
++ s->hybrid_maxclip = (( 1LL << (orig_bpp - 1)) - 1) >> s->post_shift;
++ s->hybrid_minclip = ((-1LL << (orig_bpp - 1))) >> s->post_shift;
+ s->CRC = AV_RL32(buf); buf += 4;
+ if (wc->mkv_mode)
+ buf += 4; //skip block size;
+@@ -968,6 +970,15 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
+ s->and = 1;
+ s->shift = buf[3];
+ }
++ /* original WavPack decoder forces 32-bit lossy sound to be treated
++ * as 24-bit one in order to have proper clipping
++ */
++ if (s->hybrid && bpp == 4 && s->post_shift < 8 && s->shift > 8) {
++ s->post_shift += 8;
++ s->shift -= 8;
++ s->hybrid_maxclip >>= 8;
++ s->hybrid_minclip >>= 8;
++ }
+ buf += 4;
+ break;
+ case WP_ID_FLOATINFO:
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0051-lavc-Relax-API-strictness-in-avcodec_decode_audio3-w.patch b/debian/patches/post-0.8b2/0051-lavc-Relax-API-strictness-in-avcodec_decode_audio3-w.patch
new file mode 100644
index 0000000..b8a3f23
--- /dev/null
+++ b/debian/patches/post-0.8b2/0051-lavc-Relax-API-strictness-in-avcodec_decode_audio3-w.patch
@@ -0,0 +1,59 @@
+From e2ff436ef64589de8486517352e17f513886e15b Mon Sep 17 00:00:00 2001
+From: Reinhard Tartler <siretart at tauware.de>
+Date: Sun, 15 Jan 2012 20:32:11 +0100
+Subject: [PATCH 51/63] lavc: Relax API strictness in avcodec_decode_audio3
+ with a custom get_buffer()
+
+Do not fail audio decoding with avcodec_decode_audio3 if user has set a
+custom get_buffer. Strictly speaking, this was never allowed by the API,
+but it seems that some software packages did so anyways. In order to
+unbreak applications (cf. http://bugs.debian.org/655890), this change
+clarifies the API and overrides the custom get_buffer() with the defaults.
+
+This change is inspired by a similar
+commit (c3846e3ebab610be691adb8b40d376dc2f675dc4) in FFmpeg.
+
+Signed-off-by: Reinhard Tartler <siretart at tauware.de>
+---
+ libavcodec/avcodec.h | 5 +++++
+ libavcodec/utils.c | 8 +++++---
+ 2 files changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
+index c195ad5..49d2a0f 100644
+--- a/libavcodec/avcodec.h
++++ b/libavcodec/avcodec.h
+@@ -4070,6 +4070,11 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
+ * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
+ * no overreading happens for damaged MPEG streams.
+ *
++ * @warning You must not provide a custom get_buffer() when using
++ * avcodec_decode_audio3(). Doing so will override it with
++ * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
++ * which does allow the application to provide a custom get_buffer().
++ *
+ * @note You might have to align the input buffer avpkt->data and output buffer
+ * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
+ * necessary at all, on others it won't work at all if not aligned and on others
+diff --git a/libavcodec/utils.c b/libavcodec/utils.c
+index 6f4d7e6..8473aac 100644
+--- a/libavcodec/utils.c
++++ b/libavcodec/utils.c
+@@ -933,9 +933,11 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
+ int ret, got_frame = 0;
+
+ if (avctx->get_buffer != avcodec_default_get_buffer) {
+- av_log(avctx, AV_LOG_ERROR, "A custom get_buffer() cannot be used with "
+- "avcodec_decode_audio3()\n");
+- return AVERROR(EINVAL);
++ av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with"
++ "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
++ av_log(avctx, AV_LOG_ERROR, "Please port your application to "
++ "avcodec_decode_audio4()\n");
++ avctx->get_buffer = avcodec_default_get_buffer;
+ }
+
+ ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt);
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0052-mov-mxfdec-Employ-more-meaningful-return-values.patch b/debian/patches/post-0.8b2/0052-mov-mxfdec-Employ-more-meaningful-return-values.patch
new file mode 100644
index 0000000..aa14c3e
--- /dev/null
+++ b/debian/patches/post-0.8b2/0052-mov-mxfdec-Employ-more-meaningful-return-values.patch
@@ -0,0 +1,673 @@
+From bcd5d979aa377a16d7fa6b9993e269003281af5c Mon Sep 17 00:00:00 2001
+From: Daniel Huang <dtvrij74 at gmail.com>
+Date: Sat, 14 Jan 2012 15:25:12 -0600
+Subject: [PATCH 52/63] mov, mxfdec: Employ more meaningful return values.
+
+Signed-off-by: Diego Biurrun <diego at biurrun.de>
+---
+ libavformat/mov.c | 93 ++++++++++++++++++++++++++-----------------------
+ libavformat/mxfdec.c | 88 ++++++++++++++++++++++++----------------------
+ 2 files changed, 95 insertions(+), 86 deletions(-)
+
+diff --git a/libavformat/mov.c b/libavformat/mov.c
+index 63089b9..f12a8b4 100644
+--- a/libavformat/mov.c
++++ b/libavformat/mov.c
+@@ -239,7 +239,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ if (!key)
+ return 0;
+ if (atom.size < 0)
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
+
+@@ -380,7 +380,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ avio_rb32(pb); // version + flags
+ entries = avio_rb32(pb);
+ if (entries >= UINT_MAX / sizeof(*sc->drefs))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
+ if (!sc->drefs)
+ return AVERROR(ENOMEM);
+@@ -392,7 +392,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ int64_t next = avio_tell(pb) + size - 4;
+
+ if (size < 12)
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ dref->type = avio_rl32(pb);
+ avio_rb32(pb); // version + flags
+@@ -673,7 +673,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+
+ comp_brand_size = atom.size - 8;
+ if (comp_brand_size < 0)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
+ if (!comp_brands_str)
+ return AVERROR(ENOMEM);
+@@ -688,8 +688,10 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ /* this atom should contain all header atoms */
+ static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ {
+- if (mov_read_default(c, pb, atom) < 0)
+- return -1;
++ int ret;
++
++ if ((ret = mov_read_default(c, pb, atom)) < 0)
++ return ret;
+ /* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */
+ /* so we don't parse the whole file if over a network */
+ c->found_moov=1;
+@@ -731,9 +733,10 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ sc = st->priv_data;
+
+ version = avio_r8(pb);
+- if (version > 1)
+- return -1; /* unsupported */
+-
++ if (version > 1) {
++ av_log_ask_for_sample(c, "unsupported version %d\n", version);
++ return AVERROR_PATCHWELCOME;
++ }
+ avio_rb24(pb); /* flags */
+ if (version == 1) {
+ creation_time = avio_rb64(pb);
+@@ -802,7 +805,7 @@ static int mov_read_smi(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ st = c->fc->streams[c->fc->nb_streams-1];
+
+ if ((uint64_t)atom.size > (1<<30))
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ // currently SVQ3 decoder expect full STSD header - so let's fake it
+ // this should be fixed and just SMI header should be passed
+@@ -895,10 +898,10 @@ static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ st= c->fc->streams[c->fc->nb_streams-1];
+ size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE;
+ if (size > INT_MAX || (uint64_t)atom.size > INT_MAX)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ buf= av_realloc(st->codec->extradata, size);
+ if (!buf)
+- return -1;
++ return AVERROR(ENOMEM);
+ st->codec->extradata= buf;
+ buf+= st->codec->extradata_size;
+ st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;
+@@ -917,7 +920,7 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ st = c->fc->streams[c->fc->nb_streams-1];
+
+ if ((uint64_t)atom.size > (1<<30))
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ if (st->codec->codec_id == CODEC_ID_QDM2 || st->codec->codec_id == CODEC_ID_QDMC) {
+ // pass all frma atom to codec, needed at least for QDMC and QDM2
+@@ -928,8 +931,9 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ st->codec->extradata_size = atom.size;
+ avio_read(pb, st->codec->extradata, atom.size);
+ } else if (atom.size > 8) { /* to read frma, esds atoms */
+- if (mov_read_default(c, pb, atom) < 0)
+- return -1;
++ int ret;
++ if ((ret = mov_read_default(c, pb, atom)) < 0)
++ return ret;
+ } else
+ avio_skip(pb, atom.size);
+ return 0;
+@@ -948,7 +952,7 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ st = c->fc->streams[c->fc->nb_streams-1];
+
+ if ((uint64_t)atom.size > (1<<30))
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ if (atom.size >= 10) {
+ // Broken files created by legacy versions of Libav and FFmpeg will
+@@ -984,7 +988,7 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ st = c->fc->streams[c->fc->nb_streams-1];
+
+ if ((uint64_t)atom.size > (1<<30))
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ av_free(st->codec->extradata);
+ st->codec->extradata = av_mallocz(atom.size - 40 + FF_INPUT_BUFFER_PADDING_SIZE);
+@@ -1015,7 +1019,7 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ if (!entries)
+ return 0;
+ if (entries >= UINT_MAX/sizeof(int64_t))
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
+ if (!sc->chunk_offsets)
+@@ -1029,7 +1033,7 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ for (i=0; i<entries; i++)
+ sc->chunk_offsets[i] = avio_rb64(pb);
+ else
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ return 0;
+ }
+@@ -1338,8 +1342,9 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
+ /* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */
+ a.size = size - (avio_tell(pb) - start_pos);
+ if (a.size > 8) {
+- if (mov_read_default(c, pb, a) < 0)
+- return -1;
++ int ret;
++ if ((ret = mov_read_default(c, pb, a)) < 0)
++ return ret;
+ } else if (a.size > 0)
+ avio_skip(pb, a.size);
+ }
+@@ -1355,7 +1360,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
+ c->dv_demux = avpriv_dv_init_demux(c->dv_fctx);
+ if (!c->dv_demux) {
+ av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n");
+- return -1;
++ return AVERROR(ENOMEM);
+ }
+ sc->dv_audio_container = 1;
+ st->codec->codec_id = CODEC_ID_PCM_S16LE;
+@@ -1438,7 +1443,7 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ if (!entries)
+ return 0;
+ if (entries >= UINT_MAX / sizeof(*sc->stsc_data))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));
+ if (!sc->stsc_data)
+ return AVERROR(ENOMEM);
+@@ -1467,7 +1472,7 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+
+ entries = avio_rb32(pb);
+ if (entries >= UINT_MAX / sizeof(*sc->stps_data))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
+ if (!sc->stps_data)
+ return AVERROR(ENOMEM);
+@@ -1500,7 +1505,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ av_dlog(c->fc, "keyframe_count = %d\n", entries);
+
+ if (entries >= UINT_MAX / sizeof(int))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->keyframes = av_malloc(entries * sizeof(int));
+ if (!sc->keyframes)
+ return AVERROR(ENOMEM);
+@@ -1549,13 +1554,13 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+
+ if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
+ av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+
+ if (!entries)
+ return 0;
+ if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / field_size)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->sample_sizes = av_malloc(entries * sizeof(int));
+ if (!sc->sample_sizes)
+ return AVERROR(ENOMEM);
+@@ -1571,7 +1576,7 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ if (avio_read(pb, buf, num_bytes) < num_bytes) {
+ av_freep(&sc->sample_sizes);
+ av_free(buf);
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+
+ init_get_bits(&gb, buf, 8*num_bytes);
+@@ -1656,7 +1661,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ if (!entries)
+ return 0;
+ if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data));
+ if (!sc->ctts_data)
+ return AVERROR(ENOMEM);
+@@ -2120,7 +2125,7 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+
+ track_id = avio_rb32(pb);
+ if (!track_id)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ frag->track_id = track_id;
+ for (i = 0; i < c->trex_count; i++)
+ if (c->trex_data[i].track_id == frag->track_id) {
+@@ -2129,7 +2134,7 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ }
+ if (!trex) {
+ av_log(c->fc, AV_LOG_ERROR, "could not find corresponding trex\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+
+ if (flags & 0x01) frag->base_data_offset = avio_rb64(pb);
+@@ -2155,7 +2160,7 @@ static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ MOVTrackExt *trex;
+
+ if ((uint64_t)c->trex_count+1 >= UINT_MAX / sizeof(*c->trex_data))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ trex = av_realloc(c->trex_data, (c->trex_count+1)*sizeof(*c->trex_data));
+ if (!trex)
+ return AVERROR(ENOMEM);
+@@ -2191,7 +2196,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ }
+ if (!st) {
+ av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id);
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ sc = st->priv_data;
+ if (sc->pseudo_stream_id+1 != frag->stsd_id)
+@@ -2218,7 +2223,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ sc->ctts_count++;
+ }
+ if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ ctts_data = av_realloc(sc->ctts_data,
+ (entries+sc->ctts_count)*sizeof(*sc->ctts_data));
+ if (!ctts_data)
+@@ -2294,14 +2299,14 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+
+ avio_rb32(pb); /* dcom atom */
+ if (avio_rl32(pb) != MKTAG('d','c','o','m'))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ if (avio_rl32(pb) != MKTAG('z','l','i','b')) {
+ av_log(c->fc, AV_LOG_ERROR, "unknown compression for cmov atom !");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ avio_rb32(pb); /* cmvd atom */
+ if (avio_rl32(pb) != MKTAG('c','m','v','d'))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ moov_len = avio_rb32(pb); /* uncompressed size */
+ cmov_len = atom.size - 6 * 4;
+
+@@ -2327,7 +2332,7 @@ free_and_return:
+ return ret;
+ #else
+ av_log(c->fc, AV_LOG_ERROR, "this file requires zlib support compiled in\n");
+- return -1;
++ return AVERROR(ENOSYS);
+ #endif
+ }
+
+@@ -2346,7 +2351,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+ edit_count = avio_rb32(pb); /* entries */
+
+ if ((uint64_t)edit_count*12+8 > atom.size)
+- return -1;
++ return AVERROR_INVALIDDATA;
+
+ for (i=0; i<edit_count; i++){
+ int64_t time;
+@@ -2565,7 +2570,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
+ }
+ if (!mov->found_moov) {
+ av_log(s, AV_LOG_ERROR, "moov atom not found\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ av_dlog(mov->fc, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb));
+
+@@ -2627,7 +2632,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
+ if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
+ av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
+ sc->ffindex, sample->pos);
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ ret = av_get_packet(sc->pb, pkt, sample->size);
+ if (ret < 0)
+@@ -2694,7 +2699,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp,
+ if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
+ sample = 0;
+ if (sample < 0) /* not sure what to do */
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sc->current_sample = sample;
+ av_dlog(s, "stream %d, found sample %d\n", st->index, sc->current_sample);
+ /* adjust ctts index */
+@@ -2721,14 +2726,14 @@ static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
+ int i;
+
+ if (stream_index >= s->nb_streams)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ if (sample_time < 0)
+ sample_time = 0;
+
+ st = s->streams[stream_index];
+ sample = mov_seek_stream(s, st, sample_time, flags);
+ if (sample < 0)
+- return -1;
++ return sample;
+
+ /* adjust seek timestamp to found sample timestamp */
+ seek_timestamp = st->index_entries[sample].timestamp;
+diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
+index c4c3f59..cb2ae86 100644
+--- a/libavformat/mxfdec.c
++++ b/libavformat/mxfdec.c
+@@ -170,7 +170,7 @@ static int64_t klv_decode_ber_length(AVIOContext *pb)
+ int bytes_num = size & 0x7f;
+ /* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
+ if (bytes_num > 8)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ size = 0;
+ while (bytes_num--)
+ size = size << 8 | avio_r8(pb);
+@@ -194,7 +194,7 @@ static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
+ static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
+ {
+ if (!mxf_read_sync(pb, mxf_klv_key, 4))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ klv->offset = avio_tell(pb) - 4;
+ memcpy(klv->key, mxf_klv_key, 4);
+ avio_read(pb, klv->key + 4, 12);
+@@ -224,7 +224,7 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt,
+ int i;
+
+ if (length > 61444) /* worst case PAL 1920 samples 8 channels */
+- return -1;
++ return AVERROR_INVALIDDATA;
+ length = av_get_packet(pb, pkt, length);
+ if (length < 0)
+ return length;
+@@ -261,7 +261,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
+ if (!mxf->aesc && s->key && s->keylen == 16) {
+ mxf->aesc = av_malloc(av_aes_size);
+ if (!mxf->aesc)
+- return -1;
++ return AVERROR(ENOMEM);
+ av_aes_init(mxf->aesc, s->key, 128, 1);
+ }
+ // crypto context
+@@ -273,19 +273,19 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
+ klv_decode_ber_length(pb);
+ avio_read(pb, klv->key, 16);
+ if (!IS_KLV_KEY(klv, mxf_essence_element_key))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ index = mxf_get_stream_index(s, klv);
+ if (index < 0)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ // source size
+ klv_decode_ber_length(pb);
+ orig_size = avio_rb64(pb);
+ if (orig_size < plaintext_size)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ // enc. code
+ size = klv_decode_ber_length(pb);
+ if (size < 32 || size - 32 < orig_size)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ avio_read(pb, ivec, 16);
+ avio_read(pb, tmpbuf, 16);
+ if (mxf->aesc)
+@@ -313,15 +313,16 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
+ KLVPacket klv;
+
+ while (!s->pb->eof_reached) {
++ int ret;
+ if (klv_read_packet(&klv, s->pb) < 0)
+ return -1;
+ PRINT_KEY(s, "read packet", klv.key);
+ av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
+ if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
+- int res = mxf_decrypt_triplet(s, pkt, &klv);
+- if (res < 0) {
++ ret = mxf_decrypt_triplet(s, pkt, &klv);
++ if (ret < 0) {
+ av_log(s, AV_LOG_ERROR, "invalid encoded triplet\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ return 0;
+ }
+@@ -337,10 +338,10 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
+ if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) {
+ if (mxf_get_d10_aes3_packet(s->pb, s->streams[index], pkt, klv.length) < 0) {
+ av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ } else {
+- int ret = av_get_packet(s->pb, pkt, klv.length);
++ ret = av_get_packet(s->pb, pkt, klv.length);
+ if (ret < 0)
+ return ret;
+ }
+@@ -361,15 +362,16 @@ static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, U
+ int item_len = avio_rb32(pb);
+
+ if (item_len != 18) {
+- av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n");
+- return -1;
++ av_log_ask_for_sample(pb, "unsupported primer pack item length %d\n",
++ item_len);
++ return AVERROR_PATCHWELCOME;
+ }
+ if (item_num > UINT_MAX / item_len)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ mxf->local_tags_count = item_num;
+ mxf->local_tags = av_malloc(item_num*item_len);
+ if (!mxf->local_tags)
+- return -1;
++ return AVERROR(ENOMEM);
+ avio_read(pb, mxf->local_tags, item_num*item_len);
+ return 0;
+ }
+@@ -380,7 +382,7 @@ static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
+ return AVERROR(ENOMEM);
+ mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
+ if (!mxf->metadata_sets)
+- return -1;
++ return AVERROR(ENOMEM);
+ mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
+ mxf->metadata_sets_count++;
+ return 0;
+@@ -390,7 +392,7 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i
+ {
+ MXFCryptoContext *cryptocontext = arg;
+ if (size != 16)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul))
+ avio_read(pb, cryptocontext->source_container_ul, 16);
+ return 0;
+@@ -403,10 +405,10 @@ static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int siz
+ case 0x1901:
+ mxf->packages_count = avio_rb32(pb);
+ if (mxf->packages_count >= UINT_MAX / sizeof(UID))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
+ if (!mxf->packages_refs)
+- return -1;
++ return AVERROR(ENOMEM);
+ avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
+ break;
+@@ -443,10 +445,10 @@ static int mxf_read_material_package(void *arg, AVIOContext *pb, int tag, int si
+ case 0x4403:
+ package->tracks_count = avio_rb32(pb);
+ if (package->tracks_count >= UINT_MAX / sizeof(UID))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
+ if (!package->tracks_refs)
+- return -1;
++ return AVERROR(ENOMEM);
+ avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ break;
+@@ -488,10 +490,10 @@ static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID
+ case 0x1001:
+ sequence->structural_components_count = avio_rb32(pb);
+ if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
+ if (!sequence->structural_components_refs)
+- return -1;
++ return AVERROR(ENOMEM);
+ avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
+ break;
+@@ -506,10 +508,10 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size
+ case 0x4403:
+ package->tracks_count = avio_rb32(pb);
+ if (package->tracks_count >= UINT_MAX / sizeof(UID))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
+ if (!package->tracks_refs)
+- return -1;
++ return AVERROR(ENOMEM);
+ avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ break;
+@@ -564,10 +566,10 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
+ case 0x3F01:
+ descriptor->sub_descriptors_count = avio_rb32(pb);
+ if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
+- return -1;
++ return AVERROR_INVALIDDATA;
+ descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
+ if (!descriptor->sub_descriptors_refs)
+- return -1;
++ return AVERROR(ENOMEM);
+ avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
+ break;
+@@ -611,7 +613,7 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
+ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) {
+ descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!descriptor->extradata)
+- return -1;
++ return AVERROR(ENOMEM);
+ descriptor->extradata_size = size;
+ avio_read(pb, descriptor->extradata, size);
+ }
+@@ -684,7 +686,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
+ }
+ if (!material_package) {
+ av_log(mxf->fc, AV_LOG_ERROR, "no material package found\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+
+ for (i = 0; i < material_package->tracks_count; i++) {
+@@ -732,7 +734,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
+ for (k = 0; k < source_package->tracks_count; k++) {
+ if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k], Track))) {
+ av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ if (temp_track->track_id == component->source_track_id) {
+ source_track = temp_track;
+@@ -750,7 +752,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
+ st = avformat_new_stream(mxf->fc, NULL);
+ if (!st) {
+ av_log(mxf->fc, AV_LOG_ERROR, "could not allocate stream\n");
+- return -1;
++ return AVERROR(ENOMEM);
+ }
+ st->id = source_track->track_id;
+ st->priv_data = source_track;
+@@ -762,7 +764,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
+
+ if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) {
+ av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+
+ PRINT_KEY(mxf->fc, "data definition ul", source_track->sequence->data_definition_ul);
+@@ -880,8 +882,9 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
+ uint64_t klv_end = avio_tell(pb) + klv->length;
+
+ if (!ctx)
+- return -1;
++ return AVERROR(ENOMEM);
+ while (avio_tell(pb) + 4 < klv_end) {
++ int ret;
+ int tag = avio_rb16(pb);
+ int size = avio_rb16(pb); /* KLV specified by 0x53 */
+ uint64_t next = avio_tell(pb) + size;
+@@ -905,8 +908,8 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
+ }
+ if (ctx_size && tag == 0x3C0A)
+ avio_read(pb, ctx->uid, 16);
+- else if (read_child(ctx, pb, tag, size, uid) < 0)
+- return -1;
++ else if ((ret = read_child(ctx, pb, tag, size, uid)) < 0)
++ return ret;
+
+ avio_seek(pb, next, SEEK_SET);
+ }
+@@ -921,15 +924,16 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
+
+ if (!mxf_read_sync(s->pb, mxf_header_partition_pack_key, 14)) {
+ av_log(s, AV_LOG_ERROR, "could not find header partition pack key\n");
+- return -1;
++ return AVERROR_INVALIDDATA;
+ }
+ avio_seek(s->pb, -14, SEEK_CUR);
+ mxf->fc = s;
+ while (!s->pb->eof_reached) {
++ int ret;
+ const MXFMetadataReadTableEntry *metadata;
+
+- if (klv_read_packet(&klv, s->pb) < 0)
+- return -1;
++ if ((ret = klv_read_packet(&klv, s->pb)) < 0)
++ return ret;
+ PRINT_KEY(s, "read header", klv.key);
+ av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
+ if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
+@@ -948,7 +952,7 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
+ res = metadata->read(mxf, s->pb, 0, 0, NULL);
+ if (res < 0) {
+ av_log(s, AV_LOG_ERROR, "error reading header metadata\n");
+- return -1;
++ return res;
+ }
+ break;
+ }
+@@ -1016,7 +1020,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
+ int64_t seconds;
+
+ if (!s->bit_rate)
+- return -1;
++ return AVERROR_INVALIDDATA;
+ if (sample_time < 0)
+ sample_time = 0;
+ seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0053-fate-split-ADPCM-and-DPCM-test-references-into-separ.patch b/debian/patches/post-0.8b2/0053-fate-split-ADPCM-and-DPCM-test-references-into-separ.patch
new file mode 100644
index 0000000..97c2acd
--- /dev/null
+++ b/debian/patches/post-0.8b2/0053-fate-split-ADPCM-and-DPCM-test-references-into-separ.patch
@@ -0,0 +1,116 @@
+From 2df5f59ad0710a0d85114b73bd6a5094c26d08bc Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Fri, 13 Jan 2012 00:58:22 +0100
+Subject: [PATCH 53/63] fate: split ADPCM and DPCM test references into
+ separate files.
+
+---
+ tests/Makefile | 1 +
+ tests/fate/adpcm.mak | 35 +++++++++++++++++++++++++++++++++++
+ tests/fate/dpcm.mak | 36 ------------------------------------
+ 3 files changed, 36 insertions(+), 36 deletions(-)
+ create mode 100644 tests/fate/adpcm.mak
+
+diff --git a/tests/Makefile b/tests/Makefile
+index 43024eb..dba9e83 100644
+--- a/tests/Makefile
++++ b/tests/Makefile
+@@ -25,6 +25,7 @@ tests/data/asynth%.sw tests/vsynth%/00.pgm: TAG = GEN
+
+ include $(SRC_PATH)/tests/fate/aac.mak
+ include $(SRC_PATH)/tests/fate/ac3.mak
++include $(SRC_PATH)/tests/fate/adpcm.mak
+ include $(SRC_PATH)/tests/fate/als.mak
+ include $(SRC_PATH)/tests/fate/amrnb.mak
+ include $(SRC_PATH)/tests/fate/amrwb.mak
+diff --git a/tests/fate/adpcm.mak b/tests/fate/adpcm.mak
+new file mode 100644
+index 0000000..2a12d57
+--- /dev/null
++++ b/tests/fate/adpcm.mak
+@@ -0,0 +1,35 @@
++FATE_TESTS += fate-adpcm-ea-r2
++fate-adpcm-ea-r2: CMD = crc -i $(SAMPLES)/ea-mpc/THX_logo.mpc -vn
++
++FATE_TESTS += fate-adpcm-ea-r3
++fate-adpcm-ea-r3: CMD = crc -i $(SAMPLES)/ea-vp6/THX_logo.vp6 -vn
++
++FATE_TESTS += fate-creative-adpcm
++fate-creative-adpcm: CMD = md5 -i $(SAMPLES)/creative/intro-partial.wav -f s16le
++
++FATE_TESTS += fate-creative-adpcm-8-2bit
++fate-creative-adpcm-8-2bit: CMD = md5 -i $(SAMPLES)/creative/BBC_2BIT.VOC -f s16le
++
++FATE_TESTS += fate-creative-adpcm-8-2.6bit
++fate-creative-adpcm-8-2.6bit: CMD = md5 -i $(SAMPLES)/creative/BBC_3BIT.VOC -f s16le
++
++FATE_TESTS += fate-creative-adpcm-8-4bit
++fate-creative-adpcm-8-4bit: CMD = md5 -i $(SAMPLES)/creative/BBC_4BIT.VOC -f s16le
++
++FATE_TESTS += fate-ea-mad-adpcm-ea-r1
++fate-ea-mad-adpcm-ea-r1: CMD = framecrc -i $(SAMPLES)/ea-mad/NFS6LogoE.mad
++
++FATE_TESTS += fate-ea-tqi-adpcm
++fate-ea-tqi-adpcm: CMD = framecrc -i $(SAMPLES)/ea-wve/networkBackbone-partial.wve -frames:v 26
++
++FATE_TESTS += fate-psx-str-v3-adpcm_xa
++fate-psx-str-v3-adpcm_xa: CMD = framecrc -i $(SAMPLES)/psx-str/abc000_cut.str -vn
++
++FATE_TESTS += fate-qt-msadpcm-stereo
++fate-qt-msadpcm-stereo: CMD = md5 -i $(SAMPLES)/qt-surge-suite/surge-2-16-L-ms02.mov -f s16le
++
++FATE_TESTS += fate-qt-msimaadpcm-stereo
++fate-qt-msimaadpcm-stereo: CMD = md5 -i $(SAMPLES)/qt-surge-suite/surge-2-16-L-ms11.mov -f s16le
++
++FATE_TESTS += fate-thp-mjpeg-adpcm
++fate-thp-mjpeg-adpcm: CMD = framecrc -idct simple -i $(SAMPLES)/thp/pikmin2-opening1-partial.thp
+diff --git a/tests/fate/dpcm.mak b/tests/fate/dpcm.mak
+index 606a524..afbc4ba 100644
+--- a/tests/fate/dpcm.mak
++++ b/tests/fate/dpcm.mak
+@@ -1,42 +1,6 @@
+-FATE_TESTS += fate-adpcm-ea-r2
+-fate-adpcm-ea-r2: CMD = crc -i $(SAMPLES)/ea-mpc/THX_logo.mpc -vn
+-
+-FATE_TESTS += fate-adpcm-ea-r3
+-fate-adpcm-ea-r3: CMD = crc -i $(SAMPLES)/ea-vp6/THX_logo.vp6 -vn
+-
+-FATE_TESTS += fate-creative-adpcm
+-fate-creative-adpcm: CMD = md5 -i $(SAMPLES)/creative/intro-partial.wav -f s16le
+-
+-FATE_TESTS += fate-creative-adpcm-8-2bit
+-fate-creative-adpcm-8-2bit: CMD = md5 -i $(SAMPLES)/creative/BBC_2BIT.VOC -f s16le
+-
+-FATE_TESTS += fate-creative-adpcm-8-2.6bit
+-fate-creative-adpcm-8-2.6bit: CMD = md5 -i $(SAMPLES)/creative/BBC_3BIT.VOC -f s16le
+-
+-FATE_TESTS += fate-creative-adpcm-8-4bit
+-fate-creative-adpcm-8-4bit: CMD = md5 -i $(SAMPLES)/creative/BBC_4BIT.VOC -f s16le
+-
+-FATE_TESTS += fate-ea-mad-adpcm-ea-r1
+-fate-ea-mad-adpcm-ea-r1: CMD = framecrc -i $(SAMPLES)/ea-mad/NFS6LogoE.mad
+-
+-FATE_TESTS += fate-ea-tqi-adpcm
+-fate-ea-tqi-adpcm: CMD = framecrc -i $(SAMPLES)/ea-wve/networkBackbone-partial.wve -frames:v 26
+-
+ FATE_TESTS += fate-idroq-video-dpcm
+ fate-idroq-video-dpcm: CMD = framecrc -i $(SAMPLES)/idroq/idlogo.roq
+
+-FATE_TESTS += fate-psx-str-v3-adpcm_xa
+-fate-psx-str-v3-adpcm_xa: CMD = framecrc -i $(SAMPLES)/psx-str/abc000_cut.str -vn
+-
+-FATE_TESTS += fate-qt-msadpcm-stereo
+-fate-qt-msadpcm-stereo: CMD = md5 -i $(SAMPLES)/qt-surge-suite/surge-2-16-L-ms02.mov -f s16le
+-
+-FATE_TESTS += fate-qt-msimaadpcm-stereo
+-fate-qt-msimaadpcm-stereo: CMD = md5 -i $(SAMPLES)/qt-surge-suite/surge-2-16-L-ms11.mov -f s16le
+-
+-FATE_TESTS += fate-thp-mjpeg-adpcm
+-fate-thp-mjpeg-adpcm: CMD = framecrc -idct simple -i $(SAMPLES)/thp/pikmin2-opening1-partial.thp
+-
+ FATE_TESTS += fate-dpcm-xan
+ fate-dpcm-xan: CMD = md5 -i $(SAMPLES)/wc4-xan/wc4_2.avi -vn -f s16le
+
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0054-rv34-Inter-intra-MB-code-split.patch b/debian/patches/post-0.8b2/0054-rv34-Inter-intra-MB-code-split.patch
new file mode 100644
index 0000000..30a7521
--- /dev/null
+++ b/debian/patches/post-0.8b2/0054-rv34-Inter-intra-MB-code-split.patch
@@ -0,0 +1,335 @@
+From 3eeb7557637e8e48fbc64e844a94775edb496906 Mon Sep 17 00:00:00 2001
+From: Christophe GISQUET <christophe.gisquet at gmail.com>
+Date: Mon, 2 Jan 2012 20:53:54 +0100
+Subject: [PATCH 54/63] rv34: Inter/intra MB code split
+
+Split inter/intra macroblock handling code. This will allow further
+optimizations such as performing inverse transform and block reconstruction
+in a single pass as well as specialize code.
+
+Signed-off-by: Janne Grunau <janne-libav at jannau.net>
+---
+ libavcodec/rv34.c | 244 +++++++++++++++++++++++++++++++++++++++++------------
+ 1 files changed, 191 insertions(+), 53 deletions(-)
+
+diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
+index 48b5193..48f34b9 100644
+--- a/libavcodec/rv34.c
++++ b/libavcodec/rv34.c
+@@ -351,44 +351,70 @@ static inline RV34VLC* choose_vlc_set(int quant, int mod, int type)
+ }
+
+ /**
+- * Decode macroblock header and return CBP in case of success, -1 otherwise.
++ * Decode intra macroblock header and return CBP in case of success, -1 otherwise.
+ */
+-static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types)
++static int rv34_decode_intra_mb_header(RV34DecContext *r, int8_t *intra_types)
+ {
+ MpegEncContext *s = &r->s;
+ GetBitContext *gb = &s->gb;
+ int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
+- int i, t;
++ int t;
+
+- if(!r->si.type){
+- r->is16 = get_bits1(gb);
+- if(!r->is16 && !r->rv30){
++ r->is16 = get_bits1(gb);
++ if(r->is16){
++ s->current_picture_ptr->f.mb_type[mb_pos] = MB_TYPE_INTRA16x16;
++ r->block_type = RV34_MB_TYPE_INTRA16x16;
++ t = get_bits(gb, 2);
++ fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0]));
++ r->luma_vlc = 2;
++ }else{
++ if(!r->rv30){
+ if(!get_bits1(gb))
+ av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n");
+ }
+- s->current_picture_ptr->f.mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA;
+- r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA;
+- }else{
+- r->block_type = r->decode_mb_info(r);
+- if(r->block_type == -1)
++ s->current_picture_ptr->f.mb_type[mb_pos] = MB_TYPE_INTRA;
++ r->block_type = RV34_MB_TYPE_INTRA;
++ if(r->decode_intra_types(r, gb, intra_types) < 0)
+ return -1;
+- s->current_picture_ptr->f.mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type];
+- r->mb_type[mb_pos] = r->block_type;
+- if(r->block_type == RV34_MB_SKIP){
+- if(s->pict_type == AV_PICTURE_TYPE_P)
+- r->mb_type[mb_pos] = RV34_MB_P_16x16;
+- if(s->pict_type == AV_PICTURE_TYPE_B)
+- r->mb_type[mb_pos] = RV34_MB_B_DIRECT;
+- }
+- r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->f.mb_type[mb_pos]);
+- rv34_decode_mv(r, r->block_type);
+- if(r->block_type == RV34_MB_SKIP){
+- fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0]));
+- return 0;
+- }
+- r->chroma_vlc = 1;
+- r->luma_vlc = 0;
++ r->luma_vlc = 1;
+ }
++
++ r->chroma_vlc = 0;
++ r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0);
++
++ return rv34_decode_cbp(gb, r->cur_vlcs, r->is16);
++}
++
++/**
++ * Decode inter macroblock header and return CBP in case of success, -1 otherwise.
++ */
++static int rv34_decode_inter_mb_header(RV34DecContext *r, int8_t *intra_types)
++{
++ MpegEncContext *s = &r->s;
++ GetBitContext *gb = &s->gb;
++ int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
++ int i, t;
++
++ r->block_type = r->decode_mb_info(r);
++ if(r->block_type == -1)
++ return -1;
++ s->current_picture_ptr->f.mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type];
++ r->mb_type[mb_pos] = r->block_type;
++ if(r->block_type == RV34_MB_SKIP){
++ if(s->pict_type == AV_PICTURE_TYPE_P)
++ r->mb_type[mb_pos] = RV34_MB_P_16x16;
++ if(s->pict_type == AV_PICTURE_TYPE_B)
++ r->mb_type[mb_pos] = RV34_MB_B_DIRECT;
++ }
++ r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->f.mb_type[mb_pos]);
++ rv34_decode_mv(r, r->block_type);
++ if(r->block_type == RV34_MB_SKIP){
++ fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0]));
++ return 0;
++ }
++ r->chroma_vlc = 1;
++ r->luma_vlc = 0;
++
+ if(IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])){
+ if(r->is16){
+ t = get_bits(gb, 2);
+@@ -1123,7 +1149,7 @@ static int rv34_set_deblock_coef(RV34DecContext *r)
+ return hmvmask | vmvmask;
+ }
+
+-static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
++static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types)
+ {
+ MpegEncContext *s = &r->s;
+ GetBitContext *gb = &s->gb;
+@@ -1131,7 +1157,6 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
+ int q_dc, q_ac, has_ac;
+ int i, blknum, blkoff;
+ LOCAL_ALIGNED_16(DCTELEM, block16, [64]);
+- int luma_dc_quant;
+ int dist;
+ int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
+
+@@ -1151,20 +1176,19 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
+ r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1];
+
+ s->qscale = r->si.quant;
+- cbp = cbp2 = rv34_decode_mb_header(r, intra_types);
++ cbp = cbp2 = rv34_decode_inter_mb_header(r, intra_types);
+ r->cbp_luma [mb_pos] = cbp;
+ r->cbp_chroma[mb_pos] = cbp >> 16;
+- if(s->pict_type == AV_PICTURE_TYPE_I)
+- r->deblock_coefs[mb_pos] = 0xFFFF;
+- else
+- r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos];
++ r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos];
+ s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
+
+ if(cbp == -1)
+ return -1;
+
+- luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16 ? r->luma_dc_quant_p[s->qscale] : r->luma_dc_quant_i[s->qscale];
+ if(r->is16){
++ int luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16
++ ? r->luma_dc_quant_p[s->qscale]
++ : r->luma_dc_quant_i[s->qscale];
+ q_dc = rv34_qscale_tab[luma_dc_quant];
+ q_ac = rv34_qscale_tab[s->qscale];
+ s->dsp.clear_block(block16);
+@@ -1172,25 +1196,37 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
+ r->rdsp.rv34_inv_transform_tab[1](block16);
+ else
+ r->rdsp.rv34_inv_transform_dc_tab[1](block16);
+- }
+
+- q_ac = rv34_qscale_tab[s->qscale];
+- for(i = 0; i < 16; i++, cbp >>= 1){
+- DCTELEM *ptr;
+- if(!r->is16 && !(cbp & 1)) continue;
+- blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
+- blkoff = ((i & 1) << 2) + ((i & 4) << 3);
+- ptr = s->block[blknum] + blkoff;
+- if(cbp & 1)
+- has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
+- else
+- has_ac = 0;
+- if(r->is16) //FIXME: optimize
++ q_ac = rv34_qscale_tab[s->qscale];
++ for(i = 0; i < 16; i++, cbp >>= 1){
++ DCTELEM *ptr;
++ blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
++ blkoff = ((i & 1) << 2) + ((i & 4) << 3);
++ ptr = s->block[blknum] + blkoff;
++ if(cbp & 1)
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ else
++ has_ac = 0;
+ ptr[0] = block16[(i & 3) | ((i & 0xC) << 1)];
+- if(has_ac)
+- r->rdsp.rv34_inv_transform_tab[0](ptr);
+- else
+- r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ if(has_ac)
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ }
++ }else{
++ q_ac = rv34_qscale_tab[s->qscale];
++ for(i = 0; i < 16; i++, cbp >>= 1){
++ DCTELEM *ptr;
++ if(!(cbp & 1)) continue;
++ blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
++ blkoff = ((i & 1) << 2) + ((i & 4) << 3);
++ ptr = s->block[blknum] + blkoff;
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ if(has_ac)
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ }
+ }
+ if(r->block_type == RV34_MB_P_MIX16x16)
+ r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1);
+@@ -1215,6 +1251,104 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
+ return 0;
+ }
+
++static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types)
++{
++ MpegEncContext *s = &r->s;
++ GetBitContext *gb = &s->gb;
++ int cbp, cbp2;
++ int q_dc, q_ac, has_ac;
++ int i, blknum, blkoff;
++ LOCAL_ALIGNED_16(DCTELEM, block16, [64]);
++ int dist;
++ int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
++
++ // Calculate which neighbours are available. Maybe it's worth optimizing too.
++ memset(r->avail_cache, 0, sizeof(r->avail_cache));
++ fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4);
++ dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width;
++ if(s->mb_x && dist)
++ r->avail_cache[5] =
++ r->avail_cache[9] = s->current_picture_ptr->f.mb_type[mb_pos - 1];
++ if(dist >= s->mb_width)
++ r->avail_cache[2] =
++ r->avail_cache[3] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride];
++ if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1)
++ r->avail_cache[4] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride + 1];
++ if(s->mb_x && dist > s->mb_width)
++ r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1];
++
++ s->qscale = r->si.quant;
++ cbp = cbp2 = rv34_decode_intra_mb_header(r, intra_types);
++ r->cbp_luma [mb_pos] = cbp;
++ r->cbp_chroma[mb_pos] = cbp >> 16;
++ r->deblock_coefs[mb_pos] = 0xFFFF;
++ s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
++
++ if(cbp == -1)
++ return -1;
++
++ if(r->is16){
++ int luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16
++ ? r->luma_dc_quant_p[s->qscale]
++ : r->luma_dc_quant_i[s->qscale];
++ q_dc = rv34_qscale_tab[luma_dc_quant];
++ q_ac = rv34_qscale_tab[s->qscale];
++ s->dsp.clear_block(block16);
++ if (rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac))
++ r->rdsp.rv34_inv_transform_tab[1](block16);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[1](block16);
++
++ q_ac = rv34_qscale_tab[s->qscale];
++ for(i = 0; i < 16; i++, cbp >>= 1){
++ DCTELEM *ptr;
++ blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
++ blkoff = ((i & 1) << 2) + ((i & 4) << 3);
++ ptr = s->block[blknum] + blkoff;
++ if(cbp & 1)
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ else
++ has_ac = 0;
++ ptr[0] = block16[(i & 3) | ((i & 0xC) << 1)];
++ if(has_ac)
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ }
++ }else{
++ q_ac = rv34_qscale_tab[s->qscale];
++ for(i = 0; i < 16; i++, cbp >>= 1){
++ DCTELEM *ptr;
++ if(!(cbp & 1)) continue;
++ blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
++ blkoff = ((i & 1) << 2) + ((i & 4) << 3);
++ ptr = s->block[blknum] + blkoff;
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ if(has_ac)
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ }
++ }
++
++ q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
++ q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
++ for(; i < 24; i++, cbp >>= 1){
++ DCTELEM *ptr;
++ if(!(cbp & 1)) continue;
++ blknum = ((i & 4) >> 2) + 4;
++ blkoff = ((i & 1) << 2) + ((i & 2) << 4);
++ ptr = s->block[blknum] + blkoff;
++ if (rv34_decode_block(ptr, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac))
++ r->rdsp.rv34_inv_transform_tab[0](ptr);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ }
++ rv34_output_macroblock(r, intra_types, cbp2, r->is16);
++
++ return 0;
++}
++
+ static int check_slice_end(RV34DecContext *r, MpegEncContext *s)
+ {
+ int bits;
+@@ -1324,7 +1458,11 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
+ ff_update_block_index(s);
+ s->dsp.clear_blocks(s->block[0]);
+
+- if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){
++ if(r->si.type)
++ res = rv34_decode_inter_macroblock(r, r->intra_types + s->mb_x * 4 + 4);
++ else
++ res = rv34_decode_intra_macroblock(r, r->intra_types + s->mb_x * 4 + 4);
++ if(res < 0){
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_ERROR);
+ return -1;
+ }
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0055-rv34-Intra-16x16-handling.patch b/debian/patches/post-0.8b2/0055-rv34-Intra-16x16-handling.patch
new file mode 100644
index 0000000..5097d21
--- /dev/null
+++ b/debian/patches/post-0.8b2/0055-rv34-Intra-16x16-handling.patch
@@ -0,0 +1,606 @@
+From d78062386e425deafe9a08d109cff70b7a2de22c Mon Sep 17 00:00:00 2001
+From: Christophe GISQUET <christophe.gisquet at gmail.com>
+Date: Tue, 3 Jan 2012 00:22:11 +0100
+Subject: [PATCH 55/63] rv34: Intra 16x16 handling
+
+Extract processing of intra 16x16 blocks from intra macroblock
+processing.
+Also implement a function performing inverse transform and block
+reconstruction for DC-only blocks in 1 pass instead of 2.
+---
+ libavcodec/rv34.c | 281 +++++++++++++++++++++++------------------
+ libavcodec/rv34dsp.c | 47 +++++++-
+ libavcodec/rv34dsp.h | 7 +
+ libavcodec/x86/rv34dsp.asm | 83 +++++++++++--
+ libavcodec/x86/rv34dsp_init.c | 14 ++-
+ 5 files changed, 292 insertions(+), 140 deletions(-)
+
+diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
+index 48f34b9..478c93a 100644
+--- a/libavcodec/rv34.c
++++ b/libavcodec/rv34.c
+@@ -982,15 +982,6 @@ static void rv34_pred_4x4_block(RV34DecContext *r, uint8_t *dst, int stride, int
+ r->h.pred4x4[itype](dst, prev, stride);
+ }
+
+-/** add_pixels_clamped for 4x4 block */
+-static void rv34_add_4x4_block(uint8_t *dst, int stride, DCTELEM block[64], int off)
+-{
+- int x, y;
+- for(y = 0; y < 4; y++)
+- for(x = 0; x < 4; x++)
+- dst[x + y*stride] = av_clip_uint8(dst[x + y*stride] + block[off + x+y*8]);
+-}
+-
+ static inline int adjust_pred16(int itype, int up, int left)
+ {
+ if(!up && !left)
+@@ -1007,15 +998,20 @@ static inline int adjust_pred16(int itype, int up, int left)
+ return itype;
+ }
+
+-static void rv34_output_macroblock(RV34DecContext *r, int8_t *intra_types, int cbp, int is16)
++static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp)
+ {
+- MpegEncContext *s = &r->s;
+- DSPContext *dsp = &s->dsp;
+- int i, j;
+- uint8_t *Y, *U, *V;
+- int itype;
+- int avail[6*8] = {0};
+- int idx;
++ LOCAL_ALIGNED_16(DCTELEM, block16, [64]);
++ MpegEncContext *s = &r->s;
++ DSPContext *dsp = &s->dsp;
++ GetBitContext *gb = &s->gb;
++ int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
++ q_ac = rv34_qscale_tab[s->qscale];
++ uint8_t *dst = s->dest[0];
++ DCTELEM *ptr = s->block[0];
++ int avail[6*8] = {0};
++ int i, j, itype, has_ac;
++
++ memset(block16, 0, 64 * sizeof(*block16));
+
+ // Set neighbour information.
+ if(r->avail_cache[1])
+@@ -1031,52 +1027,142 @@ static void rv34_output_macroblock(RV34DecContext *r, int8_t *intra_types, int c
+ if(r->avail_cache[9])
+ avail[24] = avail[32] = 1;
+
+- Y = s->dest[0];
+- U = s->dest[1];
+- V = s->dest[2];
+- if(!is16){
+- for(j = 0; j < 4; j++){
+- idx = 9 + j*8;
+- for(i = 0; i < 4; i++, cbp >>= 1, Y += 4, idx++){
+- rv34_pred_4x4_block(r, Y, s->linesize, ittrans[intra_types[i]], avail[idx-8], avail[idx-1], avail[idx+7], avail[idx-7]);
+- avail[idx] = 1;
+- if(cbp & 1)
+- rv34_add_4x4_block(Y, s->linesize, s->block[(i>>1)+(j&2)], (i&1)*4+(j&1)*32);
++ has_ac = rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
++ if(has_ac)
++ r->rdsp.rv34_inv_transform_tab[1](block16);
++ else
++ r->rdsp.rv34_inv_transform_dc_tab[1](block16);
++
++ itype = ittrans16[intra_types[0]];
++ itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
++ r->h.pred16x16[itype](dst, s->linesize);
++
++ dsp->clear_block(ptr);
++ for(j = 0; j < 4; j++){
++ for(i = 0; i < 4; i++, cbp >>= 1){
++ int dc = block16[i + j*8];
++
++ if(cbp & 1){
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ }else
++ has_ac = 0;
++
++ if(has_ac){
++ ptr[0] = dc;
++ r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr);
++ dsp->clear_block(ptr);
++ }else
++ r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc);
++ }
++
++ dst += 4*s->linesize;
++ }
++
++ itype = ittrans16[intra_types[0]];
++ if(itype == PLANE_PRED8x8) itype = DC_PRED8x8;
++ itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
++
++ q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
++ q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
++
++ for(j = 1; j < 3; j++){
++ dst = s->dest[j];
++ r->h.pred8x8[itype](dst, s->uvlinesize);
++ for(i = 0; i < 4; i++, cbp >>= 1){
++ uint8_t *pdst;
++ if(!(cbp & 1)) continue;
++ pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize;
++
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac);
++ if(has_ac){
++ r->rdsp.rv34_idct_add(pdst, s->uvlinesize, ptr);
++ dsp->clear_block(ptr);
++ }else{
++ r->rdsp.rv34_idct_dc_add(pdst, s->uvlinesize, ptr[0]);
++ ptr[0] = 0;
+ }
+- Y += s->linesize * 4 - 4*4;
+- intra_types += r->intra_types_stride;
+ }
+- intra_types -= r->intra_types_stride * 4;
++ }
++}
++
++static void rv34_output_intra(RV34DecContext *r, int8_t *intra_types, int cbp)
++{
++ MpegEncContext *s = &r->s;
++ DSPContext *dsp = &s->dsp;
++ GetBitContext *gb = &s->gb;
++ DCTELEM *ptr = s->block[0];
++ uint8_t *dst = s->dest[0];
++ int avail[6*8] = {0};
++ int i, j, k;
++ int idx, has_ac;
++ int q_ac, q_dc;
++
++ // Set neighbour information.
++ if(r->avail_cache[1])
++ avail[0] = 1;
++ if(r->avail_cache[2])
++ avail[1] = avail[2] = 1;
++ if(r->avail_cache[3])
++ avail[3] = avail[4] = 1;
++ if(r->avail_cache[4])
++ avail[5] = 1;
++ if(r->avail_cache[5])
++ avail[8] = avail[16] = 1;
++ if(r->avail_cache[9])
++ avail[24] = avail[32] = 1;
++
++ q_ac = rv34_qscale_tab[s->qscale];
++ for(j = 0; j < 4; j++){
++ idx = 9 + j*8;
++ for(i = 0; i < 4; i++, cbp >>= 1, dst += 4, idx++){
++ rv34_pred_4x4_block(r, dst, s->linesize, ittrans[intra_types[i]], avail[idx-8], avail[idx-1], avail[idx+7], avail[idx-7]);
++ avail[idx] = 1;
++ if(!(cbp & 1)) continue;
++
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
++ if(has_ac){
++ r->rdsp.rv34_idct_add(dst, s->linesize, ptr);
++ dsp->clear_block(ptr);
++ }else{
++ r->rdsp.rv34_idct_dc_add(dst, s->linesize, ptr[0]);
++ ptr[0] = 0;
++ }
++ }
++ dst += s->linesize * 4 - 4*4;
++ intra_types += r->intra_types_stride;
++ }
++
++ intra_types -= r->intra_types_stride * 4;
++
++ q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
++ q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
++
++ for(k = 0; k < 2; k++){
++ dst = s->dest[1+k];
+ fill_rectangle(r->avail_cache + 6, 2, 2, 4, 0, 4);
++
+ for(j = 0; j < 2; j++){
+- idx = 6 + j*4;
+- for(i = 0; i < 2; i++, cbp >>= 1, idx++){
+- rv34_pred_4x4_block(r, U + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]);
+- rv34_pred_4x4_block(r, V + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]);
+- r->avail_cache[idx] = 1;
+- if(cbp & 0x01)
+- rv34_add_4x4_block(U + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[4], i*4+j*32);
+- if(cbp & 0x10)
+- rv34_add_4x4_block(V + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[5], i*4+j*32);
++ int* acache = r->avail_cache + 6 + j*4;
++ for(i = 0; i < 2; i++, cbp >>= 1, acache++){
++ int itype = ittrans[intra_types[i*2+j*2*r->intra_types_stride]];
++ rv34_pred_4x4_block(r, dst+4*i, s->uvlinesize, itype, acache[-4], acache[-1], !i && !j, acache[-3]);
++ acache[0] = 1;
++
++ if(!(cbp&1)) continue;
++
++ has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac);
++ if(has_ac){
++ r->rdsp.rv34_idct_add(dst + 4*i, s->uvlinesize, ptr);
++ dsp->clear_block(ptr);
++ }
++ else {
++ r->rdsp.rv34_idct_dc_add(dst + 4*i, s->uvlinesize, ptr[0]);
++ ptr[0] = 0;
++ }
+ }
++
++ dst += 4*s->uvlinesize;
+ }
+- }else{
+- itype = ittrans16[intra_types[0]];
+- itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
+- r->h.pred16x16[itype](Y, s->linesize);
+- dsp->add_pixels_clamped(s->block[0], Y, s->linesize);
+- dsp->add_pixels_clamped(s->block[1], Y + 8, s->linesize);
+- Y += s->linesize * 8;
+- dsp->add_pixels_clamped(s->block[2], Y, s->linesize);
+- dsp->add_pixels_clamped(s->block[3], Y + 8, s->linesize);
+-
+- itype = ittrans16[intra_types[0]];
+- if(itype == PLANE_PRED8x8) itype = DC_PRED8x8;
+- itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
+- r->h.pred8x8[itype](U, s->uvlinesize);
+- dsp->add_pixels_clamped(s->block[4], U, s->uvlinesize);
+- r->h.pred8x8[itype](V, s->uvlinesize);
+- dsp->add_pixels_clamped(s->block[5], V, s->uvlinesize);
+ }
+ }
+
+@@ -1185,6 +1271,12 @@ static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types)
+ if(cbp == -1)
+ return -1;
+
++ if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])){
++ if(r->is16) rv34_output_i16x16(r, intra_types, cbp);
++ else rv34_output_intra(r, intra_types, cbp);
++ return 0;
++ }
++
+ if(r->is16){
+ int luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16
+ ? r->luma_dc_quant_p[s->qscale]
+@@ -1243,10 +1335,7 @@ static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types)
+ else
+ r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
+ }
+- if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos]))
+- rv34_output_macroblock(r, intra_types, cbp2, r->is16);
+- else
+- rv34_apply_differences(r, cbp2);
++ rv34_apply_differences(r, cbp2);
+
+ return 0;
+ }
+@@ -1254,12 +1343,7 @@ static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types)
+ static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types)
+ {
+ MpegEncContext *s = &r->s;
+- GetBitContext *gb = &s->gb;
+- int cbp, cbp2;
+- int q_dc, q_ac, has_ac;
+- int i, blknum, blkoff;
+- LOCAL_ALIGNED_16(DCTELEM, block16, [64]);
+- int dist;
++ int cbp, dist;
+ int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
+
+ // Calculate which neighbours are available. Maybe it's worth optimizing too.
+@@ -1278,74 +1362,21 @@ static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types)
+ r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1];
+
+ s->qscale = r->si.quant;
+- cbp = cbp2 = rv34_decode_intra_mb_header(r, intra_types);
++ cbp = rv34_decode_intra_mb_header(r, intra_types);
+ r->cbp_luma [mb_pos] = cbp;
+ r->cbp_chroma[mb_pos] = cbp >> 16;
+ r->deblock_coefs[mb_pos] = 0xFFFF;
+- s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
++ s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
+
+ if(cbp == -1)
+ return -1;
+
+ if(r->is16){
+- int luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16
+- ? r->luma_dc_quant_p[s->qscale]
+- : r->luma_dc_quant_i[s->qscale];
+- q_dc = rv34_qscale_tab[luma_dc_quant];
+- q_ac = rv34_qscale_tab[s->qscale];
+- s->dsp.clear_block(block16);
+- if (rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac))
+- r->rdsp.rv34_inv_transform_tab[1](block16);
+- else
+- r->rdsp.rv34_inv_transform_dc_tab[1](block16);
+-
+- q_ac = rv34_qscale_tab[s->qscale];
+- for(i = 0; i < 16; i++, cbp >>= 1){
+- DCTELEM *ptr;
+- blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
+- blkoff = ((i & 1) << 2) + ((i & 4) << 3);
+- ptr = s->block[blknum] + blkoff;
+- if(cbp & 1)
+- has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
+- else
+- has_ac = 0;
+- ptr[0] = block16[(i & 3) | ((i & 0xC) << 1)];
+- if(has_ac)
+- r->rdsp.rv34_inv_transform_tab[0](ptr);
+- else
+- r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
+- }
+- }else{
+- q_ac = rv34_qscale_tab[s->qscale];
+- for(i = 0; i < 16; i++, cbp >>= 1){
+- DCTELEM *ptr;
+- if(!(cbp & 1)) continue;
+- blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
+- blkoff = ((i & 1) << 2) + ((i & 4) << 3);
+- ptr = s->block[blknum] + blkoff;
+- has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
+- if(has_ac)
+- r->rdsp.rv34_inv_transform_tab[0](ptr);
+- else
+- r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
+- }
+- }
+-
+- q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
+- q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
+- for(; i < 24; i++, cbp >>= 1){
+- DCTELEM *ptr;
+- if(!(cbp & 1)) continue;
+- blknum = ((i & 4) >> 2) + 4;
+- blkoff = ((i & 1) << 2) + ((i & 2) << 4);
+- ptr = s->block[blknum] + blkoff;
+- if (rv34_decode_block(ptr, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac))
+- r->rdsp.rv34_inv_transform_tab[0](ptr);
+- else
+- r->rdsp.rv34_inv_transform_dc_tab[0](ptr);
++ rv34_output_i16x16(r, intra_types, cbp);
++ return 0;
+ }
+- rv34_output_macroblock(r, intra_types, cbp2, r->is16);
+
++ rv34_output_intra(r, intra_types, cbp);
+ return 0;
+ }
+
+diff --git a/libavcodec/rv34dsp.c b/libavcodec/rv34dsp.c
+index 1767be4..91c455a 100644
+--- a/libavcodec/rv34dsp.c
++++ b/libavcodec/rv34dsp.c
+@@ -32,7 +32,7 @@
+ * @{
+ */
+
+-static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block)
++static av_always_inline void rv34_row_transform(int temp[16], const DCTELEM *block)
+ {
+ int i;
+
+@@ -73,6 +73,32 @@ static void rv34_inv_transform_c(DCTELEM *block){
+ }
+
+ /**
++ * Real Video 3.0/4.0 inverse transform + sample reconstruction
++ * Code is almost the same as in SVQ3, only scaling is different.
++ */
++static void rv34_idct_add_c(uint8_t *dst, int stride, const DCTELEM *block){
++ int temp[16];
++ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
++ int i;
++
++ rv34_row_transform(temp, block);
++
++ for(i = 0; i < 4; i++){
++ const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
++ const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
++ const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
++ const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
++
++ dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
++ dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
++ dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
++ dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
++
++ dst += stride;
++ }
++}
++
++/**
+ * RealVideo 3.0/4.0 inverse transform for DC block
+ *
+ * Code is almost the same as rv34_inv_transform()
+@@ -97,6 +123,22 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){
+ }
+ }
+
++static void rv34_idct_dc_add_c(uint8_t *dst, int stride, int dc)
++{
++ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
++ int i, j;
++
++ cm += (13*13*dc + 0x200) >> 10;
++
++ for (i = 0; i < 4; i++)
++ {
++ for (j = 0; j < 4; j++)
++ dst[j] = cm[ dst[j] ];
++
++ dst += stride;
++ }
++}
++
+ static void rv34_inv_transform_dc_c(DCTELEM *block)
+ {
+ DCTELEM dc = (13 * 13 * block[0] + 0x200) >> 10;
+@@ -126,6 +168,9 @@ av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
+ c->rv34_inv_transform_dc_tab[0] = rv34_inv_transform_dc_c;
+ c->rv34_inv_transform_dc_tab[1] = rv34_inv_transform_dc_noround_c;
+
++ c->rv34_idct_add = rv34_idct_add_c;
++ c->rv34_idct_dc_add = rv34_idct_dc_add_c;
++
+ if (HAVE_NEON)
+ ff_rv34dsp_init_neon(c, dsp);
+ if (HAVE_MMX)
+diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h
+index 6f53a09..2e9e58e 100644
+--- a/libavcodec/rv34dsp.h
++++ b/libavcodec/rv34dsp.h
+@@ -36,6 +36,11 @@ typedef void (*rv40_weight_func)(uint8_t *dst/*align width (8 or 16)*/,
+
+ typedef void (*rv34_inv_transform_func)(DCTELEM *block);
+
++typedef void (*rv34_idct_add_func)(uint8_t *dst, int stride,
++ const DCTELEM *block);
++typedef void (*rv34_idct_dc_add_func)(uint8_t *dst, int stride,
++ int dc);
++
+ typedef void (*rv40_weak_loop_filter_func)(uint8_t *src, int stride,
+ int filter_p1, int filter_q1,
+ int alpha, int beta,
+@@ -57,6 +62,8 @@ typedef struct RV34DSPContext {
+ rv40_weight_func rv40_weight_pixels_tab[2];
+ rv34_inv_transform_func rv34_inv_transform_tab[2];
+ void (*rv34_inv_transform_dc_tab[2])(DCTELEM *block);
++ rv34_idct_add_func rv34_idct_add;
++ rv34_idct_dc_add_func rv34_idct_dc_add;
+ rv40_weak_loop_filter_func rv40_weak_loop_filter[2];
+ rv40_strong_loop_filter_func rv40_strong_loop_filter[2];
+ rv40_loop_filter_strength_func rv40_loop_filter_strength[2];
+diff --git a/libavcodec/x86/rv34dsp.asm b/libavcodec/x86/rv34dsp.asm
+index 58f1af0..c8eeebb 100644
+--- a/libavcodec/x86/rv34dsp.asm
++++ b/libavcodec/x86/rv34dsp.asm
+@@ -35,21 +35,84 @@ SECTION .text
+ sar %1, 10
+ %endmacro
+
+-%macro rv34_idct_dequant4x4_dc 1
+-cglobal rv34_idct_dequant4x4_%1_mmx2, 1, 2, 0
++%macro rv34_idct 1
++cglobal rv34_idct_%1_mmx2, 1, 2, 0
+ movsx r1, word [r0]
+ IDCT_DC r1
+- movd mm0, r1
+- pshufw mm0, mm0, 0
+- movq [r0+ 0], mm0
+- movq [r0+16], mm0
+- movq [r0+32], mm0
+- movq [r0+48], mm0
++ movd m0, r1
++ pshufw m0, m0, 0
++ movq [r0+ 0], m0
++ movq [r0+16], m0
++ movq [r0+32], m0
++ movq [r0+48], m0
+ REP_RET
+ %endmacro
+
+ INIT_MMX
+ %define IDCT_DC IDCT_DC_ROUND
+-rv34_idct_dequant4x4_dc dc
++rv34_idct dc
+ %define IDCT_DC IDCT_DC_NOROUND
+-rv34_idct_dequant4x4_dc dc_noround
++rv34_idct dc_noround
++
++; ff_rv34_idct_dc_add_mmx(uint8_t *dst, int stride, int dc);
++cglobal rv34_idct_dc_add_mmx, 3, 3
++ ; calculate DC
++ IDCT_DC_ROUND r2
++ pxor m1, m1
++ movd m0, r2
++ psubw m1, m0
++ packuswb m0, m0
++ packuswb m1, m1
++ punpcklbw m0, m0
++ punpcklbw m1, m1
++ punpcklwd m0, m0
++ punpcklwd m1, m1
++
++ ; add DC
++ lea r2, [r0+r1*2]
++ movh m2, [r0]
++ movh m3, [r0+r1]
++ movh m4, [r2]
++ movh m5, [r2+r1]
++ paddusb m2, m0
++ paddusb m3, m0
++ paddusb m4, m0
++ paddusb m5, m0
++ psubusb m2, m1
++ psubusb m3, m1
++ psubusb m4, m1
++ psubusb m5, m1
++ movh [r0], m2
++ movh [r0+r1], m3
++ movh [r2], m4
++ movh [r2+r1], m5
++ RET
++
++; ff_rv34_idct_dc_add_sse4(uint8_t *dst, int stride, int dc);
++INIT_XMM
++cglobal rv34_idct_dc_add_sse4, 3, 3, 6
++ ; load data
++ IDCT_DC_ROUND r2
++ pxor m1, m1
++
++ ; calculate DC
++ movd m0, r2
++ lea r2, [r0+r1*2]
++ movd m2, [r0]
++ movd m3, [r0+r1]
++ pshuflw m0, m0, 0
++ movd m4, [r2]
++ movd m5, [r2+r1]
++ punpcklqdq m0, m0
++ punpckldq m2, m3
++ punpckldq m4, m5
++ punpcklbw m2, m1
++ punpcklbw m4, m1
++ paddw m2, m0
++ paddw m4, m0
++ packuswb m2, m4
++ movd [r0], m2
++ pextrd [r0+r1], m2, 1
++ pextrd [r2], m2, 2
++ pextrd [r2+r1], m2, 3
++ RET
+diff --git a/libavcodec/x86/rv34dsp_init.c b/libavcodec/x86/rv34dsp_init.c
+index 4317e9b..c10ae4e 100644
+--- a/libavcodec/x86/rv34dsp_init.c
++++ b/libavcodec/x86/rv34dsp_init.c
+@@ -24,17 +24,23 @@
+ #include "libavcodec/dsputil.h"
+ #include "libavcodec/rv34dsp.h"
+
+-void ff_rv34_idct_dequant4x4_dc_mmx2(DCTELEM *block);
+-void ff_rv34_idct_dequant4x4_dc_noround_mmx2(DCTELEM *block);
++void ff_rv34_idct_dc_mmx2(DCTELEM *block);
++void ff_rv34_idct_dc_noround_mmx2(DCTELEM *block);
++void ff_rv34_idct_dc_add_mmx(uint8_t *dst, int stride, int dc);
++void ff_rv34_idct_dc_add_sse4(uint8_t *dst, int stride, int dc);
+
+ av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp)
+ {
+ #if HAVE_YASM
+ int mm_flags = av_get_cpu_flags();
+
++ if (mm_flags & AV_CPU_FLAG_MMX)
++ c->rv34_idct_dc_add = ff_rv34_idct_dc_add_mmx;
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
+- c->rv34_inv_transform_dc_tab[0] = ff_rv34_idct_dequant4x4_dc_mmx2;
+- c->rv34_inv_transform_dc_tab[1] = ff_rv34_idct_dequant4x4_dc_noround_mmx2;
++ c->rv34_inv_transform_dc_tab[0] = ff_rv34_idct_dc_mmx2;
++ c->rv34_inv_transform_dc_tab[1] = ff_rv34_idct_dc_noround_mmx2;
+ }
++ if (mm_flags & AV_CPU_FLAG_SSE4)
++ c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;
+ #endif
+ }
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0056-avcodec-add-a-public-function-avcodec_fill_audio_fra.patch b/debian/patches/post-0.8b2/0056-avcodec-add-a-public-function-avcodec_fill_audio_fra.patch
new file mode 100644
index 0000000..a6641b2
--- /dev/null
+++ b/debian/patches/post-0.8b2/0056-avcodec-add-a-public-function-avcodec_fill_audio_fra.patch
@@ -0,0 +1,176 @@
+From 5ee5fa021f32e0506bed6ebd183c807d5162bc72 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Thu, 15 Dec 2011 17:56:06 -0500
+Subject: [PATCH 56/63] avcodec: add a public function,
+ avcodec_fill_audio_frame().
+
+This is a convenience function for the user to fill audio AVFrame information.
+---
+ libavcodec/avcodec.h | 20 +++++++++++
+ libavcodec/utils.c | 94 +++++++++++++++++++++++++++++---------------------
+ 2 files changed, 75 insertions(+), 39 deletions(-)
+
+diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
+index 49d2a0f..a5071aa 100644
+--- a/libavcodec/avcodec.h
++++ b/libavcodec/avcodec.h
+@@ -4239,6 +4239,26 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
+ const short *samples);
+
+ /**
++ * Fill audio frame data and linesize.
++ * AVFrame extended_data channel pointers are allocated if necessary for
++ * planar audio.
++ *
++ * @param frame the AVFrame
++ * frame->nb_samples must be set prior to calling the
++ * function. This function fills in frame->data,
++ * frame->extended_data, frame->linesize[0].
++ * @param nb_channels channel count
++ * @param sample_fmt sample format
++ * @param buf buffer to use for frame data
++ * @param buf_size size of buffer
++ * @param align plane size sample alignment
++ * @return 0 on success, negative error code on failure
++ */
++int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
++ enum AVSampleFormat sample_fmt, const uint8_t *buf,
++ int buf_size, int align);
++
++/**
+ * Encode a video frame from pict into buf.
+ * The input picture should be
+ * stored using a specific format, namely avctx.pix_fmt.
+diff --git a/libavcodec/utils.c b/libavcodec/utils.c
+index 8473aac..c3faa76 100644
+--- a/libavcodec/utils.c
++++ b/libavcodec/utils.c
+@@ -239,11 +239,47 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
+ *width=FFALIGN(*width, align);
+ }
+
++int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
++ enum AVSampleFormat sample_fmt, const uint8_t *buf,
++ int buf_size, int align)
++{
++ int ch, planar, needed_size, ret = 0;
++
++ needed_size = av_samples_get_buffer_size(NULL, nb_channels,
++ frame->nb_samples, sample_fmt,
++ align);
++ if (buf_size < needed_size)
++ return AVERROR(EINVAL);
++
++ planar = av_sample_fmt_is_planar(sample_fmt);
++ if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
++ if (!(frame->extended_data = av_mallocz(nb_channels *
++ sizeof(*frame->extended_data))))
++ return AVERROR(ENOMEM);
++ } else {
++ frame->extended_data = frame->data;
++ }
++
++ if ((ret = av_samples_fill_arrays(frame->extended_data, &frame->linesize[0],
++ buf, nb_channels, frame->nb_samples,
++ sample_fmt, align)) < 0) {
++ if (frame->extended_data != frame->data)
++ av_free(frame->extended_data);
++ return ret;
++ }
++ if (frame->extended_data != frame->data) {
++ for (ch = 0; ch < AV_NUM_DATA_POINTERS; ch++)
++ frame->data[ch] = frame->extended_data[ch];
++ }
++
++ return ret;
++}
++
+ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
+ {
+ AVCodecInternal *avci = avctx->internal;
+ InternalBuffer *buf;
+- int buf_size, ret, i, needs_extended_data;
++ int buf_size, ret;
+
+ buf_size = av_samples_get_buffer_size(NULL, avctx->channels,
+ frame->nb_samples, avctx->sample_fmt,
+@@ -251,9 +287,6 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
+ if (buf_size < 0)
+ return AVERROR(EINVAL);
+
+- needs_extended_data = av_sample_fmt_is_planar(avctx->sample_fmt) &&
+- avctx->channels > AV_NUM_DATA_POINTERS;
+-
+ /* allocate InternalBuffer if needed */
+ if (!avci->buffer) {
+ avci->buffer = av_mallocz(sizeof(InternalBuffer));
+@@ -285,48 +318,31 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
+ /* if there is no previous buffer or the previous buffer cannot be used
+ as-is, allocate a new buffer and/or rearrange the channel pointers */
+ if (!buf->extended_data) {
+- /* if the channel pointers will fit, just set extended_data to data,
+- otherwise allocate the extended_data channel pointers */
+- if (needs_extended_data) {
+- buf->extended_data = av_mallocz(avctx->channels *
+- sizeof(*buf->extended_data));
+- if (!buf->extended_data)
++ if (!buf->data[0]) {
++ if (!(buf->data[0] = av_mallocz(buf_size)))
+ return AVERROR(ENOMEM);
+- } else {
+- buf->extended_data = buf->data;
++ buf->audio_data_size = buf_size;
+ }
+-
+- /* if there is a previous buffer and it is large enough, reuse it and
+- just fill-in new channel pointers and linesize, otherwise allocate
+- a new buffer */
+- if (buf->extended_data[0]) {
+- ret = av_samples_fill_arrays(buf->extended_data, &buf->linesize[0],
+- buf->extended_data[0], avctx->channels,
+- frame->nb_samples, avctx->sample_fmt,
+- 32);
+- } else {
+- ret = av_samples_alloc(buf->extended_data, &buf->linesize[0],
+- avctx->channels, frame->nb_samples,
+- avctx->sample_fmt, 32);
+- }
+- if (ret)
++ if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
++ avctx->sample_fmt, buf->data[0],
++ buf->audio_data_size, 32)))
+ return ret;
+
+- /* if data was not used for extended_data, we need to copy as many of
+- the extended_data channel pointers as will fit */
+- if (needs_extended_data) {
+- for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
+- buf->data[i] = buf->extended_data[i];
+- }
+- buf->audio_data_size = buf_size;
+- buf->nb_channels = avctx->channels;
++ if (frame->extended_data == frame->data)
++ buf->extended_data = buf->data;
++ else
++ buf->extended_data = frame->extended_data;
++ memcpy(buf->data, frame->data, sizeof(frame->data));
++ buf->linesize[0] = frame->linesize[0];
++ buf->nb_channels = avctx->channels;
++ } else {
++ /* copy InternalBuffer info to the AVFrame */
++ frame->extended_data = buf->extended_data;
++ frame->linesize[0] = buf->linesize[0];
++ memcpy(frame->data, buf->data, sizeof(frame->data));
+ }
+
+- /* copy InternalBuffer info to the AVFrame */
+ frame->type = FF_BUFFER_TYPE_INTERNAL;
+- frame->extended_data = buf->extended_data;
+- frame->linesize[0] = buf->linesize[0];
+- memcpy(frame->data, buf->data, sizeof(frame->data));
+
+ if (avctx->pkt) frame->pkt_pts = avctx->pkt->pts;
+ else frame->pkt_pts = AV_NOPTS_VALUE;
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0057-avcodec-Add-avcodec_encode_audio2-as-replacement-for.patch b/debian/patches/post-0.8b2/0057-avcodec-Add-avcodec_encode_audio2-as-replacement-for.patch
new file mode 100644
index 0000000..0668d2e
--- /dev/null
+++ b/debian/patches/post-0.8b2/0057-avcodec-Add-avcodec_encode_audio2-as-replacement-for.patch
@@ -0,0 +1,526 @@
+From b2c75b6e6320b1a399d76913f9d98c56f386f98b Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Sun, 18 Dec 2011 13:20:15 -0500
+Subject: [PATCH 57/63] avcodec: Add avcodec_encode_audio2() as replacement
+ for avcodec_encode_audio()
+
+This allows audio encoders to optionally take an AVFrame as input and write
+encoded output to an AVPacket.
+
+This also adds AVCodec.encode2() which will also be usable by video and
+subtitle encoders once support is implemented in the public functions.
+---
+ libavcodec/avcodec.h | 72 ++++++++++++++-
+ libavcodec/internal.h | 25 +++++
+ libavcodec/pcm.c | 1 +
+ libavcodec/utils.c | 246 +++++++++++++++++++++++++++++++++++++++++++++----
+ libavcodec/version.h | 3 +
+ 5 files changed, 328 insertions(+), 19 deletions(-)
+
+diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
+index a5071aa..be1b202 100644
+--- a/libavcodec/avcodec.h
++++ b/libavcodec/avcodec.h
+@@ -741,6 +741,11 @@ typedef struct RcOverride{
+ * Encoders:
+ * The encoder needs to be fed with NULL data at the end of encoding until the
+ * encoder no longer returns data.
++ *
++ * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
++ * flag also means that the encoder must set the pts and duration for
++ * each output packet. If this flag is not set, the pts and duration will
++ * be determined by libavcodec from the input frame.
+ */
+ #define CODEC_CAP_DELAY 0x0020
+ /**
+@@ -793,6 +798,10 @@ typedef struct RcOverride{
+ * Codec supports avctx->thread_count == 0 (auto).
+ */
+ #define CODEC_CAP_AUTO_THREADS 0x8000
++/**
++ * Audio encoder supports receiving a different number of samples in each call.
++ */
++#define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
+
+ //The following defines may change, don't expect compatibility if you use them.
+ #define MB_TYPE_INTRA4x4 0x0001
+@@ -3246,6 +3255,19 @@ typedef struct AVCodec {
+ * Initialize codec static data, called from avcodec_register().
+ */
+ void (*init_static_data)(struct AVCodec *codec);
++
++ /**
++ * Encode data to an AVPacket.
++ *
++ * @param avctx codec context
++ * @param avpkt output AVPacket (may contain a user-provided buffer)
++ * @param[in] frame AVFrame containing the raw data to be encoded
++ * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
++ * non-empty packet was returned in avpkt.
++ * @return 0 on success, negative error code on failure
++ */
++ int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
++ int *got_packet_ptr);
+ } AVCodec;
+
+ /**
+@@ -4213,9 +4235,12 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
+ */
+ void avsubtitle_free(AVSubtitle *sub);
+
++#if FF_API_OLD_ENCODE_AUDIO
+ /**
+ * Encode an audio frame from samples into buf.
+ *
++ * @deprecated Use avcodec_encode_audio2 instead.
++ *
+ * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
+ * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
+ * will know how much space is needed because it depends on the value passed
+@@ -4235,8 +4260,51 @@ void avsubtitle_free(AVSubtitle *sub);
+ * @return On error a negative value is returned, on success zero or the number
+ * of bytes used to encode the data read from the input buffer.
+ */
+-int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
+- const short *samples);
++int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
++ uint8_t *buf, int buf_size,
++ const short *samples);
++#endif
++
++/**
++ * Encode a frame of audio.
++ *
++ * Takes input samples from frame and writes the next output packet, if
++ * available, to avpkt. The output packet does not necessarily contain data for
++ * the most recent frame, as encoders can delay, split, and combine input frames
++ * internally as needed.
++ *
++ * @param avctx codec context
++ * @param avpkt output AVPacket.
++ * The user can supply an output buffer by setting
++ * avpkt->data and avpkt->size prior to calling the
++ * function, but if the size of the user-provided data is not
++ * large enough, encoding will fail. All other AVPacket fields
++ * will be reset by the encoder using av_init_packet(). If
++ * avpkt->data is NULL, the encoder will allocate it.
++ * The encoder will set avpkt->size to the size of the
++ * output packet.
++ * @param[in] frame AVFrame containing the raw audio data to be encoded.
++ * May be NULL when flushing an encoder that has the
++ * CODEC_CAP_DELAY capability set.
++ * There are 2 codec capabilities that affect the allowed
++ * values of frame->nb_samples.
++ * If CODEC_CAP_SMALL_LAST_FRAME is set, then only the final
++ * frame may be smaller than avctx->frame_size, and all other
++ * frames must be equal to avctx->frame_size.
++ * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
++ * can have any number of samples.
++ * If neither is set, frame->nb_samples must be equal to
++ * avctx->frame_size for all frames.
++ * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
++ * output packet is non-empty, and to 0 if it is
++ * empty. If the function returns an error, the
++ * packet can be assumed to be invalid, and the
++ * value of got_packet_ptr is undefined and should
++ * not be used.
++ * @return 0 on success, negative error code on failure
++ */
++int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
++ const AVFrame *frame, int *got_packet_ptr);
+
+ /**
+ * Fill audio frame data and linesize.
+diff --git a/libavcodec/internal.h b/libavcodec/internal.h
+index 1c2d0da..441430e 100644
+--- a/libavcodec/internal.h
++++ b/libavcodec/internal.h
+@@ -61,6 +61,14 @@ typedef struct AVCodecInternal {
+ * should be freed from the original context only.
+ */
+ int is_copy;
++
++#if FF_API_OLD_DECODE_AUDIO
++ /**
++ * Internal sample count used by avcodec_encode_audio() to fabricate pts.
++ * Can be removed along with avcodec_encode_audio().
++ */
++ int sample_count;
++#endif
+ } AVCodecInternal;
+
+ struct AVCodecDefault {
+@@ -101,4 +109,21 @@ int avpriv_unlock_avformat(void);
+ */
+ #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE)
+
++/**
++ * Check AVPacket size and/or allocate data.
++ *
++ * Encoders supporting AVCodec.encode2() can use this as a convenience to
++ * ensure the output packet data is large enough, whether provided by the user
++ * or allocated in this function.
++ *
++ * @param avpkt the AVPacket
++ * If avpkt->data is already set, avpkt->size is checked
++ * to ensure it is large enough.
++ * If avpkt->data is NULL, a new buffer is allocated.
++ * All other AVPacket fields will be reset with av_init_packet().
++ * @param size the minimum required packet size
++ * @return 0 on success, negative error code on failure
++ */
++int ff_alloc_packet(AVPacket *avpkt, int size);
++
+ #endif /* AVCODEC_INTERNAL_H */
+diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
+index 3223112..190f027 100644
+--- a/libavcodec/pcm.c
++++ b/libavcodec/pcm.c
+@@ -474,6 +474,7 @@ AVCodec ff_ ## name_ ## _encoder = { \
+ .init = pcm_encode_init, \
+ .encode = pcm_encode_frame, \
+ .close = pcm_encode_close, \
++ .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \
+ .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
+ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
+ }
+diff --git a/libavcodec/utils.c b/libavcodec/utils.c
+index c3faa76..ff3f065 100644
+--- a/libavcodec/utils.c
++++ b/libavcodec/utils.c
+@@ -25,6 +25,7 @@
+ * utils.
+ */
+
++#include "libavutil/avassert.h"
+ #include "libavutil/avstring.h"
+ #include "libavutil/crc.h"
+ #include "libavutil/mathematics.h"
+@@ -101,6 +102,16 @@ void avcodec_init(void)
+ dsputil_static_init();
+ }
+
++static av_always_inline int codec_is_encoder(AVCodec *codec)
++{
++ return codec && (codec->encode || codec->encode2);
++}
++
++static av_always_inline int codec_is_decoder(AVCodec *codec)
++{
++ return codec && codec->decode;
++}
++
+ void avcodec_register(AVCodec *codec)
+ {
+ AVCodec **p;
+@@ -690,7 +701,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
+
+ /* if the decoder init function was already called previously,
+ free the already allocated subtitle_header before overwriting it */
+- if (codec->decode)
++ if (codec_is_decoder(codec))
+ av_freep(&avctx->subtitle_header);
+
+ #define SANE_NB_CHANNELS 128U
+@@ -738,7 +749,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
+ ret = AVERROR(EINVAL);
+ goto free_and_end;
+ }
+- if (avctx->codec->encode) {
++ if (codec_is_encoder(avctx->codec)) {
+ int i;
+ if (avctx->codec->sample_fmts) {
+ for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
+@@ -812,20 +823,221 @@ free_and_end:
+ goto end;
+ }
+
+-int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
+- const short *samples)
++int ff_alloc_packet(AVPacket *avpkt, int size)
+ {
+- if(buf_size < FF_MIN_BUFFER_SIZE && 0){
+- av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
+- return -1;
++ if (size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
++ return AVERROR(EINVAL);
++
++ if (avpkt->data) {
++ uint8_t *pkt_data;
++ int pkt_size;
++
++ if (avpkt->size < size)
++ return AVERROR(EINVAL);
++
++ pkt_data = avpkt->data;
++ pkt_size = avpkt->size;
++ av_init_packet(avpkt);
++ avpkt->data = pkt_data;
++ avpkt->size = pkt_size;
++ return 0;
++ } else {
++ return av_new_packet(avpkt, size);
+ }
+- if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){
+- int ret = avctx->codec->encode(avctx, buf, buf_size, samples);
+- avctx->frame_number++;
+- return ret;
+- }else
++}
++
++int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
++ AVPacket *avpkt,
++ const AVFrame *frame,
++ int *got_packet_ptr)
++{
++ int ret;
++ int user_packet = !!avpkt->data;
++ int nb_samples;
++
++ if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
++ av_init_packet(avpkt);
++ avpkt->size = 0;
+ return 0;
++ }
++
++ /* check for valid frame size */
++ if (frame) {
++ nb_samples = frame->nb_samples;
++ if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
++ if (nb_samples > avctx->frame_size)
++ return AVERROR(EINVAL);
++ } else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
++ if (nb_samples != avctx->frame_size)
++ return AVERROR(EINVAL);
++ }
++ } else {
++ nb_samples = avctx->frame_size;
++ }
++
++ if (avctx->codec->encode2) {
++ *got_packet_ptr = 0;
++ ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
++ if (!ret && *got_packet_ptr &&
++ !(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
++ avpkt->pts = frame->pts;
++ avpkt->duration = av_rescale_q(frame->nb_samples,
++ (AVRational){ 1, avctx->sample_rate },
++ avctx->time_base);
++ }
++ } else {
++ /* for compatibility with encoders not supporting encode2(), we need to
++ allocate a packet buffer if the user has not provided one or check
++ the size otherwise */
++ int fs_tmp = 0;
++ int buf_size = avpkt->size;
++ if (!user_packet) {
++ if (avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) {
++ av_assert0(av_get_bits_per_sample(avctx->codec_id) != 0);
++ buf_size = nb_samples * avctx->channels *
++ av_get_bits_per_sample(avctx->codec_id) / 8;
++ } else {
++ /* this is a guess as to the required size.
++ if an encoder needs more than this, it should probably
++ implement encode2() */
++ buf_size = 2 * avctx->frame_size * avctx->channels *
++ av_get_bytes_per_sample(avctx->sample_fmt);
++ buf_size += FF_MIN_BUFFER_SIZE;
++ }
++ }
++ if ((ret = ff_alloc_packet(avpkt, buf_size)))
++ return ret;
++
++ /* Encoders using AVCodec.encode() that support
++ CODEC_CAP_SMALL_LAST_FRAME require avctx->frame_size to be set to
++ the smaller size when encoding the last frame.
++ This code can be removed once all encoders supporting
++ CODEC_CAP_SMALL_LAST_FRAME use encode2() */
++ if ((avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) &&
++ nb_samples < avctx->frame_size) {
++ fs_tmp = avctx->frame_size;
++ avctx->frame_size = nb_samples;
++ }
++
++ /* encode the frame */
++ ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size,
++ frame ? frame->data[0] : NULL);
++ if (ret >= 0) {
++ if (!ret) {
++ /* no output. if the packet data was allocated by libavcodec,
++ free it */
++ if (!user_packet)
++ av_freep(&avpkt->data);
++ } else {
++ if (avctx->coded_frame)
++ avpkt->pts = avctx->coded_frame->pts;
++ /* Set duration for final small packet. This can be removed
++ once all encoders supporting CODEC_CAP_SMALL_LAST_FRAME use
++ encode2() */
++ if (fs_tmp) {
++ avpkt->duration = av_rescale_q(avctx->frame_size,
++ (AVRational){ 1, avctx->sample_rate },
++ avctx->time_base);
++ }
++ }
++ avpkt->size = ret;
++ *got_packet_ptr = (ret > 0);
++ ret = 0;
++ }
++
++ if (fs_tmp)
++ avctx->frame_size = fs_tmp;
++ }
++ if (!ret)
++ avctx->frame_number++;
++
++ /* NOTE: if we add any audio encoders which output non-keyframe packets,
++ this needs to be moved to the encoders, but for now we can do it
++ here to simplify things */
++ avpkt->flags |= AV_PKT_FLAG_KEY;
++
++ return ret;
++}
++
++#if FF_API_OLD_DECODE_AUDIO
++int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
++ uint8_t *buf, int buf_size,
++ const short *samples)
++{
++ AVPacket pkt;
++ AVFrame frame0;
++ AVFrame *frame;
++ int ret, samples_size, got_packet;
++
++ av_init_packet(&pkt);
++ pkt.data = buf;
++ pkt.size = buf_size;
++
++ if (samples) {
++ frame = &frame0;
++ avcodec_get_frame_defaults(frame);
++
++ if (avctx->frame_size) {
++ frame->nb_samples = avctx->frame_size;
++ } else {
++ /* if frame_size is not set, the number of samples must be
++ calculated from the buffer size */
++ int64_t nb_samples;
++ if (!av_get_bits_per_sample(avctx->codec_id)) {
++ av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
++ "support this codec\n");
++ return AVERROR(EINVAL);
++ }
++ nb_samples = (int64_t)buf_size * 8 /
++ (av_get_bits_per_sample(avctx->codec_id) *
++ avctx->channels);
++ if (nb_samples >= INT_MAX)
++ return AVERROR(EINVAL);
++ frame->nb_samples = nb_samples;
++ }
++
++ /* it is assumed that the samples buffer is large enough based on the
++ relevant parameters */
++ samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
++ frame->nb_samples,
++ avctx->sample_fmt, 1);
++ if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
++ avctx->sample_fmt,
++ samples, samples_size, 1)))
++ return ret;
++
++ /* fabricate frame pts from sample count.
++ this is needed because the avcodec_encode_audio() API does not have
++ a way for the user to provide pts */
++ frame->pts = av_rescale_q(avctx->internal->sample_count,
++ (AVRational){ 1, avctx->sample_rate },
++ avctx->time_base);
++ avctx->internal->sample_count += frame->nb_samples;
++ } else {
++ frame = NULL;
++ }
++
++ got_packet = 0;
++ ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
++ if (!ret && got_packet && avctx->coded_frame) {
++ avctx->coded_frame->pts = pkt.pts;
++ avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
++ }
++ /* free any side data since we cannot return it */
++ if (pkt.side_data_elems > 0) {
++ int i;
++ for (i = 0; i < pkt.side_data_elems; i++)
++ av_free(pkt.side_data[i].data);
++ av_freep(&pkt.side_data);
++ pkt.side_data_elems = 0;
++ }
++
++ if (frame && frame->extended_data != frame->data)
++ av_free(frame->extended_data);
++
++ return ret ? ret : pkt.size;
+ }
++#endif
+
+ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
+ const AVFrame *pict)
+@@ -1077,7 +1289,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
+ av_opt_free(avctx->priv_data);
+ av_opt_free(avctx);
+ av_freep(&avctx->priv_data);
+- if(avctx->codec && avctx->codec->encode)
++ if (codec_is_encoder(avctx->codec))
+ av_freep(&avctx->extradata);
+ avctx->codec = NULL;
+ avctx->active_thread_type = 0;
+@@ -1095,7 +1307,7 @@ AVCodec *avcodec_find_encoder(enum CodecID id)
+ AVCodec *p, *experimental=NULL;
+ p = first_avcodec;
+ while (p) {
+- if (p->encode != NULL && p->id == id) {
++ if (codec_is_encoder(p) && p->id == id) {
+ if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {
+ experimental = p;
+ } else
+@@ -1113,7 +1325,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name)
+ return NULL;
+ p = first_avcodec;
+ while (p) {
+- if (p->encode != NULL && strcmp(name,p->name) == 0)
++ if (codec_is_encoder(p) && strcmp(name,p->name) == 0)
+ return p;
+ p = p->next;
+ }
+@@ -1125,7 +1337,7 @@ AVCodec *avcodec_find_decoder(enum CodecID id)
+ AVCodec *p;
+ p = first_avcodec;
+ while (p) {
+- if (p->decode != NULL && p->id == id)
++ if (codec_is_decoder(p) && p->id == id)
+ return p;
+ p = p->next;
+ }
+@@ -1139,7 +1351,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name)
+ return NULL;
+ p = first_avcodec;
+ while (p) {
+- if (p->decode != NULL && strcmp(name,p->name) == 0)
++ if (codec_is_decoder(p) && strcmp(name,p->name) == 0)
+ return p;
+ p = p->next;
+ }
+diff --git a/libavcodec/version.h b/libavcodec/version.h
+index 87838c0..0b7547f 100644
+--- a/libavcodec/version.h
++++ b/libavcodec/version.h
+@@ -119,5 +119,8 @@
+ #ifndef FF_API_AVFRAME_AGE
+ #define FF_API_AVFRAME_AGE (LIBAVCODEC_VERSION_MAJOR < 54)
+ #endif
++#ifndef FF_API_OLD_ENCODE_AUDIO
++#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54)
++#endif
+
+ #endif /* AVCODEC_VERSION_H */
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0058-avcodec-bump-minor-version-and-add-APIChanges-for-th.patch b/debian/patches/post-0.8b2/0058-avcodec-bump-minor-version-and-add-APIChanges-for-th.patch
new file mode 100644
index 0000000..126b8aa
--- /dev/null
+++ b/debian/patches/post-0.8b2/0058-avcodec-bump-minor-version-and-add-APIChanges-for-th.patch
@@ -0,0 +1,46 @@
+From a6ccae3f4c17831d1e158c6cfeecbcf92f750b03 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Sun, 18 Dec 2011 19:47:38 -0500
+Subject: [PATCH 58/63] avcodec: bump minor version and add APIChanges for the
+ new audio encoding API
+
+---
+ doc/APIchanges | 8 ++++++++
+ libavcodec/version.h | 2 +-
+ 2 files changed, 9 insertions(+), 1 deletions(-)
+
+diff --git a/doc/APIchanges b/doc/APIchanges
+index 751566a..2d78324 100644
+--- a/doc/APIchanges
++++ b/doc/APIchanges
+@@ -13,6 +13,14 @@ libavutil: 2011-04-18
+
+ API changes, most recent first:
+
++2012-xx-xx - lavc 53.34.0
++ New audio encoding API:
++ xxxxxxx Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio
++ encoders.
++ xxxxxxx Add avcodec_fill_audio_frame() as a convenience function.
++ xxxxxxx Add avcodec_encode_audio2() and deprecate avcodec_encode_audio().
++ Add AVCodec.encode2().
++
+ 2012-01-xx - xxxxxxx - lavfi 2.15.0
+ Add a new installed header -- libavfilter/version.h -- with version macros.
+
+diff --git a/libavcodec/version.h b/libavcodec/version.h
+index 0b7547f..c7b4c15 100644
+--- a/libavcodec/version.h
++++ b/libavcodec/version.h
+@@ -21,7 +21,7 @@
+ #define AVCODEC_VERSION_H
+
+ #define LIBAVCODEC_VERSION_MAJOR 53
+-#define LIBAVCODEC_VERSION_MINOR 33
++#define LIBAVCODEC_VERSION_MINOR 34
+ #define LIBAVCODEC_VERSION_MICRO 0
+
+ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0059-pcmenc-use-AVCodec.encode2.patch b/debian/patches/post-0.8b2/0059-pcmenc-use-AVCodec.encode2.patch
new file mode 100644
index 0000000..ec23705
--- /dev/null
+++ b/debian/patches/post-0.8b2/0059-pcmenc-use-AVCodec.encode2.patch
@@ -0,0 +1,87 @@
+From 05f95443cac79eba959d7a1a919d77e8f401ea6f Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Sun, 8 Jan 2012 17:37:16 -0500
+Subject: [PATCH 59/63] pcmenc: use AVCodec.encode2()
+
+---
+ libavcodec/pcm.c | 27 +++++++++++++++++----------
+ 1 files changed, 17 insertions(+), 10 deletions(-)
+
+diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
+index 190f027..1adaf70 100644
+--- a/libavcodec/pcm.c
++++ b/libavcodec/pcm.c
+@@ -27,6 +27,7 @@
+ #include "avcodec.h"
+ #include "libavutil/common.h" /* for av_reverse */
+ #include "bytestream.h"
++#include "internal.h"
+ #include "pcm_tablegen.h"
+
+ #define MAX_CHANNELS 64
+@@ -77,10 +78,10 @@ static av_cold int pcm_encode_close(AVCodecContext *avctx)
+ bytestream_put_##endian(&dst, v); \
+ }
+
+-static int pcm_encode_frame(AVCodecContext *avctx,
+- unsigned char *frame, int buf_size, void *data)
++static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
++ const AVFrame *frame, int *got_packet_ptr)
+ {
+- int n, sample_size, v;
++ int n, sample_size, v, ret;
+ const short *samples;
+ unsigned char *dst;
+ const uint8_t *srcu8;
+@@ -91,9 +92,14 @@ static int pcm_encode_frame(AVCodecContext *avctx,
+ const uint32_t *samples_uint32_t;
+
+ sample_size = av_get_bits_per_sample(avctx->codec->id)/8;
+- n = buf_size / sample_size;
+- samples = data;
+- dst = frame;
++ n = frame->nb_samples * avctx->channels;
++ samples = (const short *)frame->data[0];
++
++ if ((ret = ff_alloc_packet(avpkt, n * sample_size))) {
++ av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
++ return ret;
++ }
++ dst = avpkt->data;
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_U32LE:
+@@ -130,7 +136,7 @@ static int pcm_encode_frame(AVCodecContext *avctx,
+ ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000)
+ break;
+ case CODEC_ID_PCM_S8:
+- srcu8= data;
++ srcu8 = frame->data[0];
+ for(;n>0;n--) {
+ v = *srcu8++;
+ *dst++ = v - 128;
+@@ -186,9 +192,10 @@ static int pcm_encode_frame(AVCodecContext *avctx,
+ default:
+ return -1;
+ }
+- //avctx->frame_size = (dst - frame) / (sample_size * avctx->channels);
+
+- return dst - frame;
++ avpkt->size = frame->nb_samples * avctx->channels * sample_size;
++ *got_packet_ptr = 1;
++ return 0;
+ }
+
+ typedef struct PCMDecode {
+@@ -472,7 +479,7 @@ AVCodec ff_ ## name_ ## _encoder = { \
+ .type = AVMEDIA_TYPE_AUDIO, \
+ .id = id_, \
+ .init = pcm_encode_init, \
+- .encode = pcm_encode_frame, \
++ .encode2 = pcm_encode_frame, \
+ .close = pcm_encode_close, \
+ .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \
+ .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0060-avconv-use-avcodec_encode_audio2.patch b/debian/patches/post-0.8b2/0060-avconv-use-avcodec_encode_audio2.patch
new file mode 100644
index 0000000..e7a9042
--- /dev/null
+++ b/debian/patches/post-0.8b2/0060-avconv-use-avcodec_encode_audio2.patch
@@ -0,0 +1,331 @@
+From ee458cb1fa3faa006785d725fb3e386174793000 Mon Sep 17 00:00:00 2001
+From: Justin Ruggles <justin.ruggles at gmail.com>
+Date: Sat, 31 Dec 2011 09:36:25 -0500
+Subject: [PATCH 60/63] avconv: use avcodec_encode_audio2()
+
+---
+ avconv.c | 205 ++++++++++++++++++++++++++++++++------------------------------
+ 1 files changed, 105 insertions(+), 100 deletions(-)
+
+diff --git a/avconv.c b/avconv.c
+index 817c0cf..2246851 100644
+--- a/avconv.c
++++ b/avconv.c
+@@ -141,8 +141,7 @@ static float dts_delta_threshold = 10;
+ static int print_stats = 1;
+
+ static uint8_t *audio_buf;
+-static uint8_t *audio_out;
+-static unsigned int allocated_audio_out_size, allocated_audio_buf_size;
++static unsigned int allocated_audio_buf_size;
+
+ #define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
+
+@@ -208,6 +207,7 @@ typedef struct OutputStream {
+ AVBitStreamFilterContext *bitstream_filters;
+ AVCodec *enc;
+ int64_t max_frames;
++ AVFrame *output_frame;
+
+ /* video only */
+ int video_resample;
+@@ -680,6 +680,13 @@ void exit_program(int ret)
+ }
+ output_streams[i].bitstream_filters = NULL;
+
++ if (output_streams[i].output_frame) {
++ AVFrame *frame = output_streams[i].output_frame;
++ if (frame->extended_data != frame->data)
++ av_freep(&frame->extended_data);
++ av_freep(&frame);
++ }
++
+ #if CONFIG_AVFILTER
+ av_freep(&output_streams[i].avfilter);
+ #endif
+@@ -705,8 +712,7 @@ void exit_program(int ret)
+
+ uninit_opts();
+ av_free(audio_buf);
+- av_free(audio_out);
+- allocated_audio_buf_size = allocated_audio_out_size = 0;
++ allocated_audio_buf_size = 0;
+
+ #if CONFIG_AVFILTER
+ avfilter_uninit();
+@@ -907,18 +913,75 @@ static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_
+ memset(buf, fill_char, size);
+ }
+
++static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,
++ const uint8_t *buf, int buf_size)
++{
++ AVCodecContext *enc = ost->st->codec;
++ AVFrame *frame = NULL;
++ AVPacket pkt;
++ int ret, got_packet;
++
++ av_init_packet(&pkt);
++ pkt.data = NULL;
++ pkt.size = 0;
++
++ if (buf) {
++ if (!ost->output_frame) {
++ ost->output_frame = avcodec_alloc_frame();
++ if (!ost->output_frame) {
++ av_log(NULL, AV_LOG_FATAL, "out-of-memory in encode_audio_frame()\n");
++ exit_program(1);
++ }
++ }
++ frame = ost->output_frame;
++ if (frame->extended_data != frame->data)
++ av_freep(&frame->extended_data);
++ avcodec_get_frame_defaults(frame);
++
++ frame->nb_samples = buf_size /
++ (enc->channels * av_get_bytes_per_sample(enc->sample_fmt));
++ if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt,
++ buf, buf_size, 1)) < 0) {
++ av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
++ exit_program(1);
++ }
++ }
++
++ got_packet = 0;
++ if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) {
++ av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
++ exit_program(1);
++ }
++
++ if (got_packet) {
++ pkt.stream_index = ost->index;
++ if (pkt.pts != AV_NOPTS_VALUE)
++ pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
++ if (pkt.duration > 0)
++ pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
++
++ write_frame(s, &pkt, ost);
++
++ audio_size += pkt.size;
++ }
++
++ if (frame)
++ ost->sync_opts += frame->nb_samples;
++
++ return pkt.size;
++}
++
+ static void do_audio_out(AVFormatContext *s, OutputStream *ost,
+ InputStream *ist, AVFrame *decoded_frame)
+ {
+ uint8_t *buftmp;
+- int64_t audio_out_size, audio_buf_size;
++ int64_t audio_buf_size;
+
+- int size_out, frame_bytes, ret, resample_changed;
++ int size_out, frame_bytes, resample_changed;
+ AVCodecContext *enc = ost->st->codec;
+ AVCodecContext *dec = ist->st->codec;
+ int osize = av_get_bytes_per_sample(enc->sample_fmt);
+ int isize = av_get_bytes_per_sample(dec->sample_fmt);
+- const int coded_bps = av_get_bits_per_sample(enc->codec->id);
+ uint8_t *buf = decoded_frame->data[0];
+ int size = decoded_frame->nb_samples * dec->channels * isize;
+ int64_t allocated_for_size = size;
+@@ -930,19 +993,13 @@ need_realloc:
+ audio_buf_size = FFMAX(audio_buf_size, enc->frame_size);
+ audio_buf_size *= osize * enc->channels;
+
+- audio_out_size = FFMAX(audio_buf_size, enc->frame_size * osize * enc->channels);
+- if (coded_bps > 8 * osize)
+- audio_out_size = audio_out_size * coded_bps / (8*osize);
+- audio_out_size += FF_MIN_BUFFER_SIZE;
+-
+- if (audio_out_size > INT_MAX || audio_buf_size > INT_MAX) {
++ if (audio_buf_size > INT_MAX) {
+ av_log(NULL, AV_LOG_FATAL, "Buffer sizes too large\n");
+ exit_program(1);
+ }
+
+ av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size);
+- av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size);
+- if (!audio_buf || !audio_out) {
++ if (!audio_buf) {
+ av_log(NULL, AV_LOG_FATAL, "Out of memory in do_audio_out\n");
+ exit_program(1);
+ }
+@@ -1080,7 +1137,7 @@ need_realloc:
+ }
+
+ /* now encode as many frames as possible */
+- if (enc->frame_size > 1) {
++ if (!(enc->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
+ /* output resampled raw samples */
+ if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "av_fifo_realloc2() failed\n");
+@@ -1091,62 +1148,11 @@ need_realloc:
+ frame_bytes = enc->frame_size * osize * enc->channels;
+
+ while (av_fifo_size(ost->fifo) >= frame_bytes) {
+- AVPacket pkt;
+- av_init_packet(&pkt);
+-
+ av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
+-
+- // FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
+-
+- ret = avcodec_encode_audio(enc, audio_out, audio_out_size,
+- (short *)audio_buf);
+- if (ret < 0) {
+- av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
+- exit_program(1);
+- }
+- audio_size += ret;
+- pkt.stream_index = ost->index;
+- pkt.data = audio_out;
+- pkt.size = ret;
+- if (enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
+- pkt.pts = av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
+- pkt.flags |= AV_PKT_FLAG_KEY;
+- write_frame(s, &pkt, ost);
+-
+- ost->sync_opts += enc->frame_size;
++ encode_audio_frame(s, ost, audio_buf, frame_bytes);
+ }
+ } else {
+- AVPacket pkt;
+- av_init_packet(&pkt);
+-
+- ost->sync_opts += size_out / (osize * enc->channels);
+-
+- /* output a pcm frame */
+- /* determine the size of the coded buffer */
+- size_out /= osize;
+- if (coded_bps)
+- size_out = size_out * coded_bps / 8;
+-
+- if (size_out > audio_out_size) {
+- av_log(NULL, AV_LOG_FATAL, "Internal error, buffer size too small\n");
+- exit_program(1);
+- }
+-
+- // FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
+- ret = avcodec_encode_audio(enc, audio_out, size_out,
+- (short *)buftmp);
+- if (ret < 0) {
+- av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
+- exit_program(1);
+- }
+- audio_size += ret;
+- pkt.stream_index = ost->index;
+- pkt.data = audio_out;
+- pkt.size = ret;
+- if (enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
+- pkt.pts = av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
+- pkt.flags |= AV_PKT_FLAG_KEY;
+- write_frame(s, &pkt, ost);
++ encode_audio_frame(s, ost, buftmp, size_out);
+ }
+ }
+
+@@ -1620,6 +1626,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
+ OutputStream *ost = &ost_table[i];
+ AVCodecContext *enc = ost->st->codec;
+ AVFormatContext *os = output_files[ost->file_index].ctx;
++ int stop_encoding = 0;
+
+ if (!ost->encoding_needed)
+ continue;
+@@ -1633,41 +1640,35 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
+ AVPacket pkt;
+ int fifo_bytes;
+ av_init_packet(&pkt);
+- pkt.stream_index = ost->index;
++ pkt.data = NULL;
++ pkt.size = 0;
+
+ switch (ost->st->codec->codec_type) {
+ case AVMEDIA_TYPE_AUDIO:
+ fifo_bytes = av_fifo_size(ost->fifo);
+- ret = 0;
+- /* encode any samples remaining in fifo */
+ if (fifo_bytes > 0) {
+- int osize = av_get_bytes_per_sample(enc->sample_fmt);
+- int fs_tmp = enc->frame_size;
++ /* encode any samples remaining in fifo */
++ int frame_bytes = fifo_bytes;
+
+ av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL);
+- if (enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
+- enc->frame_size = fifo_bytes / (osize * enc->channels);
+- } else { /* pad */
+- int frame_bytes = enc->frame_size*osize*enc->channels;
++
++ /* pad last frame with silence if needed */
++ if (!(enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME)) {
++ frame_bytes = enc->frame_size * enc->channels *
++ av_get_bytes_per_sample(enc->sample_fmt);
+ if (allocated_audio_buf_size < frame_bytes)
+ exit_program(1);
+ generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes);
+ }
+-
+- ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, (short *)audio_buf);
+- pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den,
+- ost->st->time_base.num, enc->sample_rate);
+- enc->frame_size = fs_tmp;
+- }
+- if (ret <= 0) {
+- ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
+- }
+- if (ret < 0) {
+- av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
+- exit_program(1);
++ encode_audio_frame(os, ost, audio_buf, frame_bytes);
++ } else {
++ /* flush encoder with NULL frames until it is done
++ returning packets */
++ if (encode_audio_frame(os, ost, NULL, 0) == 0) {
++ stop_encoding = 1;
++ break;
++ }
+ }
+- audio_size += ret;
+- pkt.flags |= AV_PKT_FLAG_KEY;
+ break;
+ case AVMEDIA_TYPE_VIDEO:
+ ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL);
+@@ -1681,18 +1682,22 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
+ if (ost->logfile && enc->stats_out) {
+ fprintf(ost->logfile, "%s", enc->stats_out);
+ }
++ if (ret <= 0) {
++ stop_encoding = 1;
++ break;
++ }
++ pkt.stream_index = ost->index;
++ pkt.data = bit_buffer;
++ pkt.size = ret;
++ if (enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
++ pkt.pts = av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
++ write_frame(os, &pkt, ost);
+ break;
+ default:
+- ret = -1;
++ stop_encoding = 1;
+ }
+-
+- if (ret <= 0)
++ if (stop_encoding)
+ break;
+- pkt.data = bit_buffer;
+- pkt.size = ret;
+- if (enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
+- pkt.pts = av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
+- write_frame(os, &pkt, ost);
+ }
+ }
+ }
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0061-pictordec-Use-bytestream2-functions.patch b/debian/patches/post-0.8b2/0061-pictordec-Use-bytestream2-functions.patch
new file mode 100644
index 0000000..33633fe
--- /dev/null
+++ b/debian/patches/post-0.8b2/0061-pictordec-Use-bytestream2-functions.patch
@@ -0,0 +1,191 @@
+From d859191322d8596b6d4219269db96456267f0d04 Mon Sep 17 00:00:00 2001
+From: Laurentiu Ion <ionlaurentiucristian at gmail.com>
+Date: Mon, 16 Jan 2012 04:47:07 +0200
+Subject: [PATCH 61/63] pictordec: Use bytestream2 functions
+
+Signed-off-by: Justin Ruggles <justin.ruggles at gmail.com>
+---
+ libavcodec/pictordec.c | 99 +++++++++++++++++++++++++++---------------------
+ 1 files changed, 56 insertions(+), 43 deletions(-)
+
+diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
+index 732583e..e0bc899 100644
+--- a/libavcodec/pictordec.c
++++ b/libavcodec/pictordec.c
+@@ -33,6 +33,7 @@ typedef struct PicContext {
+ AVFrame frame;
+ int width, height;
+ int nb_planes;
++ GetByteContext g;
+ } PicContext;
+
+ static void picmemset_8bpp(PicContext *s, int value, int run, int *x, int *y)
+@@ -55,7 +56,8 @@ static void picmemset_8bpp(PicContext *s, int value, int run, int *x, int *y)
+ }
+ }
+
+-static void picmemset(PicContext *s, int value, int run, int *x, int *y, int *plane, int bits_per_plane)
++static void picmemset(PicContext *s, int value, int run,
++ int *x, int *y, int *plane, int bits_per_plane)
+ {
+ uint8_t *d;
+ int shift = *plane * bits_per_plane;
+@@ -99,34 +101,35 @@ static int decode_frame(AVCodecContext *avctx,
+ AVPacket *avpkt)
+ {
+ PicContext *s = avctx->priv_data;
+- int buf_size = avpkt->size;
+- const uint8_t *buf = avpkt->data;
+- const uint8_t *buf_end = avpkt->data + buf_size;
+ uint32_t *palette;
+- int bits_per_plane, bpp, etype, esize, npal;
+- int i, x, y, plane;
++ int bits_per_plane, bpp, etype, esize, npal, pos_after_pal;
++ int i, x, y, plane, tmp;
+
+- if (buf_size < 11)
++ bytestream2_init(&s->g, avpkt->data, avpkt->size);
++
++ if (bytestream2_get_bytes_left(&s->g) < 11)
+ return AVERROR_INVALIDDATA;
+
+- if (bytestream_get_le16(&buf) != 0x1234)
++ if (bytestream2_get_le16u(&s->g) != 0x1234)
+ return AVERROR_INVALIDDATA;
+- s->width = bytestream_get_le16(&buf);
+- s->height = bytestream_get_le16(&buf);
+- buf += 4;
+- bits_per_plane = *buf & 0xF;
+- s->nb_planes = (*buf++ >> 4) + 1;
+- bpp = s->nb_planes ? bits_per_plane*s->nb_planes : bits_per_plane;
++
++ s->width = bytestream2_get_le16u(&s->g);
++ s->height = bytestream2_get_le16u(&s->g);
++ bytestream2_skip(&s->g, 4);
++ tmp = bytestream2_get_byteu(&s->g);
++ bits_per_plane = tmp & 0xF;
++ s->nb_planes = (tmp >> 4) + 1;
++ bpp = bits_per_plane * s->nb_planes;
+ if (bits_per_plane > 8 || bpp < 1 || bpp > 32) {
+ av_log_ask_for_sample(s, "unsupported bit depth\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+- if (*buf == 0xFF) {
+- buf += 2;
+- etype = bytestream_get_le16(&buf);
+- esize = bytestream_get_le16(&buf);
+- if (buf_end - buf < esize)
++ if (bytestream2_peek_byte(&s->g) == 0xFF) {
++ bytestream2_skip(&s->g, 2);
++ etype = bytestream2_get_le16(&s->g);
++ esize = bytestream2_get_le16(&s->g);
++ if (bytestream2_get_bytes_left(&s->g) < esize)
+ return AVERROR_INVALIDDATA;
+ } else {
+ etype = -1;
+@@ -151,24 +154,29 @@ static int decode_frame(AVCodecContext *avctx,
+ s->frame.pict_type = AV_PICTURE_TYPE_I;
+ s->frame.palette_has_changed = 1;
+
++ pos_after_pal = bytestream2_tell(&s->g) + esize;
+ palette = (uint32_t*)s->frame.data[1];
+- if (etype == 1 && esize > 1 && *buf < 6) {
+- int idx = *buf;
++ if (etype == 1 && esize > 1 && bytestream2_peek_byte(&s->g) < 6) {
++ int idx = bytestream2_get_byte(&s->g);
+ npal = 4;
+ for (i = 0; i < npal; i++)
+ palette[i] = ff_cga_palette[ cga_mode45_index[idx][i] ];
+ } else if (etype == 2) {
+ npal = FFMIN(esize, 16);
+- for (i = 0; i < npal; i++)
+- palette[i] = ff_cga_palette[ FFMIN(buf[i], 16)];
++ for (i = 0; i < npal; i++) {
++ int pal_idx = bytestream2_get_byte(&s->g);
++ palette[i] = ff_cga_palette[FFMIN(pal_idx, 16)];
++ }
+ } else if (etype == 3) {
+ npal = FFMIN(esize, 16);
+- for (i = 0; i < npal; i++)
+- palette[i] = ff_ega_palette[ FFMIN(buf[i], 63)];
++ for (i = 0; i < npal; i++) {
++ int pal_idx = bytestream2_get_byte(&s->g);
++ palette[i] = ff_ega_palette[FFMIN(pal_idx, 63)];
++ }
+ } else if (etype == 4 || etype == 5) {
+ npal = FFMIN(esize / 3, 256);
+ for (i = 0; i < npal; i++)
+- palette[i] = AV_RB24(buf + i*3) << 2;
++ palette[i] = bytestream2_get_be24(&s->g) << 2;
+ } else {
+ if (bpp == 1) {
+ npal = 2;
+@@ -185,29 +193,34 @@ static int decode_frame(AVCodecContext *avctx,
+ }
+ // fill remaining palette entries
+ memset(palette + npal, 0, AVPALETTE_SIZE - npal * 4);
+- buf += esize;
+-
++ // skip remaining palette bytes
++ bytestream2_seek(&s->g, pos_after_pal, SEEK_SET);
+
+ x = 0;
+ y = s->height - 1;
+ plane = 0;
+- if (bytestream_get_le16(&buf)) {
+- while (buf_end - buf >= 6) {
+- const uint8_t *buf_pend = buf + FFMIN(AV_RL16(buf), buf_end - buf);
+- //ignore uncompressed block size reported at buf[2]
+- int marker = buf[4];
+- buf += 5;
+-
+- while (plane < s->nb_planes && buf_pend - buf >= 1) {
++ if (bytestream2_get_le16(&s->g)) {
++ while (bytestream2_get_bytes_left(&s->g) >= 6) {
++ int stop_size, marker, t1, t2;
++
++ t1 = bytestream2_get_bytes_left(&s->g);
++ t2 = bytestream2_get_le16(&s->g);
++ stop_size = t1 - FFMIN(t1, t2);
++ // ignore uncompressed block size
++ bytestream2_skip(&s->g, 2);
++ marker = bytestream2_get_byte(&s->g);
++
++ while (plane < s->nb_planes &&
++ bytestream2_get_bytes_left(&s->g) > stop_size) {
+ int run = 1;
+- int val = *buf++;
++ int val = bytestream2_get_byte(&s->g);
+ if (val == marker) {
+- run = *buf++;
++ run = bytestream2_get_byte(&s->g);
+ if (run == 0)
+- run = bytestream_get_le16(&buf);
+- val = *buf++;
++ run = bytestream2_get_le16(&s->g);
++ val = bytestream2_get_byte(&s->g);
+ }
+- if (buf > buf_end)
++ if (!bytestream2_get_bytes_left(&s->g))
+ break;
+
+ if (bits_per_plane == 8) {
+@@ -221,12 +234,12 @@ static int decode_frame(AVCodecContext *avctx,
+ }
+ } else {
+ av_log_ask_for_sample(s, "uncompressed image\n");
+- return buf_size;
++ return avpkt->size;
+ }
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+- return buf_size;
++ return avpkt->size;
+ }
+
+ static av_cold int decode_end(AVCodecContext *avctx)
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0062-avformat-split-out-common-SMJPEG-code.patch b/debian/patches/post-0.8b2/0062-avformat-split-out-common-SMJPEG-code.patch
new file mode 100644
index 0000000..2538ac5
--- /dev/null
+++ b/debian/patches/post-0.8b2/0062-avformat-split-out-common-SMJPEG-code.patch
@@ -0,0 +1,452 @@
+From 68b94f8bc3a54735c360c6e72a3698fed8aba10b Mon Sep 17 00:00:00 2001
+From: Paul B Mahol <onemda at gmail.com>
+Date: Sat, 14 Jan 2012 16:47:07 +0000
+Subject: [PATCH 62/63] avformat: split out common SMJPEG code
+
+This is a preparation for adding SMJPEG muxer.
+
+Signed-off-by: Kostya Shishkov <kostya.shishkov at gmail.com>
+---
+ libavformat/Makefile | 2 +-
+ libavformat/smjpeg.c | 159 ++----------------------------------------
+ libavformat/smjpeg.h | 45 ++++++++++++
+ libavformat/smjpegdec.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 229 insertions(+), 154 deletions(-)
+ create mode 100644 libavformat/smjpeg.h
+ create mode 100644 libavformat/smjpegdec.c
+
+diff --git a/libavformat/Makefile b/libavformat/Makefile
+index 3902e89..3e0808a 100644
+--- a/libavformat/Makefile
++++ b/libavformat/Makefile
+@@ -274,7 +274,7 @@ OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o
+ OBJS-$(CONFIG_SHORTEN_DEMUXER) += rawdec.o
+ OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o
+ OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o
+-OBJS-$(CONFIG_SMJPEG_DEMUXER) += smjpeg.o
++OBJS-$(CONFIG_SMJPEG_DEMUXER) += smjpegdec.o smjpeg.o
+ OBJS-$(CONFIG_SOL_DEMUXER) += sol.o pcm.o
+ OBJS-$(CONFIG_SOX_DEMUXER) += soxdec.o pcm.o
+ OBJS-$(CONFIG_SOX_MUXER) += soxenc.o
+diff --git a/libavformat/smjpeg.c b/libavformat/smjpeg.c
+index dc94361..573a8a3 100644
+--- a/libavformat/smjpeg.c
++++ b/libavformat/smjpeg.c
+@@ -1,6 +1,6 @@
+ /*
+- * SMJPEG demuxer
+- * Copyright (c) 2011 Paul B Mahol
++ * SMJPEG common code
++ * Copyright (c) 2011-2012 Paul B Mahol
+ *
+ * This file is part of Libav.
+ *
+@@ -21,167 +21,20 @@
+
+ /**
+ * @file
+- * This is a demuxer for Loki SDL Motion JPEG files
++ * SMJPEG common code
+ */
+
+ #include "avformat.h"
+ #include "internal.h"
+-#include "riff.h"
++#include "smjpeg.h"
+
+-static const AVCodecTag codec_smjpeg_video_tags[] = {
++const AVCodecTag ff_codec_smjpeg_video_tags[] = {
+ { CODEC_ID_MJPEG, MKTAG('J', 'F', 'I', 'F') },
+ { CODEC_ID_NONE, 0 },
+ };
+
+-static const AVCodecTag codec_smjpeg_audio_tags[] = {
++const AVCodecTag ff_codec_smjpeg_audio_tags[] = {
+ { CODEC_ID_ADPCM_IMA_SMJPEG, MKTAG('A', 'P', 'C', 'M') },
+ { CODEC_ID_PCM_S16LE, MKTAG('N', 'O', 'N', 'E') },
+ { CODEC_ID_NONE, 0 },
+ };
+-
+-typedef struct SMJPEGContext {
+- int audio_stream_index;
+- int video_stream_index;
+-} SMJPEGContext;
+-
+-static int smjpeg_probe(AVProbeData *p)
+-{
+- if (!memcmp(p->buf, "\x0\xaSMJPEG", 8))
+- return AVPROBE_SCORE_MAX;
+- return 0;
+-}
+-
+-static int smjpeg_read_header(AVFormatContext *s, AVFormatParameters *ap)
+-{
+- SMJPEGContext *sc = s->priv_data;
+- AVStream *ast = NULL, *vst = NULL;
+- AVIOContext *pb = s->pb;
+- uint32_t version, htype, hlength, duration;
+- char *comment;
+-
+- avio_skip(pb, 8); // magic
+- version = avio_rb32(pb);
+- if (version)
+- av_log_ask_for_sample(s, "unknown version %d\n", version);
+-
+- duration = avio_rb32(pb); // in msec
+-
+- while (!pb->eof_reached) {
+- htype = avio_rl32(pb);
+- switch (htype) {
+- case MKTAG('_', 'T', 'X', 'T'):
+- hlength = avio_rb32(pb);
+- if (!hlength || hlength > 512)
+- return AVERROR_INVALIDDATA;
+- comment = av_malloc(hlength + 1);
+- if (!comment)
+- return AVERROR(ENOMEM);
+- if (avio_read(pb, comment, hlength) != hlength) {
+- av_freep(&comment);
+- av_log(s, AV_LOG_ERROR, "error when reading comment\n");
+- return AVERROR_INVALIDDATA;
+- }
+- comment[hlength] = 0;
+- av_dict_set(&s->metadata, "comment", comment,
+- AV_DICT_DONT_STRDUP_VAL);
+- break;
+- case MKTAG('_', 'S', 'N', 'D'):
+- if (ast) {
+- av_log_ask_for_sample(s, "multiple audio streams not supported\n");
+- return AVERROR_INVALIDDATA;
+- }
+- hlength = avio_rb32(pb);
+- if (hlength < 8)
+- return AVERROR_INVALIDDATA;
+- ast = avformat_new_stream(s, 0);
+- if (!ast)
+- return AVERROR(ENOMEM);
+- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+- ast->codec->sample_rate = avio_rb16(pb);
+- ast->codec->bits_per_coded_sample = avio_r8(pb);
+- ast->codec->channels = avio_r8(pb);
+- ast->codec->codec_tag = avio_rl32(pb);
+- ast->codec->codec_id = ff_codec_get_id(codec_smjpeg_audio_tags,
+- ast->codec->codec_tag);
+- ast->duration = duration;
+- sc->audio_stream_index = ast->index;
+- avpriv_set_pts_info(ast, 32, 1, 1000);
+- avio_skip(pb, hlength - 8);
+- break;
+- case MKTAG('_', 'V', 'I', 'D'):
+- if (vst) {
+- av_log_ask_for_sample(s, "multiple video streams not supported\n");
+- return AVERROR_INVALIDDATA;
+- }
+- hlength = avio_rb32(pb);
+- if (hlength < 12)
+- return AVERROR_INVALIDDATA;
+- avio_skip(pb, 4); // number of frames
+- vst = avformat_new_stream(s, 0);
+- if (!vst)
+- return AVERROR(ENOMEM);
+- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+- vst->codec->width = avio_rb16(pb);
+- vst->codec->height = avio_rb16(pb);
+- vst->codec->codec_tag = avio_rl32(pb);
+- vst->codec->codec_id = ff_codec_get_id(codec_smjpeg_video_tags,
+- vst->codec->codec_tag);
+- vst->duration = duration;
+- sc->video_stream_index = vst->index;
+- avpriv_set_pts_info(vst, 32, 1, 1000);
+- avio_skip(pb, hlength - 12);
+- break;
+- case MKTAG('H', 'E', 'N', 'D'):
+- return 0;
+- default:
+- av_log(s, AV_LOG_ERROR, "unknown header %x\n", htype);
+- return AVERROR_INVALIDDATA;
+- }
+- }
+-
+- return AVERROR_EOF;
+-}
+-
+-static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
+-{
+- SMJPEGContext *sc = s->priv_data;
+- uint32_t dtype, ret, size, timestamp;
+-
+- if (s->pb->eof_reached)
+- return AVERROR_EOF;
+- dtype = avio_rl32(s->pb);
+- switch (dtype) {
+- case MKTAG('s', 'n', 'd', 'D'):
+- timestamp = avio_rb32(s->pb);
+- size = avio_rb32(s->pb);
+- ret = av_get_packet(s->pb, pkt, size);
+- pkt->stream_index = sc->audio_stream_index;
+- pkt->pts = timestamp;
+- break;
+- case MKTAG('v', 'i', 'd', 'D'):
+- timestamp = avio_rb32(s->pb);
+- size = avio_rb32(s->pb);
+- ret = av_get_packet(s->pb, pkt, size);
+- pkt->stream_index = sc->video_stream_index;
+- pkt->pts = timestamp;
+- break;
+- case MKTAG('D', 'O', 'N', 'E'):
+- ret = AVERROR_EOF;
+- break;
+- default:
+- av_log(s, AV_LOG_ERROR, "unknown chunk %x\n", dtype);
+- ret = AVERROR_INVALIDDATA;
+- break;
+- }
+- return ret;
+-}
+-
+-AVInputFormat ff_smjpeg_demuxer = {
+- .name = "smjpeg",
+- .long_name = NULL_IF_CONFIG_SMALL("Loki SDL MJPEG"),
+- .priv_data_size = sizeof(SMJPEGContext),
+- .read_probe = smjpeg_probe,
+- .read_header = smjpeg_read_header,
+- .read_packet = smjpeg_read_packet,
+- .extensions = "mjpg",
+-};
+diff --git a/libavformat/smjpeg.h b/libavformat/smjpeg.h
+new file mode 100644
+index 0000000..c56fe46
+--- /dev/null
++++ b/libavformat/smjpeg.h
+@@ -0,0 +1,45 @@
++/*
++ * SMJPEG common code
++ * Copyright (c) 2011-2012 Paul B Mahol
++ *
++ * 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
++ */
++
++/**
++ * @file
++ * SMJPEG common code
++ */
++
++#ifndef AVFORMAT_SMJPEG_H
++#define AVFORMAT_SMJPEG_H
++
++#include "internal.h"
++
++#define SMJPEG_MAGIC "\x0\xaSMJPEG"
++
++#define SMJPEG_DONE MKTAG('D', 'O', 'N', 'E')
++#define SMJPEG_HEND MKTAG('H', 'E', 'N', 'D')
++#define SMJPEG_SND MKTAG('_', 'S', 'N', 'D')
++#define SMJPEG_SNDD MKTAG('s', 'n', 'd', 'D')
++#define SMJPEG_TXT MKTAG('_', 'T', 'X', 'T')
++#define SMJPEG_VID MKTAG('_', 'V', 'I', 'D')
++#define SMJPEG_VIDD MKTAG('v', 'i', 'd', 'D')
++
++extern const AVCodecTag ff_codec_smjpeg_video_tags[];
++extern const AVCodecTag ff_codec_smjpeg_audio_tags[];
++
++#endif /* AVFORMAT_SMJPEG_H */
+diff --git a/libavformat/smjpegdec.c b/libavformat/smjpegdec.c
+new file mode 100644
+index 0000000..d7ff979
+--- /dev/null
++++ b/libavformat/smjpegdec.c
+@@ -0,0 +1,177 @@
++/*
++ * SMJPEG demuxer
++ * Copyright (c) 2011 Paul B Mahol
++ *
++ * 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
++ */
++
++/**
++ * @file
++ * This is a demuxer for Loki SDL Motion JPEG files
++ */
++
++#include "avformat.h"
++#include "internal.h"
++#include "riff.h"
++#include "smjpeg.h"
++
++typedef struct SMJPEGContext {
++ int audio_stream_index;
++ int video_stream_index;
++} SMJPEGContext;
++
++static int smjpeg_probe(AVProbeData *p)
++{
++ if (!memcmp(p->buf, SMJPEG_MAGIC, 8))
++ return AVPROBE_SCORE_MAX;
++ return 0;
++}
++
++static int smjpeg_read_header(AVFormatContext *s, AVFormatParameters *ap)
++{
++ SMJPEGContext *sc = s->priv_data;
++ AVStream *ast = NULL, *vst = NULL;
++ AVIOContext *pb = s->pb;
++ uint32_t version, htype, hlength, duration;
++ char *comment;
++
++ avio_skip(pb, 8); // magic
++ version = avio_rb32(pb);
++ if (version)
++ av_log_ask_for_sample(s, "unknown version %d\n", version);
++
++ duration = avio_rb32(pb); // in msec
++
++ while (!pb->eof_reached) {
++ htype = avio_rl32(pb);
++ switch (htype) {
++ case SMJPEG_TXT:
++ hlength = avio_rb32(pb);
++ if (!hlength || hlength > 512)
++ return AVERROR_INVALIDDATA;
++ comment = av_malloc(hlength + 1);
++ if (!comment)
++ return AVERROR(ENOMEM);
++ if (avio_read(pb, comment, hlength) != hlength) {
++ av_freep(&comment);
++ av_log(s, AV_LOG_ERROR, "error when reading comment\n");
++ return AVERROR_INVALIDDATA;
++ }
++ comment[hlength] = 0;
++ av_dict_set(&s->metadata, "comment", comment,
++ AV_DICT_DONT_STRDUP_VAL);
++ break;
++ case SMJPEG_SND:
++ if (ast) {
++ av_log_ask_for_sample(s, "multiple audio streams not supported\n");
++ return AVERROR_INVALIDDATA;
++ }
++ hlength = avio_rb32(pb);
++ if (hlength < 8)
++ return AVERROR_INVALIDDATA;
++ ast = avformat_new_stream(s, 0);
++ if (!ast)
++ return AVERROR(ENOMEM);
++ ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
++ ast->codec->sample_rate = avio_rb16(pb);
++ ast->codec->bits_per_coded_sample = avio_r8(pb);
++ ast->codec->channels = avio_r8(pb);
++ ast->codec->codec_tag = avio_rl32(pb);
++ ast->codec->codec_id = ff_codec_get_id(ff_codec_smjpeg_audio_tags,
++ ast->codec->codec_tag);
++ ast->duration = duration;
++ sc->audio_stream_index = ast->index;
++ avpriv_set_pts_info(ast, 32, 1, 1000);
++ avio_skip(pb, hlength - 8);
++ break;
++ case SMJPEG_VID:
++ if (vst) {
++ av_log_ask_for_sample(s, "multiple video streams not supported\n");
++ return AVERROR_INVALIDDATA;
++ }
++ hlength = avio_rb32(pb);
++ if (hlength < 12)
++ return AVERROR_INVALIDDATA;
++ avio_skip(pb, 4); // number of frames
++ vst = avformat_new_stream(s, 0);
++ if (!vst)
++ return AVERROR(ENOMEM);
++ vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
++ vst->codec->width = avio_rb16(pb);
++ vst->codec->height = avio_rb16(pb);
++ vst->codec->codec_tag = avio_rl32(pb);
++ vst->codec->codec_id = ff_codec_get_id(ff_codec_smjpeg_video_tags,
++ vst->codec->codec_tag);
++ vst->duration = duration;
++ sc->video_stream_index = vst->index;
++ avpriv_set_pts_info(vst, 32, 1, 1000);
++ avio_skip(pb, hlength - 12);
++ break;
++ case SMJPEG_HEND:
++ return 0;
++ default:
++ av_log(s, AV_LOG_ERROR, "unknown header %x\n", htype);
++ return AVERROR_INVALIDDATA;
++ }
++ }
++
++ return AVERROR_EOF;
++}
++
++static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
++{
++ SMJPEGContext *sc = s->priv_data;
++ uint32_t dtype, ret, size, timestamp;
++
++ if (s->pb->eof_reached)
++ return AVERROR_EOF;
++ dtype = avio_rl32(s->pb);
++ switch (dtype) {
++ case SMJPEG_SNDD:
++ timestamp = avio_rb32(s->pb);
++ size = avio_rb32(s->pb);
++ ret = av_get_packet(s->pb, pkt, size);
++ pkt->stream_index = sc->audio_stream_index;
++ pkt->pts = timestamp;
++ break;
++ case SMJPEG_VIDD:
++ timestamp = avio_rb32(s->pb);
++ size = avio_rb32(s->pb);
++ ret = av_get_packet(s->pb, pkt, size);
++ pkt->stream_index = sc->video_stream_index;
++ pkt->pts = timestamp;
++ break;
++ case SMJPEG_DONE:
++ ret = AVERROR_EOF;
++ break;
++ default:
++ av_log(s, AV_LOG_ERROR, "unknown chunk %x\n", dtype);
++ ret = AVERROR_INVALIDDATA;
++ break;
++ }
++ return ret;
++}
++
++AVInputFormat ff_smjpeg_demuxer = {
++ .name = "smjpeg",
++ .long_name = NULL_IF_CONFIG_SMALL("Loki SDL MJPEG"),
++ .priv_data_size = sizeof(SMJPEGContext),
++ .read_probe = smjpeg_probe,
++ .read_header = smjpeg_read_header,
++ .read_packet = smjpeg_read_packet,
++ .extensions = "mjpg",
++};
+--
+1.7.5.4
+
diff --git a/debian/patches/post-0.8b2/0063-add-SMJPEG-muxer.patch b/debian/patches/post-0.8b2/0063-add-SMJPEG-muxer.patch
new file mode 100644
index 0000000..76cd074
--- /dev/null
+++ b/debian/patches/post-0.8b2/0063-add-SMJPEG-muxer.patch
@@ -0,0 +1,237 @@
+From ffa0923eee7707acf07a0847b6bac89b86e227dc Mon Sep 17 00:00:00 2001
+From: Paul B Mahol <onemda at gmail.com>
+Date: Sat, 14 Jan 2012 19:29:59 +0000
+Subject: [PATCH 63/63] add SMJPEG muxer
+
+Signed-off-by: Kostya Shishkov <kostya.shishkov at gmail.com>
+---
+ Changelog | 1 +
+ doc/general.texi | 2 +-
+ libavformat/Makefile | 1 +
+ libavformat/allformats.c | 2 +-
+ libavformat/smjpegenc.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++
+ libavformat/version.h | 2 +-
+ 6 files changed, 154 insertions(+), 3 deletions(-)
+ create mode 100644 libavformat/smjpegenc.c
+
+diff --git a/Changelog b/Changelog
+index cbe61f5..3515ba5 100644
+--- a/Changelog
++++ b/Changelog
+@@ -5,6 +5,7 @@ releases are sorted from youngest to oldest.
+ version <next>:
+
+ - GSM audio parser
++- SMJPEG muxer
+
+
+ version 0.8_beta2:
+diff --git a/doc/general.texi b/doc/general.texi
+index 65d65bb..79af887 100644
+--- a/doc/general.texi
++++ b/doc/general.texi
+@@ -296,7 +296,7 @@ library:
+ @tab Used in Sierra CD-ROM games.
+ @item Smacker @tab @tab X
+ @tab Multimedia format used by many games.
+- at item SMJPEG @tab @tab X
++ at item SMJPEG @tab X @tab X
+ @tab Used in certain Loki game ports.
+ @item Sony OpenMG (OMA) @tab X @tab X
+ @tab Audio format used in Sony Sonic Stage and Sony Vegas.
+diff --git a/libavformat/Makefile b/libavformat/Makefile
+index 3e0808a..e564243 100644
+--- a/libavformat/Makefile
++++ b/libavformat/Makefile
+@@ -275,6 +275,7 @@ OBJS-$(CONFIG_SHORTEN_DEMUXER) += rawdec.o
+ OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o
+ OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o
+ OBJS-$(CONFIG_SMJPEG_DEMUXER) += smjpegdec.o smjpeg.o
++OBJS-$(CONFIG_SMJPEG_MUXER) += smjpegenc.o smjpeg.o
+ OBJS-$(CONFIG_SOL_DEMUXER) += sol.o pcm.o
+ OBJS-$(CONFIG_SOX_DEMUXER) += soxdec.o pcm.o
+ OBJS-$(CONFIG_SOX_MUXER) += soxenc.o
+diff --git a/libavformat/allformats.c b/libavformat/allformats.c
+index 523b113..481d2c1 100644
+--- a/libavformat/allformats.c
++++ b/libavformat/allformats.c
+@@ -201,7 +201,7 @@ void av_register_all(void)
+ REGISTER_DEMUXER (SHORTEN, shorten);
+ REGISTER_DEMUXER (SIFF, siff);
+ REGISTER_DEMUXER (SMACKER, smacker);
+- REGISTER_DEMUXER (SMJPEG, smjpeg);
++ REGISTER_MUXDEMUX (SMJPEG, smjpeg);
+ REGISTER_DEMUXER (SOL, sol);
+ REGISTER_MUXDEMUX (SOX, sox);
+ REGISTER_MUXDEMUX (SPDIF, spdif);
+diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
+new file mode 100644
+index 0000000..45ba20b
+--- /dev/null
++++ b/libavformat/smjpegenc.c
+@@ -0,0 +1,149 @@
++/*
++ * SMJPEG muxer
++ * Copyright (c) 2012 Paul B Mahol
++ *
++ * 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
++ */
++
++/**
++ * @file
++ * This is a muxer for Loki SDL Motion JPEG files
++ */
++
++#include "avformat.h"
++#include "internal.h"
++#include "riff.h"
++#include "smjpeg.h"
++
++typedef struct SMJPEGMuxContext {
++ uint32_t duration;
++} SMJPEGMuxContext;
++
++static int smjpeg_write_header(AVFormatContext *s)
++{
++ AVDictionaryEntry *t = NULL;
++ AVIOContext *pb = s->pb;
++ int n, tag;
++
++ if (s->nb_streams > 2) {
++ av_log(s, AV_LOG_ERROR, "more than >2 streams are not supported\n");
++ return AVERROR(EINVAL);
++ }
++ avio_write(pb, SMJPEG_MAGIC, 8);
++ avio_wb32(pb, 0);
++ avio_wb32(pb, 0);
++
++ while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
++ avio_wl32(pb, SMJPEG_TXT);
++ avio_wb32(pb, strlen(t->key) + strlen(t->value) + 3);
++ avio_write(pb, t->key, strlen(t->key));
++ avio_write(pb, " = ", 3);
++ avio_write(pb, t->value, strlen(t->value));
++ }
++
++ for (n = 0; n < s->nb_streams; n++) {
++ AVStream *st = s->streams[n];
++ AVCodecContext *codec = st->codec;
++ if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
++ tag = ff_codec_get_tag(ff_codec_smjpeg_audio_tags, codec->codec_id);
++ if (!tag) {
++ av_log(s, AV_LOG_ERROR, "unsupported audio codec\n");
++ return AVERROR(EINVAL);
++ }
++ avio_wl32(pb, SMJPEG_SND);
++ avio_wb32(pb, 8);
++ avio_wb16(pb, codec->sample_rate);
++ avio_w8(pb, av_get_bits_per_sample(codec->codec_id));
++ avio_w8(pb, codec->channels);
++ avio_wl32(pb, tag);
++ avpriv_set_pts_info(st, 32, 1, 1000);
++ } else if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
++ tag = ff_codec_get_tag(ff_codec_smjpeg_video_tags, codec->codec_id);
++ if (!tag) {
++ av_log(s, AV_LOG_ERROR, "unsupported video codec\n");
++ return AVERROR(EINVAL);
++ }
++ avio_wl32(pb, SMJPEG_VID);
++ avio_wb32(pb, 12);
++ avio_wb32(pb, 0);
++ avio_wb16(pb, codec->width);
++ avio_wb16(pb, codec->height);
++ avio_wl32(pb, tag);
++ avpriv_set_pts_info(st, 32, 1, 1000);
++ }
++ }
++
++ avio_wl32(pb, SMJPEG_HEND);
++ avio_flush(pb);
++
++ return 0;
++}
++
++static int smjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
++{
++ SMJPEGMuxContext *smc = s->priv_data;
++ AVIOContext *pb = s->pb;
++ AVStream *st = s->streams[pkt->stream_index];
++ AVCodecContext *codec = st->codec;
++
++ if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
++ avio_wl32(pb, SMJPEG_SNDD);
++ else if (codec->codec_type == AVMEDIA_TYPE_VIDEO)
++ avio_wl32(pb, SMJPEG_VIDD);
++ else
++ return 0;
++
++ avio_wb32(pb, pkt->pts);
++ avio_wb32(pb, pkt->size);
++ avio_write(pb, pkt->data, pkt->size);
++ avio_flush(pb);
++
++ smc->duration = FFMAX(smc->duration, pkt->pts + pkt->duration);
++ return 0;
++}
++
++static int smjpeg_write_trailer(AVFormatContext *s)
++{
++ SMJPEGMuxContext *smc = s->priv_data;
++ AVIOContext *pb = s->pb;
++ int64_t currentpos;
++
++ if (pb->seekable) {
++ currentpos = avio_tell(pb);
++ avio_seek(pb, 12, SEEK_SET);
++ avio_wb32(pb, smc->duration);
++ avio_seek(pb, currentpos, SEEK_SET);
++ }
++
++ avio_wl32(pb, SMJPEG_DONE);
++ avio_flush(pb);
++
++ return 0;
++}
++
++AVOutputFormat ff_smjpeg_muxer = {
++ .name = "smjpeg",
++ .long_name = NULL_IF_CONFIG_SMALL("Loki SDL MJPEG"),
++ .priv_data_size = sizeof(SMJPEGMuxContext),
++ .audio_codec = CODEC_ID_PCM_S16LE,
++ .video_codec = CODEC_ID_MJPEG,
++ .write_header = smjpeg_write_header,
++ .write_packet = smjpeg_write_packet,
++ .write_trailer = smjpeg_write_trailer,
++ .flags = AVFMT_GLOBALHEADER,
++ .codec_tag = (const AVCodecTag *const []){ ff_codec_smjpeg_video_tags, ff_codec_smjpeg_audio_tags, 0 },
++};
+diff --git a/libavformat/version.h b/libavformat/version.h
+index fb5a1eb..cd774fb 100644
+--- a/libavformat/version.h
++++ b/libavformat/version.h
+@@ -30,7 +30,7 @@
+ #include "libavutil/avutil.h"
+
+ #define LIBAVFORMAT_VERSION_MAJOR 53
+-#define LIBAVFORMAT_VERSION_MINOR 19
++#define LIBAVFORMAT_VERSION_MINOR 20
+ #define LIBAVFORMAT_VERSION_MICRO 0
+
+ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
+--
+1.7.5.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 8e1e269..3096900 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,67 @@
01-Tweak-doxygen-config.patch
03-disable-configuration-warnings.patch
+
+# the patches below can be dropped at the next upstream update
+post-0.8b2/0001-Fix-a-bunch-of-platform-name-and-other-typos.patch
+post-0.8b2/0002-doc-Fix-names-of-av_log-color-environment-variables.patch
+post-0.8b2/0003-doc-Replace-ffmpeg-references-in-avserver-config-fil.patch
+post-0.8b2/0004-avcodec-add-GSM-parser.patch
+post-0.8b2/0005-gsm-demuxer-return-packets-with-only-1-gsm-block-at-.patch
+post-0.8b2/0006-gsm-demuxer-use-generic-seeking-instead-of-a-gsm-spe.patch
+post-0.8b2/0007-pcmenc-set-frame_size-to-0.patch
+post-0.8b2/0008-fft-init-functions-with-INIT_XMM-YMM.patch
+post-0.8b2/0009-latmdec-Check-AudioSpecificConfig-length-before-deco.patch
+post-0.8b2/0010-rgb2rgb-rgb12tobgr12.patch
+post-0.8b2/0011-vsrc_buffer-release-the-buffer-on-uninit.patch
+post-0.8b2/0012-lavfi-move-version-macros-to-a-new-installed-header-.patch
+post-0.8b2/0013-avconv-use-AVFrame.width-height-format-instead-of-co.patch
+post-0.8b2/0014-rv34-DC-only-inverse-transform.patch
+post-0.8b2/0015-indeo4-add-some-missing-static-and-const-qualifiers.patch
+post-0.8b2/0016-riff-remove-references-to-sonic-codec-ids.patch
+post-0.8b2/0017-mpegvideo_enc-ifdef-out-replace-references-to-deprec.patch
+post-0.8b2/0018-nellymoserdec-SAMPLE_FMT-AV_SAMPLE_FMT.patch
+post-0.8b2/0019-lavc-ifdef-out-parse_only-AVOption.patch
+post-0.8b2/0020-lavc-replace-some-remaining-FF_I_TYPE-with-AV_PICTUR.patch
+post-0.8b2/0021-avserver-remove-code-using-deprecated-CODEC_CAP_PARS.patch
+post-0.8b2/0022-lavf-undeprecate-read_seek.patch
+post-0.8b2/0023-ffmenc-remove-references-to-deprecated-AVFormatConte.patch
+post-0.8b2/0024-avprobe-use-avio_size-instead-of-deprecated-AVFormat.patch
+post-0.8b2/0025-rv34-NEON-optimised-dc-only-inverse-transform.patch
+post-0.8b2/0026-rv34-fix-and-optimise-frame-dependency-checking.patch
+post-0.8b2/0027-avio-Fix-the-value-of-the-deprecated-URL_FLAG_NONBLO.patch
+post-0.8b2/0028-ARM-rv34-fix-asm-syntax-in-dc-transform-functions.patch
+post-0.8b2/0029-utils-Check-for-extradata-size-overflows.patch
+post-0.8b2/0030-cabac-Remove-ff_h264_lps_state-array.patch
+post-0.8b2/0031-cabac-Mark-ff_h264_mps_state-array-as-static-it-is-o.patch
+post-0.8b2/0032-cabac-split-cabac.h-into-declarations-and-function-d.patch
+post-0.8b2/0033-swscale-fix-invalid-conversions-and-memory-problems.patch
+post-0.8b2/0034-swscale-test-fix-stack-overread.patch
+post-0.8b2/0035-rgb2rgb-rgb12to15.patch
+post-0.8b2/0036-ARM-4-byte-align-start-of-all-asm-functions.patch
+post-0.8b2/0037-ARM-fix-Thumb-mode-simple_idct_arm.patch
+post-0.8b2/0038-FATE-add-tests-for-targa.patch
+post-0.8b2/0039-FATE-fix-targa-tests-on-big-endian-systems.patch
+post-0.8b2/0040-targa-add-support-for-rgb555-palette.patch
+post-0.8b2/0041-FATE-enable-the-2-remaining-targa-conformance-suite-.patch
+post-0.8b2/0042-fate-add-missing-reference-files-for-targa-tests-in-.patch
+post-0.8b2/0043-FATE-convert-output-to-rgba-for-the-targa-tests-whic.patch
+post-0.8b2/0044-libx264-Don-t-leave-max_b_frames-as-1-if-the-user-di.patch
+post-0.8b2/0045-swscale-change-yuv2yuvX-code-to-use-cpuflag.patch
+post-0.8b2/0046-configure-provide-libavfilter-version.h-header-to-ge.patch
+post-0.8b2/0047-cosmetics-Move-static-and-inline-attributes-to-more-.patch
+post-0.8b2/0048-sgidec-Use-bytestream2-functions-to-prevent-buffer-o.patch
+post-0.8b2/0049-vb-Use-bytestream2-functions.patch
+post-0.8b2/0050-wavpack-fix-clipping-for-32-bit-lossy-mode.patch
+post-0.8b2/0051-lavc-Relax-API-strictness-in-avcodec_decode_audio3-w.patch
+post-0.8b2/0052-mov-mxfdec-Employ-more-meaningful-return-values.patch
+post-0.8b2/0053-fate-split-ADPCM-and-DPCM-test-references-into-separ.patch
+post-0.8b2/0054-rv34-Inter-intra-MB-code-split.patch
+post-0.8b2/0055-rv34-Intra-16x16-handling.patch
+post-0.8b2/0056-avcodec-add-a-public-function-avcodec_fill_audio_fra.patch
+post-0.8b2/0057-avcodec-Add-avcodec_encode_audio2-as-replacement-for.patch
+post-0.8b2/0058-avcodec-bump-minor-version-and-add-APIChanges-for-th.patch
+post-0.8b2/0059-pcmenc-use-AVCodec.encode2.patch
+post-0.8b2/0060-avconv-use-avcodec_encode_audio2.patch
+post-0.8b2/0061-pictordec-Use-bytestream2-functions.patch
+post-0.8b2/0062-avformat-split-out-common-SMJPEG-code.patch
+post-0.8b2/0063-add-SMJPEG-muxer.patch
--
Libav/FFmpeg packaging
More information about the pkg-multimedia-commits
mailing list