summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libffmpeg/libavcodec/Makefile.am2
-rw-r--r--src/libffmpeg/libavcodec/alpha/dsputil_alpha.c8
-rw-r--r--src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c5
-rw-r--r--src/libffmpeg/libavcodec/alpha/simple_idct_alpha.c12
-rw-r--r--src/libffmpeg/libavcodec/armv4l/dsputil_arm.c30
-rw-r--r--src/libffmpeg/libavcodec/avcodec.h848
-rw-r--r--src/libffmpeg/libavcodec/common.c32
-rw-r--r--src/libffmpeg/libavcodec/common.h200
-rw-r--r--src/libffmpeg/libavcodec/dsputil.c508
-rw-r--r--src/libffmpeg/libavcodec/dsputil.h160
-rw-r--r--src/libffmpeg/libavcodec/dv.c102
-rw-r--r--src/libffmpeg/libavcodec/dvdata.h358
-rw-r--r--src/libffmpeg/libavcodec/error_resilience.c129
-rw-r--r--src/libffmpeg/libavcodec/eval.c20
-rw-r--r--src/libffmpeg/libavcodec/fdctref.c5
-rw-r--r--src/libffmpeg/libavcodec/fft.c6
-rw-r--r--src/libffmpeg/libavcodec/h263.c534
-rw-r--r--src/libffmpeg/libavcodec/h263data.h37
-rw-r--r--src/libffmpeg/libavcodec/h263dec.c150
-rw-r--r--src/libffmpeg/libavcodec/huffyuv.c39
-rw-r--r--src/libffmpeg/libavcodec/i386/dsputil_mmx.c392
-rw-r--r--src/libffmpeg/libavcodec/i386/dsputil_mmx_avg.h32
-rw-r--r--src/libffmpeg/libavcodec/i386/dsputil_mmx_rnd.h28
-rw-r--r--src/libffmpeg/libavcodec/i386/motion_est_mmx.c79
-rw-r--r--src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c73
-rw-r--r--src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c8
-rw-r--r--src/libffmpeg/libavcodec/i386/simple_idct_mmx.c4
-rw-r--r--src/libffmpeg/libavcodec/imgconvert.c1102
-rw-r--r--src/libffmpeg/libavcodec/imgresample.c79
-rw-r--r--src/libffmpeg/libavcodec/jfdctfst.c15
-rw-r--r--src/libffmpeg/libavcodec/jfdctint.c39
-rw-r--r--src/libffmpeg/libavcodec/jrevdct.c26
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess.c10
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess.h2
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h57
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess_template.c16
-rw-r--r--src/libffmpeg/libavcodec/mace.c48
-rw-r--r--src/libffmpeg/libavcodec/mdct.c9
-rw-r--r--src/libffmpeg/libavcodec/mem.c6
-rw-r--r--src/libffmpeg/libavcodec/mjpeg.c160
-rw-r--r--src/libffmpeg/libavcodec/mlib/dsputil_mlib.c41
-rw-r--r--src/libffmpeg/libavcodec/motion_est.c171
-rw-r--r--src/libffmpeg/libavcodec/motion_est_template.c50
-rw-r--r--src/libffmpeg/libavcodec/mpeg12.c406
-rw-r--r--src/libffmpeg/libavcodec/mpeg12data.h75
-rw-r--r--src/libffmpeg/libavcodec/mpeg4data.h239
-rw-r--r--src/libffmpeg/libavcodec/mpegaudio.h11
-rw-r--r--src/libffmpeg/libavcodec/mpegaudiodec.c171
-rw-r--r--src/libffmpeg/libavcodec/mpegaudiodectab.h86
-rw-r--r--src/libffmpeg/libavcodec/mpegaudiotab.h10
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.c811
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.h518
-rw-r--r--src/libffmpeg/libavcodec/msmpeg4.c72
-rw-r--r--src/libffmpeg/libavcodec/msmpeg4data.h3
-rw-r--r--src/libffmpeg/libavcodec/opts.c192
-rw-r--r--src/libffmpeg/libavcodec/os_support.h32
-rw-r--r--src/libffmpeg/libavcodec/ppc/Makefile.am3
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_altivec.c8
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_altivec.h10
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_ppc.c17
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_ppc.h123
-rw-r--r--src/libffmpeg/libavcodec/ppc/gmc_altivec.c169
-rw-r--r--src/libffmpeg/libavcodec/ppc/idct_altivec.c8
-rw-r--r--src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c11
-rw-r--r--src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c12
-rw-r--r--src/libffmpeg/libavcodec/ratecontrol.c50
-rw-r--r--src/libffmpeg/libavcodec/rv10.c32
-rw-r--r--src/libffmpeg/libavcodec/simple_idct.c34
-rw-r--r--src/libffmpeg/libavcodec/simple_idct.h19
-rw-r--r--src/libffmpeg/libavcodec/svq1.c49
-rw-r--r--src/libffmpeg/libavcodec/svq1_cb.h5
-rw-r--r--src/libffmpeg/libavcodec/utils.c123
-rw-r--r--src/libffmpeg/libavcodec/wmadata.h5
-rw-r--r--src/libffmpeg/libavcodec/wmadec.c8
-rw-r--r--src/libffmpeg/libavcodec/wmv2.c35
75 files changed, 5477 insertions, 3502 deletions
diff --git a/src/libffmpeg/libavcodec/Makefile.am b/src/libffmpeg/libavcodec/Makefile.am
index c54f72ae8..c45f91a27 100644
--- a/src/libffmpeg/libavcodec/Makefile.am
+++ b/src/libffmpeg/libavcodec/Makefile.am
@@ -40,6 +40,7 @@ libavcodec_la_SOURCES = \
mpegaudiodec.c \
mpegvideo.c \
msmpeg4.c \
+ opts.c \
ratecontrol.c \
rv10.c \
simple_idct.c \
@@ -69,6 +70,7 @@ noinst_HEADERS = \
mpegaudiotab.h \
mpegvideo.h \
msmpeg4data.h \
+ os_support.h \
simple_idct.h \
svq1_cb.h \
wmadata.h
diff --git a/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c b/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c
index 5cbc00167..cdc8a6d5a 100644
--- a/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c
+++ b/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c
@@ -20,6 +20,9 @@
#include "asm.h"
#include "../dsputil.h"
+extern void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block);
+extern void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block);
+
void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels,
int line_size, int h);
void put_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels,
@@ -295,7 +298,7 @@ static int sad8x8_mvi(void *s, uint8_t *a, uint8_t *b, int stride)
return pix_abs8x8_mvi(a, b, stride);
}
-void dsputil_init_alpha(DSPContext* c, unsigned mask)
+void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
{
c->put_pixels_tab[0][0] = put_pixels16_axp_asm;
c->put_pixels_tab[0][1] = put_pixels16_x2_axp;
@@ -357,4 +360,7 @@ void dsputil_init_alpha(DSPContext* c, unsigned mask)
put_pixels_clamped_axp_p = c->put_pixels_clamped;
add_pixels_clamped_axp_p = c->add_pixels_clamped;
+
+ c->idct_put = simple_idct_put_axp;
+ c->idct_add = simple_idct_add_axp;
}
diff --git a/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c b/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c
index 350b53f62..1a58e5dfd 100644
--- a/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c
+++ b/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c
@@ -21,9 +21,6 @@
#include "../dsputil.h"
#include "../mpegvideo.h"
-extern void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block);
-extern void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block);
-
static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block,
int n, int qscale)
{
@@ -97,6 +94,4 @@ static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block,
void MPV_common_init_axp(MpegEncContext *s)
{
s->dct_unquantize_h263 = dct_unquantize_h263_axp;
- s->idct_put = simple_idct_put_axp;
- s->idct_add = simple_idct_add_axp;
}
diff --git a/src/libffmpeg/libavcodec/alpha/simple_idct_alpha.c b/src/libffmpeg/libavcodec/alpha/simple_idct_alpha.c
index 5ce017740..889fd2ae1 100644
--- a/src/libffmpeg/libavcodec/alpha/simple_idct_alpha.c
+++ b/src/libffmpeg/libavcodec/alpha/simple_idct_alpha.c
@@ -49,7 +49,7 @@ extern void (*add_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels,
static inline int idct_row(DCTELEM *row)
{
int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3, t;
- uint64_t l, r;
+ uint64_t l, r, t2;
l = ldq(row);
r = ldq(row + 4);
@@ -60,12 +60,12 @@ static inline int idct_row(DCTELEM *row)
if (((l & ~0xffffUL) | r) == 0) {
a0 >>= ROW_SHIFT;
- a0 = (uint16_t) a0;
- a0 |= a0 << 16;
- a0 |= a0 << 32;
+ t2 = (uint16_t) a0;
+ t2 |= t2 << 16;
+ t2 |= t2 << 32;
- stq(a0, row);
- stq(a0, row + 4);
+ stq(t2, row);
+ stq(t2, row + 4);
return 1;
}
diff --git a/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c b/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c
index e459b3391..e3cc05f63 100644
--- a/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c
+++ b/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c
@@ -21,7 +21,33 @@
extern void j_rev_dct_ARM(DCTELEM *data);
-void dsputil_init_armv4l(DSPContext* c, unsigned mask)
+/* XXX: local hack */
+static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
+static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
+
+/* XXX: those functions should be suppressed ASAP when all IDCTs are
+ converted */
+static void arm_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ j_rev_dct_ARM (block);
+ ff_put_pixels_clamped(block, dest, line_size);
+}
+static void arm_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ j_rev_dct_ARM (block);
+ ff_add_pixels_clamped(block, dest, line_size);
+}
+
+void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx)
{
-// ff_idct = j_rev_dct_ARM;
+ const int idct_algo= avctx->idct_algo;
+
+ ff_put_pixels_clamped = c->put_pixels_clamped;
+ ff_add_pixels_clamped = c->add_pixels_clamped;
+
+ if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_ARM){
+ c->idct_put= arm_idct_put;
+ c->idct_add= arm_idct_add;
+ c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;/* FF_NO_IDCT_PERM */
+ }
}
diff --git a/src/libffmpeg/libavcodec/avcodec.h b/src/libffmpeg/libavcodec/avcodec.h
index 06b348fa7..c8b48c072 100644
--- a/src/libffmpeg/libavcodec/avcodec.h
+++ b/src/libffmpeg/libavcodec/avcodec.h
@@ -1,6 +1,12 @@
#ifndef AVCODEC_H
#define AVCODEC_H
+/**
+ * @file avcodec.h
+ * external api header.
+ */
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -9,8 +15,10 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
-#define LIBAVCODEC_BUILD 4654
-#define LIBAVCODEC_BUILD_STR "4654"
+#define LIBAVCODEC_BUILD 4663
+#define LIBAVCODEC_BUILD_STR "4663"
+
+#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
enum CodecID {
CODEC_ID_NONE,
@@ -40,6 +48,7 @@ enum CodecID {
CODEC_ID_MACE3,
CODEC_ID_MACE6,
CODEC_ID_HUFFYUV,
+ CODEC_ID_CYUV,
/* various pcm "codecs" */
CODEC_ID_PCM_S16LE,
@@ -63,27 +72,31 @@ enum CodecType {
CODEC_TYPE_AUDIO,
};
+/**
+ * Pixel format.
+ */
enum PixelFormat {
PIX_FMT_YUV420P,
PIX_FMT_YUV422,
- PIX_FMT_RGB24, /* 3 bytes, R is first */
- PIX_FMT_BGR24, /* 3 bytes, B is first */
+ PIX_FMT_RGB24, ///< 3 bytes, R is first
+ PIX_FMT_BGR24, ///< 3 bytes, B is first
PIX_FMT_YUV422P,
PIX_FMT_YUV444P,
- PIX_FMT_RGBA32, /* always stored in cpu endianness */
+ PIX_FMT_RGBA32, ///< always stored in cpu endianness
PIX_FMT_YUV410P,
PIX_FMT_YUV411P,
- PIX_FMT_RGB565, /* always stored in cpu endianness */
- PIX_FMT_RGB555, /* always stored in cpu endianness, most significant bit to 1 */
+ PIX_FMT_RGB565, ///< always stored in cpu endianness
+ PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
PIX_FMT_GRAY8,
- PIX_FMT_MONOWHITE, /* 0 is white */
- PIX_FMT_MONOBLACK, /* 0 is black */
+ PIX_FMT_MONOWHITE, ///< 0 is white
+ PIX_FMT_MONOBLACK, ///< 0 is black
+ PIX_FMT_PAL8, ///< 8 bit with RGBA palette
PIX_FMT_NB,
};
/* currently unused, may be used if 24/32 bits samples ever supported */
enum SampleFormat {
- SAMPLE_FMT_S16 = 0, /* signed 16 bits */
+ SAMPLE_FMT_S16 = 0, ///< signed 16 bits
};
/* in bytes */
@@ -127,154 +140,180 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
Note: note not everything is supported yet
*/
-#define CODEC_FLAG_HQ 0x0001 /* brute force MB-type decission mode (slow) */
-#define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
-#define CODEC_FLAG_4MV 0x0004 /* 4 MV per MB allowed */
-#define CODEC_FLAG_QPEL 0x0010 /* use qpel MC */
-#define CODEC_FLAG_GMC 0x0020 /* use GMC */
-#define CODEC_FLAG_PART 0x0080 /* use data partitioning */
+#define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
+#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
+#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
+#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
+#define CODEC_FLAG_GMC 0x0020 ///< use GMC
+#define CODEC_FLAG_PART 0x0080 ///< use data partitioning
/* parent program gurantees that the input for b-frame containing streams is not written to
for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
-#define CODEC_FLAG_PASS1 0x0200 /* use internal 2pass ratecontrol in first pass mode */
-#define CODEC_FLAG_PASS2 0x0400 /* use internal 2pass ratecontrol in second pass mode */
-#define CODEC_FLAG_EXTERN_HUFF 0x1000 /* use external huffman table (for mjpeg) */
-#define CODEC_FLAG_GRAY 0x2000 /* only decode/encode grayscale */
-#define CODEC_FLAG_EMU_EDGE 0x4000/* dont draw edges */
-#define CODEC_FLAG_PSNR 0x8000 /* error[?] variables will be set during encoding */
-#define CODEC_FLAG_TRUNCATED 0x00010000 /* input bitstream might be truncated at a random location instead
+#define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
+#define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
+#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
+#define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
+#define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
+#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
+#define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
of only at frame boundaries */
-#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 /* normalize adaptive quantization */
-#define CODEC_FLAG_INTERLACED_DCT 0x00040000 /* use interlaced dct */
-#define CODEC_FLAG_LOW_DELAY 0x00080000 /* force low delay / will fail on b frames */
-#define CODEC_FLAG_ALT_SCAN 0x00100000 /* use alternate scan */
-#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 /* use trellis quantization */
-#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 /* place global headers in extradata instead of every keyframe */
-
+#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
+#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
+#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay / will fail on b frames
+#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
+#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
+#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
+#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
+/* Fx : Flag for h263+ extra options */
+#define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
+#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
+/* For advanced prediction mode, we reuse the 4MV flag */
+/* Unsupported options :
+ * Syntax Arithmetic coding (SAC)
+ * Deblocking filter internal loop
+ * Slice structured
+ * Reference Picture Selection
+ * Independant Segment Decoding
+ * Alternative Inter * VLC
+ * Modified Quantization */
+/* /Fx */
/* codec capabilities */
-#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 /* decoder can use draw_horiz_band callback */
-#define CODEC_CAP_DR1 0x0002 /* direct rendering method 1 */
+#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
+#define CODEC_CAP_DR1 0x0002 ///< direct rendering method 1
/* if 'parse_only' field is true, then avcodec_parse_frame() can be
used */
#define CODEC_CAP_PARSE_ONLY 0x0004
#define CODEC_CAP_TRUNCATED 0x0008
-#define FRAME_RATE_BASE 10000
-
#define FF_COMMON_FRAME \
+ /**\
+ * pointer to the picture planes.\
+ * this might be different from the first allocated byte\
+ * - encoding: \
+ * - decoding: \
+ */\
uint8_t *data[4];\
int linesize[4];\
/**\
* pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
* this isnt used by lavc unless the default get/release_buffer() is used\
- * encoding: \
- * decoding: \
+ * - encoding: \
+ * - decoding: \
*/\
uint8_t *base[4];\
/**\
* 1 -> keyframe, 0-> not\
- * encoding: set by lavc\
- * decoding: set by lavc\
+ * - encoding: set by lavc\
+ * - decoding: set by lavc\
*/\
int key_frame;\
\
/**\
* picture type of the frame, see ?_TYPE below\
- * encoding: set by lavc for coded_picture (and set by user for input)\
- * decoding: set by lavc\
+ * - encoding: set by lavc for coded_picture (and set by user for input)\
+ * - decoding: set by lavc\
*/\
int pict_type;\
\
/**\
* presentation timestamp in micro seconds (time when frame should be shown to user)\
* if 0 then the frame_rate will be used as reference\
- * encoding: MUST be set by user\
- * decoding: set by lavc\
+ * - encoding: MUST be set by user\
+ * - decoding: set by lavc\
*/\
long long int pts;\
\
/**\
* picture number in bitstream order.\
- * encoding: set by\
- * decoding: set by lavc\
+ * - encoding: set by\
+ * - decoding: set by lavc\
*/\
int coded_picture_number;\
/**\
- * encoding: set by\
- * decoding: set by lavc\
* picture number in display order.\
+ * - encoding: set by\
+ * - decoding: set by lavc\
*/\
int display_picture_number;\
\
/**\
* quality (between 1 (good) and 31 (bad)) \
- * encoding: set by lavc for coded_picture (and set by user for input)\
- * decoding: set by lavc\
+ * - encoding: set by lavc for coded_picture (and set by user for input)\
+ * - decoding: set by lavc\
*/\
float quality; \
\
/**\
* buffer age (1->was last buffer and dint change, 2->..., ...).\
* set to something large if the buffer has not been used yet \
- * encoding: unused\
- * decoding: MUST be set by get_buffer()\
+ * - encoding: unused\
+ * - decoding: MUST be set by get_buffer()\
*/\
int age;\
\
/**\
* is this picture used as reference\
- * encoding: unused\
- * decoding: set by lavc (before get_buffer() call))\
+ * - encoding: unused\
+ * - decoding: set by lavc (before get_buffer() call))\
*/\
int reference;\
\
/**\
* QP table\
- * encoding: unused\
- * decoding: set by lavc\
+ * - encoding: unused\
+ * - decoding: set by lavc\
*/\
int8_t *qscale_table;\
/**\
* QP store stride\
- * encoding: unused\
- * decoding: set by lavc\
+ * - encoding: unused\
+ * - decoding: set by lavc\
*/\
int qstride;\
\
/**\
* mbskip_table[mb]>=1 if MB didnt change\
* stride= mb_width = (width+15)>>4\
- * encoding: unused\
- * decoding: set by lavc\
+ * - encoding: unused\
+ * - decoding: set by lavc\
*/\
uint8_t *mbskip_table;\
\
/**\
* for some private data of the user\
- * encoding: unused\
- * decoding: set by user\
+ * - encoding: unused\
+ * - decoding: set by user\
*/\
void *opaque;\
\
/**\
* error\
- * encoding: set by lavc if flags&CODEC_FLAG_PSNR\
- * decoding: unused\
+ * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
+ * - decoding: unused\
*/\
uint64_t error[4];\
\
/**\
* type of the buffer (to keep track of who has to dealloc data[*])\
- * encoding: set by the one who allocs it\
- * decoding: set by the one who allocs it\
+ * - encoding: set by the one who allocs it\
+ * - decoding: set by the one who allocs it\
* Note: user allocated (direct rendering) & internal buffers can not coexist currently\
*/\
int type;\
+ \
+ /**\
+ * when decoding, this signal how much the picture must be delayed.\
+ * extra_delay = repeat_pict / (2*fps)\
+ * - encoding: unused\
+ * - decoding: set by lavc\
+ */\
+ int repeat_pict;
+
#define FF_BUFFER_TYPE_INTERNAL 1
-#define FF_BUFFER_TYPE_USER 2 // Direct rendering buffers
-#define FF_BUFFER_TYPE_SHARED 4 // input frame for encoding(wont be dealloced)
+#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
+#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
#define FF_I_TYPE 1 // Intra
@@ -286,67 +325,73 @@ typedef struct AVFrame {
FF_COMMON_FRAME
} AVFrame;
+#define DEFAULT_FRAME_RATE_BASE 1001000
+
+/**
+ * main external api structure.
+ */
typedef struct AVCodecContext {
/**
- * the average bitrate
- * encoding: set by user. unused for constant quantizer encoding
- * decoding: set by lavc. 0 or some bitrate if this info is available in the stream
+ * the average bitrate.
+ * - encoding: set by user. unused for constant quantizer encoding
+ * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
*/
int bit_rate;
/**
- * number of bits the bitstream is allowed to diverge from the reference
+ * number of bits the bitstream is allowed to diverge from the reference.
* the reference can be CBR (for CBR pass1) or VBR (for pass2)
- * encoding: set by user. unused for constant quantizer encoding
- * decoding: unused
+ * - encoding: set by user. unused for constant quantizer encoding
+ * - decoding: unused
*/
int bit_rate_tolerance;
/**
- * CODEC_FLAG_*
- * encoding: set by user.
- * decoding: set by user.
+ * CODEC_FLAG_*.
+ * - encoding: set by user.
+ * - decoding: set by user.
*/
int flags;
/**
* some codecs needs additionnal format info. It is stored here
- * encoding: set by user.
- * decoding: set by lavc. (FIXME is this ok?)
+ * - encoding: set by user.
+ * - decoding: set by lavc. (FIXME is this ok?)
*/
int sub_id;
/**
- * motion estimation algorithm used for video coding
- * encoding: MUST be set by user.
- * decoding: unused
+ * motion estimation algorithm used for video coding.
+ * - encoding: MUST be set by user.
+ * - decoding: unused
*/
int me_method;
/**
- * some codecs need / can use extra-data like huffman tables
+ * some codecs need / can use extra-data like huffman tables.
* mjpeg: huffman tables
* rv10: additional flags
* mpeg4: global headers (they can be in the bitstream or here)
- * encoding: set/allocated/freed by lavc.
- * decoding: set/allocated/freed by user.
+ * - encoding: set/allocated/freed by lavc.
+ * - decoding: set/allocated/freed by user.
*/
void *extradata;
int extradata_size;
/* video only */
/**
- * frames per sec multiplied by FRAME_RATE_BASE
+ * frames per sec multiplied by frame_rate_base.
* for variable fps this is the precission, so if the timestamps
- * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
- * encoding: MUST be set by user
- * decoding: set by lavc. 0 or the frame_rate if available
+ * can be specified in msec precssion then this is 1000*frame_rate_base
+ * - encoding: MUST be set by user
+ * - decoding: set by lavc. 0 or the frame_rate if available
*/
int frame_rate;
-
+
/**
- * encoding: MUST be set by user.
- * decoding: set by user, some codecs might override / change it during playback
+ * width / height.
+ * - encoding: MUST be set by user.
+ * - decoding: set by user, some codecs might override / change it during playback
*/
int width, height;
@@ -358,91 +403,94 @@ typedef struct AVCodecContext {
#define FF_ASPECT_EXTENDED 15
/**
- * the number of pictures in a group of pitures, or 0 for intra_only
- * encoding: set by user.
- * decoding: unused
+ * the number of pictures in a group of pitures, or 0 for intra_only.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int gop_size;
/**
- * pixel format, see PIX_FMT_xxx
- * encoding: unused
- * decoding: set by lavc.
+ * pixel format, see PIX_FMT_xxx.
+ * - encoding: unused
+ * - decoding: set by lavc.
*/
enum PixelFormat pix_fmt;
-
- int repeat_pict; /* when decoding, this signal how much the picture */
- /* must be delayed. */
- /* extra_delay = (repeat_pict / 2) * (1/fps) */
-
+
+ /**
+ * Frame rate emulation. If not zero lower layer (i.e. format handler)
+ * has to read frames at native frame rate.
+ * - encoding: set by user.
+ * - decoding: unused.
+ */
+ int rate_emu;
+
/**
* if non NULL, 'draw_horiz_band' is called by the libavcodec
* decoder to draw an horizontal band. It improve cache usage. Not
* all codecs can do that. You must check the codec capabilities
* before
- * encoding: unused
- * decoding: set by user.
+ * - encoding: unused
+ * - decoding: set by user.
*/
void (*draw_horiz_band)(struct AVCodecContext *s,
- UINT8 **src_ptr, int linesize,
+ uint8_t **src_ptr, int linesize,
int y, int width, int height);
/* audio only */
- int sample_rate; /* samples per sec */
+ int sample_rate; ///< samples per sec
int channels;
- int sample_fmt; /* sample format, currenly unused */
+ int sample_fmt; ///< sample format, currenly unused
/* the following data should not be initialized */
- int frame_size; /* in samples, initialized when calling 'init' */
- int frame_number; /* audio or video frame number */
- int real_pict_num; /* returns the real picture number of
- previous encoded frame */
+ int frame_size; ///< in samples, initialized when calling 'init'
+ int frame_number; ///< audio or video frame number
+ int real_pict_num; ///< returns the real picture number of previous encoded frame
/**
* number of frames the decoded output will be delayed relative to
- * the encoded input
- * encoding: set by lavc.
- * decoding: unused
+ * the encoded input.
+ * - encoding: set by lavc.
+ * - decoding: unused
*/
int delay;
- /* encoding parameters */
- float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
- float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
+ /* - encoding parameters */
+ float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
+ float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
/**
- * minimum quantizer
- * encoding: set by user.
- * decoding: unused
+ * minimum quantizer.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int qmin;
/**
- * maximum quantizer
- * encoding: set by user.
- * decoding: unused
+ * maximum quantizer.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int qmax;
/**
- * maximum quantizer difference etween frames
- * encoding: set by user.
- * decoding: unused
+ * maximum quantizer difference etween frames.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int max_qdiff;
/**
- * maximum number of b frames between non b frames
+ * maximum number of b frames between non b frames.
* note: the output will be delayed by max_b_frames+1 relative to the input
- * encoding: set by user.
- * decoding: unused
+ * - encoding: set by user.
+ * - decoding: unused
*/
int max_b_frames;
/**
- * qscale factor between ip and b frames
- * encoding: set by user.
- * decoding: unused
+ * qscale factor between ip and b frames.
+ * - encoding: set by user.
+ * - decoding: unused
*/
float b_quant_factor;
@@ -451,8 +499,9 @@ typedef struct AVCodecContext {
int b_frame_strategy;
/**
- * encoding: unused
- * decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
+ * hurry up amount.
+ * - encoding: unused
+ * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
*/
int hurry_up;
@@ -491,31 +540,38 @@ typedef struct AVCodecContext {
int misc_bits;
/**
- * number of bits used for the previously encoded frame
- * encoding: set by lavc
- * decoding: - for audio - bits_per_sample
+ * number of bits used for the previously encoded frame.
+ * - encoding: set by lavc
+ * - decoding: unused
*/
int frame_bits;
-
+
/**
- * private data of the user, can be used to carry app specific stuff
- * encoding: set by user
- * decoding: set by user
+ * private data of the user, can be used to carry app specific stuff.
+ * - encoding: set by user
+ * - decoding: set by user
*/
void *opaque;
char codec_name[32];
enum CodecType codec_type; /* see CODEC_TYPE_xxx */
enum CodecID codec_id; /* see CODEC_ID_xxx */
- unsigned int codec_tag; /* codec tag, only used if unknown codec */
/**
- * workaround bugs in encoders which sometimes cannot be detected automatically
- * encoding: unused
- * decoding: set by user
+ * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
+ * this is used to workaround some encoder bugs
+ * - encoding: unused
+ * - decoding: set by user, will be converted to upper case by lavc during init
+ */
+ unsigned int codec_tag;
+
+ /**
+ * workaround bugs in encoders which sometimes cannot be detected automatically.
+ * - encoding: unused
+ * - decoding: set by user
*/
int workaround_bugs;
-#define FF_BUG_AUTODETECT 1 //autodetection
+#define FF_BUG_AUTODETECT 1 ///< autodetection
#define FF_BUG_OLD_MSMPEG4 2
#define FF_BUG_XVID_ILACE 4
#define FF_BUG_UMP4 8
@@ -524,41 +580,45 @@ typedef struct AVCodecContext {
#define FF_BUG_QPEL_CHROMA 64
#define FF_BUG_STD_QPEL 128
#define FF_BUG_QPEL_CHROMA2 256
+#define FF_BUG_DIRECT_BLOCKSIZE 512
+#define FF_BUG_EDGE 1024
//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
/**
- * encoding: set by user
- * decoding: unused
+ * luma single coeff elimination threshold.
+ * - encoding: set by user
+ * - decoding: unused
*/
int luma_elim_threshold;
/**
- * encoding: set by user
- * decoding: unused
+ * chroma single coeff elimination threshold.
+ * - encoding: set by user
+ * - decoding: unused
*/
int chroma_elim_threshold;
/**
- * strictly follow the std (MPEG4, ...)
- * encoding: set by user
- * decoding: unused
+ * strictly follow the std (MPEG4, ...).
+ * - encoding: set by user
+ * - decoding: unused
*/
int strict_std_compliance;
/**
- * qscale offset between ip and b frames
+ * qscale offset between ip and b frames.
* if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
* if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
- * encoding: set by user.
- * decoding: unused
+ * - encoding: set by user.
+ * - decoding: unused
*/
float b_quant_offset;
/**
* error resilience higher values will detect more errors but may missdetect
- * some more or less valid parts as errors
- * encoding: unused
- * decoding: set by user
+ * some more or less valid parts as errors.
+ * - encoding: unused
+ * - decoding: set by user
*/
int error_resilience;
#define FF_ER_CAREFULL 1
@@ -569,8 +629,8 @@ typedef struct AVCodecContext {
/**
* called at the beginning of each frame to get a buffer for it.
* if pic.reference is set then the frame will be read later by lavc
- * encoding: unused
- * decoding: set by lavc, user can override
+ * - encoding: unused
+ * - decoding: set by lavc, user can override
*/
int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
@@ -578,51 +638,51 @@ typedef struct AVCodecContext {
* called to release buffers which where allocated with get_buffer.
* a released buffer can be reused in get_buffer()
* pic.data[*] must be set to NULL
- * encoding: unused
- * decoding: set by lavc, user can override
+ * - encoding: unused
+ * - decoding: set by lavc, user can override
*/
void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
/**
- * is 1 if the decoded stream contains b frames, 0 otherwise
- * encoding: unused
- * decoding: set by lavc
+ * is 1 if the decoded stream contains b frames, 0 otherwise.
+ * - encoding: unused
+ * - decoding: set by lavc
*/
int has_b_frames;
- int block_align; /* used by some WAV based audio codecs */
+ int block_align; ///< used by some WAV based audio codecs
- int parse_only; /* decoding only: if true, only parsing is done
+ int parse_only; /* - decoding only: if true, only parsing is done
(function avcodec_parse_frame()). The frame
data is returned. Only MPEG codecs support this now. */
/**
- * 0-> h263 quant 1-> mpeg quant
- * encoding: set by user.
- * decoding: unused
+ * 0-> h263 quant 1-> mpeg quant.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int mpeg_quant;
/**
- * pass1 encoding statistics output buffer
- * encoding: set by lavc
- * decoding: unused
+ * pass1 encoding statistics output buffer.
+ * - encoding: set by lavc
+ * - decoding: unused
*/
- char *stats_out; /* encoding statistics output buffer */
+ char *stats_out;
/**
* pass2 encoding statistics input buffer.
* concatenated stuff from stats_out of pass1 should be placed here
- * encoding: allocated/set/freed by user
- * decoding: unused
+ * - encoding: allocated/set/freed by user
+ * - decoding: unused
*/
char *stats_in;
/**
- * ratecontrol qmin qmax limiting method
+ * ratecontrol qmin qmax limiting method.
* 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
- * encoding: set by user.
- * decoding: unused
+ * - encoding: set by user.
+ * - decoding: unused
*/
float rc_qsquish;
@@ -630,69 +690,69 @@ typedef struct AVCodecContext {
int rc_qmod_freq;
/**
- * ratecontrol override, see RcOverride
- * encoding: allocated/set/freed by user.
- * decoding: unused
+ * ratecontrol override, see RcOverride.
+ * - encoding: allocated/set/freed by user.
+ * - decoding: unused
*/
RcOverride *rc_override;
int rc_override_count;
/**
- * rate control equation
- * encoding: set by user
- * decoding: unused
+ * rate control equation.
+ * - encoding: set by user
+ * - decoding: unused
*/
char *rc_eq;
/**
- * maximum bitrate
- * encoding: set by user.
- * decoding: unused
+ * maximum bitrate.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int rc_max_rate;
/**
- * minimum bitrate
- * encoding: set by user.
- * decoding: unused
+ * minimum bitrate.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int rc_min_rate;
/**
- * decoder bitstream buffer size
- * encoding: set by user.
- * decoding: unused
+ * decoder bitstream buffer size.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int rc_buffer_size;
float rc_buffer_aggressivity;
/**
- * qscale factor between p and i frames
- * encoding: set by user.
- * decoding: unused
+ * qscale factor between p and i frames.
+ * - encoding: set by user.
+ * - decoding: unused
*/
float i_quant_factor;
/**
- * qscale offset between p and i frames
+ * qscale offset between p and i frames.
* if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
* if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
- * encoding: set by user.
- * decoding: unused
+ * - encoding: set by user.
+ * - decoding: unused
*/
float i_quant_offset;
/**
- * initial complexity for pass1 ratecontrol
- * encoding: set by user.
- * decoding: unused
+ * initial complexity for pass1 ratecontrol.
+ * - encoding: set by user.
+ * - decoding: unused
*/
float rc_initial_cplx;
/**
- * dct algorithm, see FF_DCT_* below
- * encoding: set by user
- * decoding: unused
+ * dct algorithm, see FF_DCT_* below.
+ * - encoding: set by user
+ * - decoding: unused
*/
int dct_algo;
#define FF_DCT_AUTO 0
@@ -703,52 +763,48 @@ typedef struct AVCodecContext {
#define FF_DCT_ALTIVEC 5
/**
- * luminance masking (0-> disabled)
- * encoding: set by user
- * decoding: unused
+ * luminance masking (0-> disabled).
+ * - encoding: set by user
+ * - decoding: unused
*/
float lumi_masking;
/**
- * temporary complexity masking (0-> disabled)
- * encoding: set by user
- * decoding: unused
+ * temporary complexity masking (0-> disabled).
+ * - encoding: set by user
+ * - decoding: unused
*/
float temporal_cplx_masking;
/**
- * spatial complexity masking (0-> disabled)
- * encoding: set by user
- * decoding: unused
+ * spatial complexity masking (0-> disabled).
+ * - encoding: set by user
+ * - decoding: unused
*/
float spatial_cplx_masking;
/**
- * p block masking (0-> disabled)
- * encoding: set by user
- * decoding: unused
+ * p block masking (0-> disabled).
+ * - encoding: set by user
+ * - decoding: unused
*/
float p_masking;
/**
- * darkness masking (0-> disabled)
- * encoding: set by user
- * decoding: unused
+ * darkness masking (0-> disabled).
+ * - encoding: set by user
+ * - decoding: unused
*/
float dark_masking;
+
+ /* for binary compatibility */
+ int unused;
+
/**
- * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
- * this is used to workaround some encoder bugs
- * encoding: unused
- * decoding: set by user, will be converted to upper case by lavc during init
- */
- int fourcc;
-
- /**
- * idct algorithm, see FF_IDCT_* below
- * encoding: set by user
- * decoding: set by user
+ * idct algorithm, see FF_IDCT_* below.
+ * - encoding: set by user
+ * - decoding: set by user
*/
int idct_algo;
#define FF_IDCT_AUTO 0
@@ -762,44 +818,57 @@ typedef struct AVCodecContext {
#define FF_IDCT_ALTIVEC 8
/**
- * slice count
- * encoding: set by lavc
- * decoding: set by user (or 0)
+ * slice count.
+ * - encoding: set by lavc
+ * - decoding: set by user (or 0)
*/
int slice_count;
/**
- * slice offsets in the frame in bytes
- * encoding: set/allocated by lavc
- * decoding: set/allocated by user (or NULL)
+ * slice offsets in the frame in bytes.
+ * - encoding: set/allocated by lavc
+ * - decoding: set/allocated by user (or NULL)
*/
int *slice_offset;
/**
- * error concealment flags
- * encoding: unused
- * decoding: set by user
+ * error concealment flags.
+ * - encoding: unused
+ * - decoding: set by user
*/
int error_concealment;
#define FF_EC_GUESS_MVS 1
#define FF_EC_DEBLOCK 2
/**
- * dsp_mask could be used to disable unwanted
+ * dsp_mask could be add used to disable unwanted CPU features
* CPU features (i.e. MMX, SSE. ...)
- */
- unsigned dsp_mask;
-
- /**
- * bits per sample/pixel from the demuxer (needed for huffyuv)
- * encoding: set by lavc
- * decoding: set by user
+ *
+ * with FORCE flag you may instead enable given CPU features
+ * (Dangerous: usable in case of misdetection, improper usage however will
+ * result into program crash)
+ */
+ unsigned dsp_mask;
+#define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
+ /* lower 16 bits - CPU features */
+#ifdef HAVE_MMX
+#define FF_MM_MMX 0x0001 /* standard MMX */
+#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
+#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
+#define FF_MM_SSE 0x0008 /* SSE functions */
+#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
+#endif /* HAVE_MMX */
+
+ /**
+ * bits per sample/pixel from the demuxer (needed for huffyuv).
+ * - encoding: set by lavc
+ * - decoding: set by user
*/
int bits_per_sample;
/**
- * prediction method (needed for huffyuv)
- * encoding: set by user
- * decoding: unused
+ * prediction method (needed for huffyuv).
+ * - encoding: set by user
+ * - decoding: unused
*/
int prediction_method;
#define FF_PRED_LEFT 0
@@ -807,23 +876,23 @@ typedef struct AVCodecContext {
#define FF_PRED_MEDIAN 2
/**
- * aspect ratio. (0 if unknown)
- * encoding: set by user.
- * decoding: set by lavc.
+ * aspect ratio (0 if unknown).
+ * - encoding: set by user.
+ * - decoding: set by lavc.
*/
float aspect_ratio;
/**
- * the picture in the bitstream
- * encoding: set by lavc
- * decoding: set by lavc
+ * the picture in the bitstream.
+ * - encoding: set by lavc
+ * - decoding: set by lavc
*/
AVFrame *coded_frame;
/**
- * debug
- * encoding: set by user.
- * decoding: set by user.
+ * debug.
+ * - encoding: set by user.
+ * - decoding: set by user.
*/
int debug;
#define FF_DEBUG_PICT_INFO 1
@@ -836,44 +905,45 @@ typedef struct AVCodecContext {
#define FF_DEBUG_SKIP 0x00000080
#define FF_DEBUG_STARTCODE 0x00000100
#define FF_DEBUG_PTS 0x00000200
+#define FF_DEBUG_ER 0x00000400
/**
- * error
- * encoding: set by lavc if flags&CODEC_FLAG_PSNR
- * decoding: unused
+ * error.
+ * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
+ * - decoding: unused
*/
uint64_t error[4];
/**
- * minimum MB quantizer
- * encoding: set by user.
- * decoding: unused
+ * minimum MB quantizer.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int mb_qmin;
/**
- * maximum MB quantizer
- * encoding: set by user.
- * decoding: unused
+ * maximum MB quantizer.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int mb_qmax;
/**
- * motion estimation compare function
- * encoding: set by user.
- * decoding: unused
+ * motion estimation compare function.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int me_cmp;
/**
- * subpixel motion estimation compare function
- * encoding: set by user.
- * decoding: unused
+ * subpixel motion estimation compare function.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int me_sub_cmp;
/**
- * macroblock compare function (not supported yet)
- * encoding: set by user.
- * decoding: unused
+ * macroblock compare function (not supported yet).
+ * - encoding: set by user.
+ * - decoding: unused
*/
int mb_cmp;
#define FF_CMP_SAD 0
@@ -887,79 +957,179 @@ typedef struct AVCodecContext {
#define FF_CMP_CHROMA 256
/**
- * ME diamond size & shape
- * encoding: set by user.
- * decoding: unused
+ * ME diamond size & shape.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int dia_size;
/**
- * amount of previous MV predictors (2a+1 x 2a+1 square)
- * encoding: set by user.
- * decoding: unused
+ * amount of previous MV predictors (2a+1 x 2a+1 square).
+ * - encoding: set by user.
+ * - decoding: unused
*/
int last_predictor_count;
/**
- * pre pass for motion estimation
- * encoding: set by user.
- * decoding: unused
+ * pre pass for motion estimation.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int pre_me;
/**
- * motion estimation pre pass compare function
- * encoding: set by user.
- * decoding: unused
+ * motion estimation pre pass compare function.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int me_pre_cmp;
/**
- * ME pre pass diamond size & shape
- * encoding: set by user.
- * decoding: unused
+ * ME pre pass diamond size & shape.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int pre_dia_size;
/**
- * subpel ME quality
- * encoding: set by user.
- * decoding: unused
+ * subpel ME quality.
+ * - encoding: set by user.
+ * - decoding: unused
*/
int me_subpel_quality;
/**
- * callback to negotiate the pixelFormat
+ * callback to negotiate the pixelFormat.
* @param fmt is the list of formats which are supported by the codec,
* its terminated by -1 as 0 is a valid format, the formats are ordered by quality
* the first is allways the native one
* @return the choosen format
- * encoding: unused
- * decoding: set by user, if not set then the native format will always be choosen
+ * - encoding: unused
+ * - decoding: set by user, if not set then the native format will always be choosen
*/
enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
+
+ /**
+ * DTG active format information (additionnal aspect ratio
+ * information only used in DVB MPEG2 transport streams). 0 if
+ * not set.
+ *
+ * - encoding: unused.
+ * - decoding: set by decoder
+ */
+ int dtg_active_format;
+#define FF_DTG_AFD_SAME 8
+#define FF_DTG_AFD_4_3 9
+#define FF_DTG_AFD_16_9 10
+#define FF_DTG_AFD_14_9 11
+#define FF_DTG_AFD_4_3_SP_14_9 13
+#define FF_DTG_AFD_16_9_SP_14_9 14
+#define FF_DTG_AFD_SP_4_3 15
+
+ /**
+ * Maximum motion estimation search range in subpel units.
+ * if 0 then no limit
+ *
+ * - encoding: set by user.
+ * - decoding: unused.
+ */
+ int me_range;
+
+ /**
+ * frame_rate_base.
+ * for variable fps this is 1
+ * - encoding: set by user.
+ * - decoding: set by lavc.
+ * @todo move this after frame_rate
+ */
+
+ int frame_rate_base;
+ /**
+ * intra quantizer bias.
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int intra_quant_bias;
+#define FF_DEFAULT_QUANT_BIAS 999999
+
+ /**
+ * inter quantizer bias.
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int inter_quant_bias;
+
} AVCodecContext;
+
+/**
+ * AVOption.
+ */
+typedef struct AVOption {
+ /** options' name */
+ const char *name; /* if name is NULL, it indicates a link to next */
+ /** short English text help or const struct AVOption* subpointer */
+ const char *help; // const struct AVOption* sub;
+ /** offset to context structure where the parsed value should be stored */
+ int offset;
+ /** options' type */
+ int type;
+#define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
+#define FF_OPT_TYPE_DOUBLE 2 ///< double
+#define FF_OPT_TYPE_INT 3 ///< integer
+#define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
+#define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
+//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
+#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
+#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
+ /** min value (min == max -> no limits) */
+ double min;
+ /** maximum value for double/int */
+ double max;
+ /** default boo [0,1]l/double/int value */
+ double defval;
+ /**
+ * default string value (with optional semicolon delimited extra option-list
+ * i.e. option1;option2;option3
+ * defval might select other then first argument as default
+ */
+ const char *defstr;
+#define FF_OPT_MAX_DEPTH 10
+} AVOption;
+
+/**
+ * Parse option(s) and sets fields in passed structure
+ * @param strct structure where the parsed results will be written
+ * @param list list with AVOptions
+ * @param opts string with options for parsing
+ */
+int avoption_parse(void* strct, const AVOption* list, const char* opts);
+
+
+/**
+ * AVCodec.
+ */
typedef struct AVCodec {
const char *name;
int type;
int id;
int priv_data_size;
int (*init)(AVCodecContext *);
- int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
+ int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
int (*close)(AVCodecContext *);
int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
- UINT8 *buf, int buf_size);
+ uint8_t *buf, int buf_size);
int capabilities;
+ const AVOption *options;
struct AVCodec *next;
} AVCodec;
-/**
+/**
* four components are given, that's all.
* the last component is alpha
*/
typedef struct AVPicture {
- UINT8 *data[4];
+ uint8_t *data[4];
int linesize[4];
} AVPicture;
@@ -1003,6 +1173,7 @@ extern AVCodec mace3_decoder;
extern AVCodec mace6_decoder;
extern AVCodec huffyuv_decoder;
extern AVCodec oggvorbis_decoder;
+extern AVCodec cyuv_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
@@ -1062,7 +1233,7 @@ void img_resample(ImgReSampleContext *s,
void img_resample_close(ImgReSampleContext *s);
-int avpicture_fill(AVPicture *picture, UINT8 *ptr,
+int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height);
int avpicture_get_size(int pix_fmt, int width, int height);
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
@@ -1087,8 +1258,6 @@ unsigned avcodec_version(void);
unsigned avcodec_build(void);
void avcodec_init(void);
-void avcodec_set_bit_exact(void);
-
void register_avcodec(AVCodec *format);
AVCodec *avcodec_find_encoder(enum CodecID id);
AVCodec *avcodec_find_encoder_by_name(const char *name);
@@ -1104,18 +1273,18 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
-int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
+int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
- UINT8 *buf, int buf_size);
+ uint8_t *buf, int buf_size);
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
- UINT8 *buf, int buf_size);
-int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
+ uint8_t *buf, int buf_size);
+int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
int *data_size_ptr,
- UINT8 *buf, int buf_size);
-int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
+ uint8_t *buf, int buf_size);
+int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const short *samples);
-int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
+int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict);
int avcodec_close(AVCodecContext *avctx);
@@ -1124,40 +1293,21 @@ void avcodec_register_all(void);
void avcodec_flush_buffers(AVCodecContext *avctx);
-typedef struct {
- /** options' name with default value*/
- const char* name;
- /** English text help */
- const char* help;
- /** type of variable */
- int type;
-#define FF_CONF_TYPE_BOOL 1 // boolean - true,1,on (or simply presence)
-#define FF_CONF_TYPE_DOUBLE 2 // double
-#define FF_CONF_TYPE_INT 3 // integer
-#define FF_CONF_TYPE_STRING 4 // string (finished with \0)
-#define FF_CONF_TYPE_MASK 0x1f // mask for types - upper bits are various flags
-#define FF_CONF_TYPE_EXPERT 0x20 // flag for expert option
-#define FF_CONF_TYPE_FLAG (FF_CONF_TYPE_BOOL | 0x40)
-#define FF_CONF_TYPE_RCOVERIDE (FF_CONF_TYPE_STRING | 0x80)
- /** where the parsed value should be stored */
- void* val;
- /** min value (min == max -> no limits) */
- double min;
- /** maximum value for double/int */
- double max;
- /** default boo [0,1]l/double/int value */
- double defval;
- /**
- * default string value (with optional semicolon delimited extra option-list
- * i.e. option1;option2;option3
- * defval might select other then first argument as default
- */
- const char* defstr;
- /** char* list of supported codecs (i.e. ",msmpeg4,h263," NULL - everything */
- const char* supported;
-} avc_config_t;
+/* misc usefull functions */
+/**
+ * reduce a fraction.
+ * this is usefull for framerate calculations
+ * @param max the maximum allowed for dst_nom & dst_den
+ * @return 1 if exact, 0 otherwise
+ */
+int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
+
+/**
+ * rescale a 64bit integer.
+ * a simple a*b/c isnt possible as it can overflow
+ */
+int64_t av_rescale(int64_t a, int b, int c);
-void avcodec_getopt(AVCodecContext* avctx, const char* str, avc_config_t** config);
/**
* Interface for 0.5.0 version
@@ -1166,7 +1316,7 @@ void avcodec_getopt(AVCodecContext* avctx, const char* str, avc_config_t** confi
*/
typedef struct {
- // compressed size used from given memory buffer
+ /// compressed size used from given memory buffer
int size;
/// I/P/B frame type
int frame_type;
@@ -1243,7 +1393,7 @@ void av_free(void *ptr);
char *av_strdup(const char *s);
void __av_freep(void **ptr);
#define av_freep(p) __av_freep((void **)(p))
-void *av_fast_realloc(void *ptr, int *size, int min_size);
+void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
/* for static data only */
/* call av_free_static to release all staticaly allocated tables */
void av_free_static(void);
diff --git a/src/libffmpeg/libavcodec/common.c b/src/libffmpeg/libavcodec/common.c
index aa766280b..068195384 100644
--- a/src/libffmpeg/libavcodec/common.c
+++ b/src/libffmpeg/libavcodec/common.c
@@ -18,9 +18,15 @@
*
* alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
*/
+
+/**
+ * @file common.c
+ * common internal api.
+ */
+
#include "avcodec.h"
-const UINT8 ff_sqrt_tab[128]={
+const uint8_t ff_sqrt_tab[128]={
0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
@@ -39,9 +45,9 @@ const uint8_t ff_log2_tab[256]={
};
void init_put_bits(PutBitContext *s,
- UINT8 *buffer, int buffer_size,
+ uint8_t *buffer, int buffer_size,
void *opaque,
- void (*write_data)(void *, UINT8 *, int))
+ void (*write_data)(void *, uint8_t *, int))
{
s->buf = buffer;
s->buf_end = s->buf + buffer_size;
@@ -62,12 +68,12 @@ void init_put_bits(PutBitContext *s,
}
/* return the number of bits output */
-INT64 get_bit_count(PutBitContext *s)
+int64_t get_bit_count(PutBitContext *s)
{
#ifdef ALT_BITSTREAM_WRITER
return s->data_out_size * 8 + s->index;
#else
- return (s->buf_ptr - s->buf + s->data_out_size) * 8 + 32 - (INT64)s->bit_left;
+ return (s->buf_ptr - s->buf + s->data_out_size) * 8 + 32 - (int64_t)s->bit_left;
#endif
}
@@ -110,7 +116,7 @@ void put_string(PutBitContext * pbc, char *s)
/* bit input functions */
void init_get_bits(GetBitContext *s,
- UINT8 *buffer, int bit_size)
+ const uint8_t *buffer, int bit_size)
{
const int buffer_size= (bit_size+7)>>3;
@@ -160,16 +166,16 @@ int check_marker(GetBitContext *s, const char *msg)
#define GET_DATA(v, table, i, wrap, size) \
{\
- const UINT8 *ptr = (UINT8 *)table + i * wrap;\
+ const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
switch(size) {\
case 1:\
- v = *(UINT8 *)ptr;\
+ v = *(const uint8_t *)ptr;\
break;\
case 2:\
- v = *(UINT16 *)ptr;\
+ v = *(const uint16_t *)ptr;\
break;\
default:\
- v = *(UINT32 *)ptr;\
+ v = *(const uint32_t *)ptr;\
break;\
}\
}
@@ -194,10 +200,10 @@ static int build_table(VLC *vlc, int table_nb_bits,
int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
- UINT32 code_prefix, int n_prefix)
+ uint32_t code_prefix, int n_prefix)
{
int i, j, k, n, table_size, table_index, nb, n1, index;
- UINT32 code;
+ uint32_t code;
VLC_TYPE (*table)[2];
table_size = 1 << table_nb_bits;
@@ -335,7 +341,7 @@ void free_vlc(VLC *vlc)
av_free(vlc->table);
}
-int ff_gcd(int a, int b){
+int64_t ff_gcd(int64_t a, int64_t b){
if(b) return ff_gcd(b, a%b);
else return a;
}
diff --git a/src/libffmpeg/libavcodec/common.h b/src/libffmpeg/libavcodec/common.h
index 893b7ed64..6c0271916 100644
--- a/src/libffmpeg/libavcodec/common.h
+++ b/src/libffmpeg/libavcodec/common.h
@@ -1,9 +1,11 @@
+/**
+ * @file common.h
+ * common internal api header.
+ */
+
#ifndef COMMON_H
#define COMMON_H
-#define FFMPEG_VERSION_INT 0x000406
-#define FFMPEG_VERSION "0.4.6"
-
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# define CONFIG_WIN32
#endif
@@ -37,6 +39,34 @@
#define M_PI 3.14159265358979323846
#endif
+#include <stddef.h>
+#ifndef offsetof
+# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
+#endif
+
+#define AVOPTION_CODEC_BOOL(name, help, field) \
+ { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_BOOL }
+#define AVOPTION_CODEC_DOUBLE(name, help, field, minv, maxv, defval) \
+ { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_DOUBLE, minv, maxv, defval }
+#define AVOPTION_CODEC_FLAG(name, help, field, flag, defval) \
+ { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_FLAG, flag, 0, defval }
+#define AVOPTION_CODEC_INT(name, help, field, minv, maxv, defval) \
+ { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_INT, minv, maxv, defval }
+#define AVOPTION_CODEC_STRING(name, help, field, str, val) \
+ { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_STRING, .defval = val, .defstr = str }
+#define AVOPTION_CODEC_RCOVERRIDE(name, help, field) \
+ { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_RCOVERRIDE, .defval = 0, .defstr = NULL }
+#define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
+#define AVOPTION_END() AVOPTION_SUB(NULL)
+
+struct AVOption;
+#ifdef HAVE_MMX
+extern const struct AVOption avoptions_common[3 + 5];
+#else
+extern const struct AVOption avoptions_common[3];
+#endif
+extern const struct AVOption avoptions_workaround_bug[11];
+
#endif /* HAVE_AV_CONFIG_H */
/* Suppress restrict if it was not defined in config.h. */
@@ -54,33 +84,24 @@
/* windows */
-typedef unsigned short UINT16;
-typedef signed short INT16;
-typedef unsigned char UINT8;
-typedef unsigned int UINT32;
-typedef unsigned __int64 UINT64;
-typedef signed char INT8;
-typedef signed int INT32;
-typedef signed __int64 INT64;
-
-typedef UINT8 uint8_t;
-typedef INT8 int8_t;
-typedef UINT16 uint16_t;
-typedef INT16 int16_t;
-typedef UINT32 uint32_t;
-typedef INT32 int32_t;
-typedef UINT64 uint64_t;
-typedef INT64 int64_t;
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+typedef unsigned __int64 uint64_t;
+typedef signed char int8_t;
+typedef signed int int32_t;
+typedef signed __int64 int64_t;
# ifndef __MINGW32__
-# define INT64_C(c) (c ## i64)
-# define UINT64_C(c) (c ## i64)
+# define int64_t_C(c) (c ## i64)
+# define uint64_t_C(c) (c ## i64)
# define inline __inline
# else
-# define INT64_C(c) (c ## LL)
-# define UINT64_C(c) (c ## ULL)
+# define int64_t_C(c) (c ## LL)
+# define uint64_t_C(c) (c ## ULL)
# endif /* __MINGW32__ */
# ifdef _DEBUG
@@ -96,20 +117,11 @@ typedef INT64 int64_t;
#include <inttypes.h>
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned int UINT32;
-typedef unsigned long long UINT64;
-typedef signed char INT8;
-typedef signed short INT16;
-typedef signed int INT32;
-typedef signed long long INT64;
-
#ifdef HAVE_AV_CONFIG_H
-#ifndef INT64_C
-#define INT64_C(c) (c ## LL)
-#define UINT64_C(c) (c ## ULL)
+#ifndef int64_t_C
+#define int64_t_C(c) (c ## LL)
+#define uint64_t_C(c) (c ## ULL)
#endif
#ifdef USE_FASTMEMCPY
@@ -127,23 +139,10 @@ typedef signed long long INT64;
# include <inttypes.h>
-# ifndef __WINE_WINDEF16_H
-/* workaround for typedef conflict in MPlayer (wine typedefs) */
-typedef unsigned short UINT16;
-typedef signed short INT16;
-# endif
-
-typedef unsigned char UINT8;
-typedef unsigned int UINT32;
-typedef unsigned long long UINT64;
-typedef signed char INT8;
-typedef signed int INT32;
-typedef signed long long INT64;
-
# ifdef HAVE_AV_CONFIG_H
-# ifndef INT64_C
-# define INT64_C(c) (c ## LL)
-# define UINT64_C(c) (c ## ULL)
+# ifndef int64_t_C
+# define int64_t_C(c) (c ## LL)
+# define uint64_t_C(c) (c ## ULL)
# endif
# ifdef USE_FASTMEMCPY
@@ -169,6 +168,7 @@ typedef signed long long INT64;
# ifndef DEBUG
# define NDEBUG
# endif
+# include <assert.h>
/* dprintf macros */
# if defined(CONFIG_WIN32) && !defined(__MINGW32__)
@@ -229,26 +229,26 @@ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
struct PutBitContext;
-typedef void (*WriteDataFunc)(void *, UINT8 *, int);
+typedef void (*WriteDataFunc)(void *, uint8_t *, int);
typedef struct PutBitContext {
#ifdef ALT_BITSTREAM_WRITER
- UINT8 *buf, *buf_end;
+ uint8_t *buf, *buf_end;
int index;
#else
- UINT32 bit_buf;
+ uint32_t bit_buf;
int bit_left;
- UINT8 *buf, *buf_ptr, *buf_end;
+ uint8_t *buf, *buf_ptr, *buf_end;
#endif
- INT64 data_out_size; /* in bytes */
+ int64_t data_out_size; /* in bytes */
} PutBitContext;
void init_put_bits(PutBitContext *s,
- UINT8 *buffer, int buffer_size,
+ uint8_t *buffer, int buffer_size,
void *opaque,
- void (*write_data)(void *, UINT8 *, int));
+ void (*write_data)(void *, uint8_t *, int));
-INT64 get_bit_count(PutBitContext *s); /* XXX: change function name */
+int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */
void align_put_bits(PutBitContext *s);
void flush_put_bits(PutBitContext *s);
void put_string(PutBitContext * pbc, char *s);
@@ -256,17 +256,17 @@ void put_string(PutBitContext * pbc, char *s);
/* bit input */
typedef struct GetBitContext {
- UINT8 *buffer, *buffer_end;
+ const uint8_t *buffer, *buffer_end;
#ifdef ALT_BITSTREAM_READER
int index;
#elif defined LIBMPEG2_BITSTREAM_READER
- UINT8 *buffer_ptr;
- UINT32 cache;
+ uint8_t *buffer_ptr;
+ uint32_t cache;
int bit_count;
#elif defined A32_BITSTREAM_READER
- UINT32 *buffer_ptr;
- UINT32 cache0;
- UINT32 cache1;
+ uint32_t *buffer_ptr;
+ uint32_t cache0;
+ uint32_t cache1;
int bit_count;
#endif
int size_in_bits;
@@ -274,11 +274,11 @@ typedef struct GetBitContext {
static inline int get_bits_count(GetBitContext *s);
-#define VLC_TYPE INT16
+#define VLC_TYPE int16_t
typedef struct VLC {
int bits;
- VLC_TYPE (*table)[2]; // code, bits
+ VLC_TYPE (*table)[2]; ///< code, bits
int table_size, table_allocated;
} VLC;
@@ -294,7 +294,7 @@ typedef struct RL_VLC_ELEM {
/* used to avoid missaligned exceptions on some archs (alpha, ...) */
#ifdef ARCH_X86
-# define unaligned32(a) (*(UINT32*)(a))
+# define unaligned32(a) (*(uint32_t*)(a))
#else
# ifdef __GNUC__
static inline uint32_t unaligned32(const void *v) {
@@ -325,7 +325,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
st_out_bit_counts[st_current_index] += n;
#endif
// printf("put_bits=%d %x\n", n, value);
- XINE_ASSERT((n == 32 || value < (1U << n)), "?");
+ assert(n == 32 || value < (1U << n));
bit_buf = s->bit_buf;
bit_left = s->bit_left;
@@ -346,7 +346,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
s->buf_ptr[3] = bit_buf ;
} else
#endif
- *(UINT32 *)s->buf_ptr = be2me_32(bit_buf);
+ *(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
//printf("bitbuf = %08x\n", bit_buf);
s->buf_ptr+=4;
bit_left+=32 - n;
@@ -689,7 +689,7 @@ static inline void skip_bits1(GetBitContext *s){
}
void init_get_bits(GetBitContext *s,
- UINT8 *buffer, int buffer_size);
+ const uint8_t *buffer, int buffer_size);
int check_marker(GetBitContext *s, const char *msg);
void align_get_bits(GetBitContext *s);
@@ -772,6 +772,14 @@ static inline int get_vlc(GetBitContext *s, VLC *vlc)
return code;
}
+/**
+ * parses a vlc code, faster then get_vlc()
+ * @param bits is the number of bits which will be read at once, must be
+ * identical to nb_bits in init_vlc()
+ * @param max_depth is the number of times bits bits must be readed to completly
+ * read the longest vlc code
+ * = (max_vlc_length + bits - 1) / bits
+ */
static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
int bits, int max_depth)
{
@@ -786,6 +794,46 @@ static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
return code;
}
+//#define TRACE
+
+#ifdef TRACE
+
+static inline void print_bin(int bits, int n){
+ int i;
+
+ for(i=n-1; i>=0; i--){
+ printf("%d", (bits>>i)&1);
+ }
+ for(i=n; i<24; i++)
+ printf(" ");
+}
+
+static inline int get_bits_trace(GetBitContext *s, int n, char *file, char *func, int line){
+ int r= get_bits(s, n);
+
+ print_bin(r, n);
+ printf("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
+ return r;
+}
+static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, char *func, int line){
+ int show= show_bits(s, 24);
+ int pos= get_bits_count(s);
+ int r= get_vlc2(s, table, bits, max_depth);
+ int len= get_bits_count(s) - pos;
+ int bits2= show>>(24-len);
+
+ print_bin(bits2, len);
+
+ printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
+ return r;
+}
+
+#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+
+#endif //TRACE
/* define it to include statistics code (useful only for optimizing
codec efficiency */
@@ -878,7 +926,7 @@ static inline int clip(int a, int amin, int amax)
/* math */
extern const uint8_t ff_sqrt_tab[128];
-int ff_gcd(int a, int b);
+int64_t ff_gcd(int64_t a, int64_t b);
static inline int ff_sqrt(int a)
{
@@ -902,11 +950,15 @@ static inline int ff_sqrt(int a)
* converts fourcc string to int
*/
static inline int ff_get_fourcc(const char *s){
- XINE_ASSERT( strlen(s)==4, "lenght of value 's' != 4: %d", strlen(s) );
+ assert( strlen(s)==4 );
return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
}
+#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
+#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
+
+
void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max);
diff --git a/src/libffmpeg/libavcodec/dsputil.c b/src/libffmpeg/libavcodec/dsputil.c
index 01bc84a86..5f4190f75 100644
--- a/src/libffmpeg/libavcodec/dsputil.c
+++ b/src/libffmpeg/libavcodec/dsputil.c
@@ -18,17 +18,22 @@
*
* gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
*/
+
+/**
+ * @file dsputil.c
+ * DSP utils
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "xineutils.h"
+#include "simple_idct.h"
-int ff_bit_exact=0;
-UINT8 cropTbl[256 + 2 * MAX_NEG_CROP];
-UINT32 squareTbl[512];
+uint8_t cropTbl[256 + 2 * MAX_NEG_CROP];
+uint32_t squareTbl[512];
-const UINT8 ff_zigzag_direct[64] = {
+const uint8_t ff_zigzag_direct[64] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
@@ -40,9 +45,9 @@ const UINT8 ff_zigzag_direct[64] = {
};
/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
-UINT16 __align8 inv_zigzag_direct16[64];
+uint16_t __align8 inv_zigzag_direct16[64];
-const UINT8 ff_alternate_horizontal_scan[64] = {
+const uint8_t ff_alternate_horizontal_scan[64] = {
0, 1, 2, 3, 8, 9, 16, 17,
10, 11, 4, 5, 6, 7, 15, 14,
13, 12, 19, 18, 24, 25, 32, 33,
@@ -53,7 +58,7 @@ const UINT8 ff_alternate_horizontal_scan[64] = {
52, 53, 54, 55, 60, 61, 62, 63,
};
-const UINT8 ff_alternate_vertical_scan[64] = {
+const uint8_t ff_alternate_vertical_scan[64] = {
0, 8, 16, 24, 1, 9, 2, 10,
17, 25, 32, 40, 48, 56, 57, 49,
41, 33, 26, 18, 3, 11, 4, 12,
@@ -65,7 +70,7 @@ const UINT8 ff_alternate_vertical_scan[64] = {
};
/* a*inverse[b]>>32 == a/b for all 0<=a<=65536 && 2<=b<=255 */
-const UINT32 inverse[256]={
+const uint32_t inverse[256]={
0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757,
536870912, 477218589, 429496730, 390451573, 357913942, 330382100, 306783379, 286331154,
268435456, 252645136, 238609295, 226050911, 214748365, 204522253, 195225787, 186737709,
@@ -100,7 +105,19 @@ const UINT32 inverse[256]={
17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
};
-static int pix_sum_c(UINT8 * pix, int line_size)
+/* Input permutation for the simple_idct_mmx */
+static const uint8_t simple_mmx_permutation[64]={
+ 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
+ 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
+ 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
+ 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
+ 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
+ 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
+ 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
+ 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
+};
+
+static int pix_sum_c(uint8_t * pix, int line_size)
{
int s, i, j;
@@ -122,10 +139,10 @@ static int pix_sum_c(UINT8 * pix, int line_size)
return s;
}
-static int pix_norm1_c(UINT8 * pix, int line_size)
+static int pix_norm1_c(uint8_t * pix, int line_size)
{
int s, i, j;
- UINT32 *sq = squareTbl + 256;
+ uint32_t *sq = squareTbl + 256;
s = 0;
for (i = 0; i < 16; i++) {
@@ -171,10 +188,10 @@ static int pix_norm1_c(UINT8 * pix, int line_size)
}
-static int sse8_c(void *v, UINT8 * pix1, UINT8 * pix2, int line_size)
+static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size)
{
int s, i;
- UINT32 *sq = squareTbl + 256;
+ uint32_t *sq = squareTbl + 256;
s = 0;
for (i = 0; i < 8; i++) {
@@ -222,7 +239,7 @@ static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
return s;
}
-static void get_pixels_c(DCTELEM *restrict block, const UINT8 *pixels, int line_size)
+static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
{
int i;
@@ -241,8 +258,8 @@ static void get_pixels_c(DCTELEM *restrict block, const UINT8 *pixels, int line_
}
}
-static void diff_pixels_c(DCTELEM *restrict block, const UINT8 *s1,
- const UINT8 *s2, int stride){
+static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1,
+ const uint8_t *s2, int stride){
int i;
/* read the pixels */
@@ -262,11 +279,11 @@ static void diff_pixels_c(DCTELEM *restrict block, const UINT8 *s1,
}
-static void put_pixels_clamped_c(const DCTELEM *block, UINT8 *restrict pixels,
+static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* read the pixels */
for(i=0;i<8;i++) {
@@ -284,11 +301,11 @@ static void put_pixels_clamped_c(const DCTELEM *block, UINT8 *restrict pixels,
}
}
-static void add_pixels_clamped_c(const DCTELEM *block, UINT8 *restrict pixels,
+static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* read the pixels */
for(i=0;i<8;i++) {
@@ -703,7 +720,7 @@ PIXOP2(put, op_put)
#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
-static void gmc1_c(UINT8 *dst, UINT8 *src, int stride, int h, int x16, int y16, int rounder)
+static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
{
const int A=(16-x16)*(16-y16);
const int B=( x16)*(16-y16);
@@ -726,7 +743,7 @@ static void gmc1_c(UINT8 *dst, UINT8 *src, int stride, int h, int x16, int y16,
}
}
-static void gmc_c(UINT8 *dst, UINT8 *src, int stride, int h, int ox, int oy,
+static void gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
{
int y, vx, vy;
@@ -784,7 +801,7 @@ static void gmc_c(UINT8 *dst, UINT8 *src, int stride, int h, int ox, int oy,
}
}
-static inline void copy_block17(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h)
+static inline void copy_block17(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
for(i=0; i<h; i++)
@@ -799,7 +816,7 @@ static inline void copy_block17(UINT8 *dst, UINT8 *src, int dstStride, int srcSt
}
}
-static inline void copy_block9(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h)
+static inline void copy_block9(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
for(i=0; i<h; i++)
@@ -814,8 +831,8 @@ static inline void copy_block9(UINT8 *dst, UINT8 *src, int dstStride, int srcStr
#define QPEL_MC(r, OPNAME, RND, OP) \
-static void OPNAME ## mpeg4_qpel8_h_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h){\
- UINT8 *cm = cropTbl + MAX_NEG_CROP;\
+static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;\
int i;\
for(i=0; i<h; i++)\
{\
@@ -832,9 +849,9 @@ static void OPNAME ## mpeg4_qpel8_h_lowpass(UINT8 *dst, UINT8 *src, int dstStrid
}\
}\
\
-static void OPNAME ## mpeg4_qpel8_v_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride){\
+static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w=8;\
- UINT8 *cm = cropTbl + MAX_NEG_CROP;\
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;\
int i;\
for(i=0; i<w; i++)\
{\
@@ -860,8 +877,8 @@ static void OPNAME ## mpeg4_qpel8_v_lowpass(UINT8 *dst, UINT8 *src, int dstStrid
}\
}\
\
-static void OPNAME ## mpeg4_qpel16_h_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h){\
- UINT8 *cm = cropTbl + MAX_NEG_CROP;\
+static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;\
int i;\
\
for(i=0; i<h; i++)\
@@ -887,8 +904,8 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass(UINT8 *dst, UINT8 *src, int dstStri
}\
}\
\
-static void OPNAME ## mpeg4_qpel16_v_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride){\
- UINT8 *cm = cropTbl + MAX_NEG_CROP;\
+static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;\
int i;\
const int w=16;\
for(i=0; i<w; i++)\
@@ -931,367 +948,367 @@ static void OPNAME ## mpeg4_qpel16_v_lowpass(UINT8 *dst, UINT8 *src, int dstStri
}\
}\
\
-static void OPNAME ## qpel8_mc00_c (UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## pixels8_c(dst, src, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc10_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 half[64];\
+static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t half[64];\
put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\
}\
\
-static void OPNAME ## qpel8_mc20_c(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc30_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 half[64];\
+static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t half[64];\
put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\
}\
\
-static void OPNAME ## qpel8_mc01_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 half[64];\
+static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t half[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\
}\
\
-static void OPNAME ## qpel8_mc02_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
+static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
copy_block9(full, src, 16, stride, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
}\
\
-static void OPNAME ## qpel8_mc03_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 half[64];\
+static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t half[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\
}\
-void ff_ ## OPNAME ## qpel8_mc11_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfV[64];\
- UINT8 halfHV[64];\
+void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfV[64];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc11_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfHV[64];\
+static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
}\
-void ff_ ## OPNAME ## qpel8_mc31_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfV[64];\
- UINT8 halfHV[64];\
+void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfV[64];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc31_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfHV[64];\
+static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
}\
-void ff_ ## OPNAME ## qpel8_mc13_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfV[64];\
- UINT8 halfHV[64];\
+void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfV[64];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc13_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfHV[64];\
+static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
}\
-void ff_ ## OPNAME ## qpel8_mc33_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfV[64];\
- UINT8 halfHV[64];\
+void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfV[64];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc33_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfHV[64];\
+static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc21_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 halfH[72];\
- UINT8 halfHV[64];\
+static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t halfH[72];\
+ uint8_t halfHV[64];\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc23_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 halfH[72];\
- UINT8 halfHV[64];\
+static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t halfH[72];\
+ uint8_t halfHV[64];\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
}\
-void ff_ ## OPNAME ## qpel8_mc12_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfV[64];\
- UINT8 halfHV[64];\
+void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfV[64];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc12_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
+static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
}\
-void ff_ ## OPNAME ## qpel8_mc32_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
- UINT8 halfV[64];\
- UINT8 halfHV[64];\
+void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
+ uint8_t halfV[64];\
+ uint8_t halfHV[64];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
}\
-static void OPNAME ## qpel8_mc32_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[16*9];\
- UINT8 halfH[72];\
+static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[16*9];\
+ uint8_t halfH[72];\
copy_block9(full, src, 16, stride, 9);\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
}\
-static void OPNAME ## qpel8_mc22_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 halfH[72];\
+static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t halfH[72];\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
}\
-static void OPNAME ## qpel16_mc00_c (UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## pixels16_c(dst, src, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc10_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 half[256];\
+static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t half[256];\
put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\
}\
\
-static void OPNAME ## qpel16_mc20_c(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc30_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 half[256];\
+static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t half[256];\
put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\
}\
\
-static void OPNAME ## qpel16_mc01_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 half[256];\
+static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t half[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\
}\
\
-static void OPNAME ## qpel16_mc02_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
+static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
copy_block17(full, src, 24, stride, 17);\
OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
}\
\
-static void OPNAME ## qpel16_mc03_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 half[256];\
+static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t half[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\
}\
-void ff_ ## OPNAME ## qpel16_mc11_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfV[256];\
- UINT8 halfHV[256];\
+void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfV[256];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc11_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfHV[256];\
+static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
}\
-void ff_ ## OPNAME ## qpel16_mc31_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfV[256];\
- UINT8 halfHV[256];\
+void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfV[256];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc31_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfHV[256];\
+static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
}\
-void ff_ ## OPNAME ## qpel16_mc13_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfV[256];\
- UINT8 halfHV[256];\
+void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfV[256];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc13_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfHV[256];\
+static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
}\
-void ff_ ## OPNAME ## qpel16_mc33_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfV[256];\
- UINT8 halfHV[256];\
+void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfV[256];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc33_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfHV[256];\
+static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc21_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 halfH[272];\
- UINT8 halfHV[256];\
+static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t halfH[272];\
+ uint8_t halfHV[256];\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc23_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 halfH[272];\
- UINT8 halfHV[256];\
+static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t halfH[272];\
+ uint8_t halfHV[256];\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
}\
-void ff_ ## OPNAME ## qpel16_mc12_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfV[256];\
- UINT8 halfHV[256];\
+void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfV[256];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc12_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
+static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
}\
-void ff_ ## OPNAME ## qpel16_mc32_old_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
- UINT8 halfV[256];\
- UINT8 halfHV[256];\
+void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
+ uint8_t halfV[256];\
+ uint8_t halfHV[256];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
}\
-static void OPNAME ## qpel16_mc32_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 full[24*17];\
- UINT8 halfH[272];\
+static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t full[24*17];\
+ uint8_t halfH[272];\
copy_block17(full, src, 24, stride, 17);\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
}\
-static void OPNAME ## qpel16_mc22_c(UINT8 *dst, UINT8 *src, int stride){\
- UINT8 halfH[272];\
+static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
+ uint8_t halfH[272];\
put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
}
@@ -1406,7 +1423,7 @@ static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){
}
-static inline int pix_abs16x16_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static inline int pix_abs16x16_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
@@ -1434,7 +1451,7 @@ static inline int pix_abs16x16_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static int pix_abs16x16_x2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static int pix_abs16x16_x2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
@@ -1462,10 +1479,10 @@ static int pix_abs16x16_x2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static int pix_abs16x16_y2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static int pix_abs16x16_y2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
- UINT8 *pix3 = pix2 + line_size;
+ uint8_t *pix3 = pix2 + line_size;
s = 0;
for(i=0;i<16;i++) {
@@ -1492,10 +1509,10 @@ static int pix_abs16x16_y2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static int pix_abs16x16_xy2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static int pix_abs16x16_xy2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
- UINT8 *pix3 = pix2 + line_size;
+ uint8_t *pix3 = pix2 + line_size;
s = 0;
for(i=0;i<16;i++) {
@@ -1522,7 +1539,7 @@ static int pix_abs16x16_xy2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static inline int pix_abs8x8_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static inline int pix_abs8x8_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
@@ -1542,7 +1559,7 @@ static inline int pix_abs8x8_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static int pix_abs8x8_x2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static int pix_abs8x8_x2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
@@ -1562,10 +1579,10 @@ static int pix_abs8x8_x2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static int pix_abs8x8_y2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static int pix_abs8x8_y2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
- UINT8 *pix3 = pix2 + line_size;
+ uint8_t *pix3 = pix2 + line_size;
s = 0;
for(i=0;i<8;i++) {
@@ -1584,10 +1601,10 @@ static int pix_abs8x8_y2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
return s;
}
-static int pix_abs8x8_xy2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
+static int pix_abs8x8_xy2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
{
int s, i;
- UINT8 *pix3 = pix2 + line_size;
+ uint8_t *pix3 = pix2 + line_size;
s = 0;
for(i=0;i<8;i++) {
@@ -1614,7 +1631,15 @@ static int sad8x8_c(void *s, uint8_t *a, uint8_t *b, int stride){
return pix_abs8x8_c(a,b,stride);
}
-void ff_block_permute(DCTELEM *block, UINT8 *permutation, const UINT8 *scantable, int last)
+/**
+ * permutes an 8x8 block.
+ * @param block the block which will be permuted according to the given permutation vector
+ * @param permutation the permutation vector
+ * @param last the last non zero coefficient in scantable order, used to speed the permutation up
+ * @param scantable the used scantable, this is only used to speed the permutation up, the block is not
+ * (inverse) permutated to scantable order!
+ */
+void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last)
{
int i;
DCTELEM temp[64];
@@ -1635,6 +1660,9 @@ void ff_block_permute(DCTELEM *block, UINT8 *permutation, const UINT8 *scantable
}
}
+/**
+ * memset(blocks, 0, sizeof(DCTELEM)*6*64)
+ */
static void clear_blocks_c(DCTELEM *blocks)
{
memset(blocks, 0, sizeof(DCTELEM)*6*64);
@@ -1788,7 +1816,7 @@ static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2
int sum=0, i;
s->dsp.diff_pixels(temp, src1, src2, stride);
- s->fdct(temp);
+ s->dsp.fdct(temp);
for(i=0; i<64; i++)
sum+= ABS(temp[i]);
@@ -1823,7 +1851,7 @@ static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *s
static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
MpegEncContext * const s= (MpegEncContext *)c;
- const UINT8 *scantable= s->intra_scantable.permutated;
+ const uint8_t *scantable= s->intra_scantable.permutated;
uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
uint64_t __align8 aligned_bak[stride];
DCTELEM * const temp= (DCTELEM*)aligned_temp;
@@ -1875,7 +1903,7 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int
level= temp[i] + 64;
- XINE_ASSERT(level - 64,"?");
+ assert(level - 64);
if((level&(~127)) == 0){
bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
@@ -1888,7 +1916,7 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int
s->dct_unquantize(s, temp, 0, s->qscale);
}
- s->idct_add(bak, stride, temp);
+ s->dsp.idct_add(bak, stride, temp);
distoration= s->dsp.sse[1](NULL, bak, src1, stride);
@@ -1897,7 +1925,7 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int
static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
MpegEncContext * const s= (MpegEncContext *)c;
- const UINT8 *scantable= s->intra_scantable.permutated;
+ const uint8_t *scantable= s->intra_scantable.permutated;
uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
DCTELEM * const temp= (DCTELEM*)aligned_temp;
int i, last, run, bits, level, start_i;
@@ -1942,7 +1970,7 @@ static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, in
level= temp[i] + 64;
- XINE_ASSERT(level - 64,"?");
+ assert(level - 64);
if((level&(~127)) == 0){
bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
@@ -1960,7 +1988,20 @@ WARPER88_1616(quant_psnr8x8_c, quant_psnr16x16_c)
WARPER88_1616(rd8x8_c, rd16x16_c)
WARPER88_1616(bit8x8_c, bit16x16_c)
-void dsputil_init(DSPContext* c, unsigned mask)
+/* XXX: those functions should be suppressed ASAP when all IDCTs are
+ converted */
+static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ j_rev_dct (block);
+ put_pixels_clamped_c(block, dest, line_size);
+}
+static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ j_rev_dct (block);
+ add_pixels_clamped_c(block, dest, line_size);
+}
+
+void dsputil_init(DSPContext* c, AVCodecContext *avctx)
{
static int init_done = 0;
int i;
@@ -1981,6 +2022,23 @@ void dsputil_init(DSPContext* c, unsigned mask)
init_done = 1;
}
+#ifdef CONFIG_ENCODERS
+ if(avctx->dct_algo==FF_DCT_FASTINT)
+ c->fdct = fdct_ifast;
+ else
+ c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default
+#endif //CONFIG_ENCODERS
+
+ if(avctx->idct_algo==FF_IDCT_INT){
+ c->idct_put= ff_jref_idct_put;
+ c->idct_add= ff_jref_idct_add;
+ c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
+ }else{ //accurate/default
+ c->idct_put= simple_idct_put;
+ c->idct_add= simple_idct_add;
+ c->idct_permutation_type= FF_NO_IDCT_PERM;
+ }
+
c->get_pixels = get_pixels_c;
c->diff_pixels = diff_pixels_c;
c->put_pixels_clamped = put_pixels_clamped_c;
@@ -2083,37 +2141,43 @@ void dsputil_init(DSPContext* c, unsigned mask)
c->diff_bytes= diff_bytes_c;
#ifdef HAVE_MMX
- dsputil_init_mmx(c, mask);
- if (ff_bit_exact)
- {
- /* FIXME - AVCodec context should have flag for bitexact match */
- /* fprintf(stderr, "\n\n\nff_bit_exact %d\n\n\n\n", ff_bit_exact); */
- dsputil_set_bit_exact_mmx(c, mask);
- }
+ dsputil_init_mmx(c, avctx);
#endif
#ifdef ARCH_ARMV4L
- dsputil_init_armv4l(c, mask);
+ dsputil_init_armv4l(c, avctx);
#endif
#ifdef HAVE_MLIB
- dsputil_init_mlib(c, mask);
+ dsputil_init_mlib(c, avctx);
#endif
#ifdef ARCH_ALPHA
- dsputil_init_alpha(c, mask);
+ dsputil_init_alpha(c, avctx);
#endif
#ifdef ARCH_POWERPC
- dsputil_init_ppc(c, mask);
+ dsputil_init_ppc(c, avctx);
#endif
#ifdef HAVE_MMI
- dsputil_init_mmi(c, mask);
+ dsputil_init_mmi(c, avctx);
#endif
-}
-/* remove any non bit exact operation (testing purpose) */
-void avcodec_set_bit_exact(void)
-{
- ff_bit_exact=1;
-#ifdef HAVE_MMX
-// FIXME - better set_bit_exact
-// dsputil_set_bit_exact_mmx();
-#endif
+ switch(c->idct_permutation_type){
+ case FF_NO_IDCT_PERM:
+ for(i=0; i<64; i++)
+ c->idct_permutation[i]= i;
+ break;
+ case FF_LIBMPEG2_IDCT_PERM:
+ for(i=0; i<64; i++)
+ c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
+ break;
+ case FF_SIMPLE_IDCT_PERM:
+ for(i=0; i<64; i++)
+ c->idct_permutation[i]= simple_mmx_permutation[i];
+ break;
+ case FF_TRANSPOSE_IDCT_PERM:
+ for(i=0; i<64; i++)
+ c->idct_permutation[i]= ((i&7)<<3) | (i>>3);
+ break;
+ default:
+ fprintf(stderr, "Internal error, IDCT permutation not set\n");
+ }
}
+
diff --git a/src/libffmpeg/libavcodec/dsputil.h b/src/libffmpeg/libavcodec/dsputil.h
index 2220b4871..2cdb256f9 100644
--- a/src/libffmpeg/libavcodec/dsputil.h
+++ b/src/libffmpeg/libavcodec/dsputil.h
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file dsputil.h
+ * DSP utils.
+ */
+
#ifndef DSPUTIL_H
#define DSPUTIL_H
@@ -28,6 +34,7 @@
#endif
#undef DEBUG
+
/* dct code */
typedef short DCTELEM;
//typedef int DCTELEM;
@@ -40,16 +47,16 @@ void j_rev_dct (DCTELEM *data);
void ff_fdct_mmx(DCTELEM *block);
/* encoding scans */
-extern const UINT8 ff_alternate_horizontal_scan[64];
-extern const UINT8 ff_alternate_vertical_scan[64];
-extern const UINT8 ff_zigzag_direct[64];
+extern const uint8_t ff_alternate_horizontal_scan[64];
+extern const uint8_t ff_alternate_vertical_scan[64];
+extern const uint8_t ff_zigzag_direct[64];
/* pixel operations */
#define MAX_NEG_CROP 384
/* temporary */
-extern UINT32 squareTbl[512];
-extern UINT8 cropTbl[256 + 2 * MAX_NEG_CROP];
+extern uint32_t squareTbl[512];
+extern uint8_t cropTbl[256 + 2 * MAX_NEG_CROP];
/* minimum alignment rules ;)
@@ -63,22 +70,22 @@ i (michael) didnt check them, these are just the alignents which i think could b
*/
/*
-void get_pixels_c(DCTELEM *block, const UINT8 *pixels, int line_size);
-void diff_pixels_c(DCTELEM *block, const UINT8 *s1, const UINT8 *s2, int stride);
-void put_pixels_clamped_c(const DCTELEM *block, UINT8 *pixels, int line_size);
-void add_pixels_clamped_c(const DCTELEM *block, UINT8 *pixels, int line_size);
+void get_pixels_c(DCTELEM *block, const uint8_t *pixels, int line_size);
+void diff_pixels_c(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
+void put_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
+void add_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
void clear_blocks_c(DCTELEM *blocks);
*/
/* add and put pixel (decoding) */
// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
-typedef void (*op_pixels_func)(UINT8 *block/*align width (8 or 16)*/, const UINT8 *pixels/*align 1*/, int line_size, int h);
-typedef void (*qpel_mc_func)(UINT8 *dst/*align width (8 or 16)*/, UINT8 *src/*align 1*/, int stride);
+typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
+typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
#define DEF_OLD_QPEL(name)\
-void ff_put_ ## name (UINT8 *dst/*align width (8 or 16)*/, UINT8 *src/*align 1*/, int stride);\
-void ff_put_no_rnd_ ## name (UINT8 *dst/*align width (8 or 16)*/, UINT8 *src/*align 1*/, int stride);\
-void ff_avg_ ## name (UINT8 *dst/*align width (8 or 16)*/, UINT8 *src/*align 1*/, int stride);
+void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
+void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
+void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
DEF_OLD_QPEL(qpel16_mc11_old_c)
DEF_OLD_QPEL(qpel16_mc31_old_c)
@@ -101,22 +108,31 @@ static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
/* motion estimation */
-typedef int (*op_pixels_abs_func)(UINT8 *blk1/*align width (8 or 16)*/, UINT8 *blk2/*align 1*/, int line_size)/* __attribute__ ((const))*/;
+typedef int (*op_pixels_abs_func)(uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size)/* __attribute__ ((const))*/;
-typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, UINT8 *blk1/*align width (8 or 16)*/, UINT8 *blk2/*align 1*/, int line_size)/* __attribute__ ((const))*/;
+typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size)/* __attribute__ ((const))*/;
+/**
+ * DSPContext.
+ */
typedef struct DSPContext {
/* pixel ops : interface with DCT */
- void (*get_pixels)(DCTELEM *block/*align 16*/, const UINT8 *pixels/*align 8*/, int line_size);
- void (*diff_pixels)(DCTELEM *block/*align 16*/, const UINT8 *s1/*align 8*/, const UINT8 *s2/*align 8*/, int stride);
- void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, UINT8 *pixels/*align 8*/, int line_size);
- void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, UINT8 *pixels/*align 8*/, int line_size);
- void (*gmc1)(UINT8 *dst/*align 8*/, UINT8 *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
- void (*gmc )(UINT8 *dst/*align 8*/, UINT8 *src/*align 1*/, int stride, int h, int ox, int oy,
+ void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
+ void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
+ void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
+ void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
+ /**
+ * translational global motion compensation.
+ */
+ void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
+ /**
+ * global motion compensation.
+ */
+ void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
void (*clear_blocks)(DCTELEM *blocks/*align 16*/);
- int (*pix_sum)(UINT8 * pix, int line_size);
- int (*pix_norm1)(UINT8 * pix, int line_size);
+ int (*pix_sum)(uint8_t * pix, int line_size);
+ int (*pix_norm1)(uint8_t * pix, int line_size);
me_cmp_func sad[2]; /* identical to pix_absAxA except additional void * */
me_cmp_func sse[2];
me_cmp_func hadamard8_diff[2];
@@ -132,9 +148,44 @@ typedef struct DSPContext {
me_cmp_func mb_cmp[11];
/* maybe create an array for 16/8 functions */
+ /**
+ * Halfpel motion compensation with rounding (a+b+1)>>1.
+ * *pixels_tab[ 0->16x16 1->8x8 ][ xhalfpel + 2*yhalfpel ]
+ * @param block destination where the result is stored
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
op_pixels_func put_pixels_tab[2][4];
+
+ /**
+ * Halfpel motion compensation with rounding (a+b+1)>>1.
+ * *pixels_tab[ 0->16x16 1->8x8 ][ xhalfpel + 2*yhalfpel ]
+ * @param block destination into which the result is averaged (a+b+1)>>1
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
op_pixels_func avg_pixels_tab[2][4];
+
+ /**
+ * Halfpel motion compensation with no rounding (a+b)>>1.
+ * *pixels_tab[ 0->16x16 1->8x8 ][ xhalfpel + 2*yhalfpel ]
+ * @param block destination where the result is stored
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
op_pixels_func put_no_rnd_pixels_tab[2][4];
+
+ /**
+ * Halfpel motion compensation with no rounding (a+b)>>1.
+ * *pixels_tab[ 0->16x16 1->8x8 ][ xhalfpel + 2*yhalfpel ]
+ * @param block destination into which the result is averaged (a+b)>>1
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
op_pixels_func avg_no_rnd_pixels_tab[2][4];
qpel_mc_func put_qpel_pixels_tab[2][16];
qpel_mc_func avg_qpel_pixels_tab[2][16];
@@ -154,16 +205,53 @@ typedef struct DSPContext {
/* huffyuv specific */
void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
+
+ /* (I)DCT */
+ void (*fdct)(DCTELEM *block/* align 16*/);
+
+ /**
+ * block -> idct -> clip to unsigned 8 bit -> dest.
+ * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
+ * @param line_size size in bytes of a horizotal line of dest
+ */
+ void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
+
+ /**
+ * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
+ * @param line_size size in bytes of a horizotal line of dest
+ */
+ void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
+
+ /**
+ * idct input permutation.
+ * an example to avoid confusion:
+ * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
+ * - (x -> referece dct -> reference idct -> x)
+ * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
+ * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
+ */
+ uint8_t idct_permutation[64];
+ int idct_permutation_type;
+#define FF_NO_IDCT_PERM 1
+#define FF_LIBMPEG2_IDCT_PERM 2
+#define FF_SIMPLE_IDCT_PERM 3
+#define FF_TRANSPOSE_IDCT_PERM 4
+
} DSPContext;
-void dsputil_init(DSPContext* p, unsigned mask);
+void dsputil_init(DSPContext* p, AVCodecContext *avctx);
/**
* permute block according to permuatation.
* @param last last non zero element in scantable order
*/
-void ff_block_permute(DCTELEM *block, UINT8 *permutation, const UINT8 *scantable, int last);
+void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
+/**
+ * Empty mmx state.
+ * this must be called between any dsp function and float/double code.
+ * for example sin(); dsp->idct_put(); emms_c(); cos()
+ */
#define emms_c()
/* should be defined by architectures supporting
@@ -184,8 +272,8 @@ int mm_support(void);
extern int mm_flags;
-void add_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size);
-void put_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size);
+void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
+void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
#if 0
static inline void emms(void)
@@ -203,8 +291,8 @@ static inline void emms(void)
#define __align8 __attribute__ ((aligned (8)))
-void dsputil_init_mmx(DSPContext* c, unsigned mask);
-void dsputil_set_bit_exact_mmx(DSPContext* c, unsigned mask);
+void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
+void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_ARMV4L)
@@ -212,20 +300,20 @@ void dsputil_set_bit_exact_mmx(DSPContext* c, unsigned mask);
line ptimizations */
#define __align8 __attribute__ ((aligned (4)))
-void dsputil_init_armv4l(DSPContext* c, unsigned mask);
+void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx);
#elif defined(HAVE_MLIB)
/* SPARC/VIS IDCT needs 8-byte aligned DCT blocks */
#define __align8 __attribute__ ((aligned (8)))
-void dsputil_init_mlib(DSPContext* c, unsigned mask);
+void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_ALPHA)
#define __align8 __attribute__ ((aligned (8)))
-void dsputil_init_alpha(DSPContext* c, unsigned mask);
+void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_POWERPC)
@@ -239,13 +327,13 @@ extern int mm_flags;
#define __align8 __attribute__ ((aligned (16)))
-void dsputil_init_ppc(DSPContext* c, unsigned mask);
+void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
#elif defined(HAVE_MMI)
#define __align8 __attribute__ ((aligned (16)))
-void dsputil_init_mmi(DSPContext* c, unsigned mask);
+void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
#else
@@ -273,7 +361,7 @@ struct unaligned_32 { uint32_t l; } __attribute__((packed));
#endif /* !__GNUC__ */
/* PSNR */
-void get_psnr(UINT8 *orig_image[3], UINT8 *coded_image[3],
+void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
int orig_linesize[3], int coded_linesize,
AVCodecContext *avctx);
diff --git a/src/libffmpeg/libavcodec/dv.c b/src/libffmpeg/libavcodec/dv.c
index 554b593e7..6d661f4cf 100644
--- a/src/libffmpeg/libavcodec/dv.c
+++ b/src/libffmpeg/libavcodec/dv.c
@@ -16,6 +16,11 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file dv.c
+ * DV decoder.
+ */
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -32,15 +37,15 @@ typedef struct DVVideoDecodeContext {
VLC *vlc;
int sampling_411; /* 0 = 420, 1 = 411 */
int width, height;
- UINT8 *current_picture[3]; /* picture structure */
+ uint8_t *current_picture[3]; /* picture structure */
AVFrame picture;
int linesize[3];
DCTELEM block[5*6][64] __align8;
- UINT8 dv_zigzag[2][64];
- UINT8 idct_permutation[64];
+ uint8_t dv_zigzag[2][64];
+ uint8_t idct_permutation[64];
/* XXX: move it to static storage ? */
- UINT8 dv_shift[2][22][64];
- void (*idct_put[2])(UINT8 *dest, int line_size, DCTELEM *block);
+ uint8_t dv_shift[2][22][64];
+ void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block);
} DVVideoDecodeContext;
#include "dvdata.h"
@@ -76,7 +81,7 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
{
DVVideoDecodeContext *s = avctx->priv_data;
MpegEncContext s2;
- static int done;
+ static int done=0;
if (!done) {
int i;
@@ -115,12 +120,12 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
/* XXX: fix it */
memset(&s2, 0, sizeof(MpegEncContext));
s2.avctx = avctx;
- dsputil_init(&s2.dsp, avctx->dsp_mask);
+ dsputil_init(&s2.dsp, avctx);
if (DCT_common_init(&s2) < 0)
return -1;
- s->idct_put[0] = s2.idct_put;
- memcpy(s->idct_permutation, s2.idct_permutation, 64);
+ s->idct_put[0] = s2.dsp.idct_put;
+ memcpy(s->idct_permutation, s2.dsp.idct_permutation, 64);
memcpy(s->dv_zigzag[0], s2.intra_scantable.permutated, 64);
/* XXX: use MMX also for idct248 */
@@ -136,18 +141,18 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
//#define VLC_DEBUG
typedef struct BlockInfo {
- const UINT8 *shift_table;
- const UINT8 *scan_table;
- UINT8 pos; /* position in block */
- UINT8 eob_reached; /* true if EOB has been reached */
- UINT8 dct_mode;
- UINT8 partial_bit_count;
- UINT16 partial_bit_buffer;
+ const uint8_t *shift_table;
+ const uint8_t *scan_table;
+ uint8_t pos; /* position in block */
+ uint8_t eob_reached; /* true if EOB has been reached */
+ uint8_t dct_mode;
+ uint8_t partial_bit_count;
+ uint16_t partial_bit_buffer;
int shift_offset;
} BlockInfo;
/* block size in bits */
-static const UINT16 block_sizes[6] = {
+static const uint16_t block_sizes[6] = {
112, 112, 112, 112, 80, 80
};
@@ -161,8 +166,8 @@ static void dv_decode_ac(DVVideoDecodeContext *s,
{
int last_re_index;
int shift_offset = mb->shift_offset;
- const UINT8 *scan_table = mb->scan_table;
- const UINT8 *shift_table = mb->shift_table;
+ const uint8_t *scan_table = mb->scan_table;
+ const uint8_t *shift_table = mb->shift_table;
int pos = mb->pos;
int level, pos1, sign, run;
int partial_bit_count;
@@ -176,8 +181,8 @@ static void dv_decode_ac(DVVideoDecodeContext *s,
/* if we must parse a partial vlc, we do it here */
partial_bit_count = mb->partial_bit_count;
if (partial_bit_count > 0) {
- UINT8 buf[4];
- UINT32 v;
+ uint8_t buf[4];
+ uint32_t v;
int l, l1;
GetBitContext gb1;
@@ -298,21 +303,21 @@ static inline void bit_copy(PutBitContext *pb, GetBitContext *gb, int bits_left)
/* mb_x and mb_y are in units of 8 pixels */
static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
- UINT8 *buf_ptr1,
- const UINT16 *mb_pos_ptr)
+ uint8_t *buf_ptr1,
+ const uint16_t *mb_pos_ptr)
{
int quant, dc, dct_mode, class1, j;
int mb_index, mb_x, mb_y, v, last_index;
DCTELEM *block, *block1;
int c_offset, bits_left;
- UINT8 *y_ptr;
+ uint8_t *y_ptr;
BlockInfo mb_data[5 * 6], *mb, *mb1;
- void (*idct_put)(UINT8 *dest, int line_size, DCTELEM *block);
- UINT8 *buf_ptr;
+ void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block);
+ uint8_t *buf_ptr;
PutBitContext pb, vs_pb;
- UINT8 mb_bit_buffer[80 + 4]; /* allow some slack */
+ uint8_t mb_bit_buffer[80 + 4]; /* allow some slack */
int mb_bit_count;
- UINT8 vs_bit_buffer[5 * 80 + 4]; /* allow some slack */
+ uint8_t vs_bit_buffer[5 * 80 + 4]; /* allow some slack */
int vs_bit_count;
memset(s->block, 0, sizeof(s->block));
@@ -493,12 +498,12 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
144000 bytes for PAL) */
static int dvvideo_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
DVVideoDecodeContext *s = avctx->priv_data;
int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size;
- UINT8 *buf_ptr;
- const UINT16 *mb_pos_ptr;
+ uint8_t *buf_ptr;
+ const uint16_t *mb_pos_ptr;
/* parse id */
init_get_bits(&s->gb, buf, buf_size*8);
@@ -532,25 +537,28 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
/* init size */
width = 720;
if (dsf) {
- avctx->frame_rate = 25 * FRAME_RATE_BASE;
+ avctx->frame_rate = 25;
packet_size = PAL_FRAME_SIZE;
height = 576;
nb_dif_segs = 12;
} else {
- avctx->frame_rate = 30 * FRAME_RATE_BASE;
+ avctx->frame_rate = 30;
packet_size = NTSC_FRAME_SIZE;
height = 480;
nb_dif_segs = 10;
}
+ avctx->frame_rate_base= 1;
/* NOTE: we only accept several full frames */
if (buf_size < packet_size)
return -1;
- /* XXX: is it correct to assume that 420 is always used in PAL
- mode ? */
- s->sampling_411 = !dsf;
+ /* NTSC[dsf == 0] is always 720x480, 4:1:1
+ * PAL[dsf == 1] is always 720x576, 4:2:0 for IEC 68134[apt == 0]
+ * but for the SMPTE 314M[apt == 1] it is 720x576, 4:1:1
+ */
+ s->sampling_411 = !dsf || apt;
if (s->sampling_411) {
- mb_pos_ptr = dv_place_411;
+ mb_pos_ptr = dsf ? dv_place_411P : dv_place_411;
avctx->pix_fmt = PIX_FMT_YUV411P;
} else {
mb_pos_ptr = dv_place_420;
@@ -642,9 +650,9 @@ static int dvaudio_decode_init(AVCodecContext *avctx)
return 0;
}
-static UINT16 dv_audio_12to16(UINT16 sample)
+static uint16_t dv_audio_12to16(uint16_t sample)
{
- UINT16 shift, result;
+ uint16_t shift, result;
sample = (sample < 0x800) ? sample : sample | 0xf000;
shift = (sample & 0xf00) >> 8;
@@ -676,13 +684,13 @@ static UINT16 dv_audio_12to16(UINT16 sample)
*/
static int dvaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
DVVideoDecodeContext *s = avctx->priv_data;
- const UINT16 (*unshuffle)[9];
+ const uint16_t (*unshuffle)[9];
int smpls, freq, quant, sys, stride, difseg, ad, dp, nb_dif_segs, i;
- UINT16 lc, rc;
- UINT8 *buf_ptr;
+ uint16_t lc, rc;
+ uint8_t *buf_ptr;
/* parse id */
init_get_bits(&s->gb, &buf[AAUX_OFFSET], 5*8);
@@ -742,10 +750,10 @@ static int dvaudio_decode_frame(AVCodecContext *avctx,
if (difseg >= nb_dif_segs/2)
goto out; /* We're not doing 4ch at this time */
- lc = ((UINT16)buf_ptr[dp] << 4) |
- ((UINT16)buf_ptr[dp+2] >> 4);
- rc = ((UINT16)buf_ptr[dp+1] << 4) |
- ((UINT16)buf_ptr[dp+2] & 0x0f);
+ lc = ((uint16_t)buf_ptr[dp] << 4) |
+ ((uint16_t)buf_ptr[dp+2] >> 4);
+ rc = ((uint16_t)buf_ptr[dp+1] << 4) |
+ ((uint16_t)buf_ptr[dp+2] & 0x0f);
lc = dv_audio_12to16(lc);
rc = dv_audio_12to16(rc);
diff --git a/src/libffmpeg/libavcodec/dvdata.h b/src/libffmpeg/libavcodec/dvdata.h
index 4e1fc39c7..29aea4022 100644
--- a/src/libffmpeg/libavcodec/dvdata.h
+++ b/src/libffmpeg/libavcodec/dvdata.h
@@ -17,10 +17,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * @file dvdata.h
+ * Constants for DV codec.
+ */
+
#define NB_DV_VLC 409
#define AAUX_OFFSET (80*6 + 80*16*3 + 3)
-static const UINT16 dv_vlc_bits[409] = {
+static const uint16_t dv_vlc_bits[409] = {
0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a,
0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2,
@@ -75,7 +80,7 @@ static const UINT16 dv_vlc_bits[409] = {
0x0006,
};
-static const UINT8 dv_vlc_len[409] = {
+static const uint8_t dv_vlc_len[409] = {
2, 3, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7,
7, 7, 7, 7, 7, 8, 8, 8,
@@ -130,7 +135,7 @@ static const UINT8 dv_vlc_len[409] = {
4,
};
-static const UINT8 dv_vlc_run[409] = {
+static const uint8_t dv_vlc_run[409] = {
0, 0, 1, 0, 0, 2, 1, 0,
0, 3, 4, 0, 0, 5, 6, 2,
1, 1, 0, 0, 0, 7, 8, 9,
@@ -185,7 +190,7 @@ static const UINT8 dv_vlc_run[409] = {
0,
};
-static const UINT8 dv_vlc_level[409] = {
+static const uint8_t dv_vlc_level[409] = {
1, 2, 1, 3, 4, 1, 2, 5,
6, 1, 1, 7, 8, 1, 1, 2,
3, 4, 9, 10, 11, 1, 1, 1,
@@ -242,7 +247,7 @@ static const UINT8 dv_vlc_level[409] = {
/* Specific zigzag scan for 248 idct. NOTE that unlike the
specification, we interleave the fields */
-static const UINT8 dv_248_zigzag[64] = {
+static const uint8_t dv_248_zigzag[64] = {
0, 8, 1, 9, 16, 24, 2, 10,
17, 25, 32, 40, 48, 56, 33, 41,
18, 26, 3, 11, 4, 12, 19, 27,
@@ -254,7 +259,7 @@ static const UINT8 dv_248_zigzag[64] = {
};
/* unquant tables (not used directly) */
-static const UINT8 dv_88_areas[64] = {
+static const uint8_t dv_88_areas[64] = {
0,0,0,1,1,1,2,2,
0,0,1,1,1,2,2,2,
0,1,1,1,2,2,2,3,
@@ -265,7 +270,7 @@ static const UINT8 dv_88_areas[64] = {
2,2,3,3,3,3,3,3,
};
-static const UINT8 dv_248_areas[64] = {
+static const uint8_t dv_248_areas[64] = {
0,0,1,1,1,2,2,3,
0,0,1,1,2,2,2,3,
0,1,1,2,2,2,3,3,
@@ -276,7 +281,7 @@ static const UINT8 dv_248_areas[64] = {
1,2,2,3,3,3,3,3,
};
-static UINT8 dv_quant_shifts[22][4] = {
+static uint8_t dv_quant_shifts[22][4] = {
{ 3,3,4,4 },
{ 3,3,4,4 },
{ 2,3,3,4 },
@@ -301,12 +306,12 @@ static UINT8 dv_quant_shifts[22][4] = {
{ 0,0,0,0 },
};
-static const UINT8 dv_quant_offset[4] = { 6, 3, 0, 1 };
+static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 };
/* NOTE: I prefer hardcoding the positionning of dv blocks, it is
simpler :-) */
-static const UINT16 dv_place_420[1620] = {
+static const uint16_t dv_place_420[1620] = {
0x0c24, 0x2412, 0x3036, 0x0000, 0x1848,
0x0e24, 0x2612, 0x3236, 0x0200, 0x1a48,
0x1024, 0x2812, 0x3436, 0x0400, 0x1c48,
@@ -633,7 +638,334 @@ static const UINT16 dv_place_420[1620] = {
0x0a34, 0x2222, 0x2e46, 0x4610, 0x1658,
};
-static const UINT16 dv_place_411[1350] = {
+static const uint16_t dv_place_411P[1620] = {
+ 0x0c24, 0x2710, 0x3334, 0x0000, 0x1848,
+ 0x0d24, 0x2810, 0x3434, 0x0100, 0x1948,
+ 0x0e24, 0x2910, 0x3534, 0x0200, 0x1a48,
+ 0x0f24, 0x2914, 0x3538, 0x0300, 0x1b48,
+ 0x1024, 0x2814, 0x3438, 0x0400, 0x1c48,
+ 0x1124, 0x2714, 0x3338, 0x0500, 0x1d48,
+ 0x1128, 0x2614, 0x3238, 0x0504, 0x1d4c,
+ 0x1028, 0x2514, 0x3138, 0x0404, 0x1c4c,
+ 0x0f28, 0x2414, 0x3038, 0x0304, 0x1b4c,
+ 0x0e28, 0x2418, 0x303c, 0x0204, 0x1a4c,
+ 0x0d28, 0x2518, 0x313c, 0x0104, 0x194c,
+ 0x0c28, 0x2618, 0x323c, 0x0004, 0x184c,
+ 0x0c2c, 0x2718, 0x333c, 0x0008, 0x1850,
+ 0x0d2c, 0x2818, 0x343c, 0x0108, 0x1950,
+ 0x0e2c, 0x2918, 0x353c, 0x0208, 0x1a50,
+ 0x0f2c, 0x291c, 0x3540, 0x0308, 0x1b50,
+ 0x102c, 0x281c, 0x3440, 0x0408, 0x1c50,
+ 0x112c, 0x271c, 0x3340, 0x0508, 0x1d50,
+ 0x1130, 0x261c, 0x3240, 0x050c, 0x1d54,
+ 0x1030, 0x251c, 0x3140, 0x040c, 0x1c54,
+ 0x0f30, 0x241c, 0x3040, 0x030c, 0x1b54,
+ 0x0e30, 0x2420, 0x3044, 0x020c, 0x1a54,
+ 0x0d30, 0x2520, 0x3144, 0x010c, 0x1954,
+ 0x0c30, 0x2620, 0x3244, 0x000c, 0x1854,
+ 0x0c34, 0x2720, 0x3344, 0x0010, 0x1858,
+ 0x0d34, 0x2820, 0x3444, 0x0110, 0x1a58,
+ 0x0e34, 0x2920, 0x3544, 0x0210, 0x1c58,
+ 0x1224, 0x2d10, 0x3934, 0x0600, 0x1e48,
+ 0x1324, 0x2e10, 0x3a34, 0x0700, 0x1f48,
+ 0x1424, 0x2f10, 0x3b34, 0x0800, 0x2048,
+ 0x1524, 0x2f14, 0x3b38, 0x0900, 0x2148,
+ 0x1624, 0x2e14, 0x3a38, 0x0a00, 0x2248,
+ 0x1724, 0x2d14, 0x3938, 0x0b00, 0x2348,
+ 0x1728, 0x2c14, 0x3838, 0x0b04, 0x234c,
+ 0x1628, 0x2b14, 0x3738, 0x0a04, 0x224c,
+ 0x1528, 0x2a14, 0x3638, 0x0904, 0x214c,
+ 0x1428, 0x2a18, 0x363c, 0x0804, 0x204c,
+ 0x1328, 0x2b18, 0x373c, 0x0704, 0x1f4c,
+ 0x1228, 0x2c18, 0x383c, 0x0604, 0x1e4c,
+ 0x122c, 0x2d18, 0x393c, 0x0608, 0x1e50,
+ 0x132c, 0x2e18, 0x3a3c, 0x0708, 0x1f50,
+ 0x142c, 0x2f18, 0x3b3c, 0x0808, 0x2050,
+ 0x152c, 0x2f1c, 0x3b40, 0x0908, 0x2150,
+ 0x162c, 0x2e1c, 0x3a40, 0x0a08, 0x2250,
+ 0x172c, 0x2d1c, 0x3940, 0x0b08, 0x2350,
+ 0x1730, 0x2c1c, 0x3840, 0x0b0c, 0x2354,
+ 0x1630, 0x2b1c, 0x3740, 0x0a0c, 0x2254,
+ 0x1530, 0x2a1c, 0x3640, 0x090c, 0x2154,
+ 0x1430, 0x2a20, 0x3644, 0x080c, 0x2054,
+ 0x1330, 0x2b20, 0x3744, 0x070c, 0x1f54,
+ 0x1230, 0x2c20, 0x3844, 0x060c, 0x1e54,
+ 0x1234, 0x2d20, 0x3944, 0x0610, 0x1e58,
+ 0x1334, 0x2e20, 0x3a44, 0x0710, 0x2058,
+ 0x1434, 0x2f20, 0x3b44, 0x0810, 0x2258,
+ 0x1824, 0x3310, 0x3f34, 0x0c00, 0x2448,
+ 0x1924, 0x3410, 0x4034, 0x0d00, 0x2548,
+ 0x1a24, 0x3510, 0x4134, 0x0e00, 0x2648,
+ 0x1b24, 0x3514, 0x4138, 0x0f00, 0x2748,
+ 0x1c24, 0x3414, 0x4038, 0x1000, 0x2848,
+ 0x1d24, 0x3314, 0x3f38, 0x1100, 0x2948,
+ 0x1d28, 0x3214, 0x3e38, 0x1104, 0x294c,
+ 0x1c28, 0x3114, 0x3d38, 0x1004, 0x284c,
+ 0x1b28, 0x3014, 0x3c38, 0x0f04, 0x274c,
+ 0x1a28, 0x3018, 0x3c3c, 0x0e04, 0x264c,
+ 0x1928, 0x3118, 0x3d3c, 0x0d04, 0x254c,
+ 0x1828, 0x3218, 0x3e3c, 0x0c04, 0x244c,
+ 0x182c, 0x3318, 0x3f3c, 0x0c08, 0x2450,
+ 0x192c, 0x3418, 0x403c, 0x0d08, 0x2550,
+ 0x1a2c, 0x3518, 0x413c, 0x0e08, 0x2650,
+ 0x1b2c, 0x351c, 0x4140, 0x0f08, 0x2750,
+ 0x1c2c, 0x341c, 0x4040, 0x1008, 0x2850,
+ 0x1d2c, 0x331c, 0x3f40, 0x1108, 0x2950,
+ 0x1d30, 0x321c, 0x3e40, 0x110c, 0x2954,
+ 0x1c30, 0x311c, 0x3d40, 0x100c, 0x2854,
+ 0x1b30, 0x301c, 0x3c40, 0x0f0c, 0x2754,
+ 0x1a30, 0x3020, 0x3c44, 0x0e0c, 0x2654,
+ 0x1930, 0x3120, 0x3d44, 0x0d0c, 0x2554,
+ 0x1830, 0x3220, 0x3e44, 0x0c0c, 0x2454,
+ 0x1834, 0x3320, 0x3f44, 0x0c10, 0x2458,
+ 0x1934, 0x3420, 0x4044, 0x0d10, 0x2658,
+ 0x1a34, 0x3520, 0x4144, 0x0e10, 0x2858,
+ 0x1e24, 0x3910, 0x4534, 0x1200, 0x2a48,
+ 0x1f24, 0x3a10, 0x4634, 0x1300, 0x2b48,
+ 0x2024, 0x3b10, 0x4734, 0x1400, 0x2c48,
+ 0x2124, 0x3b14, 0x4738, 0x1500, 0x2d48,
+ 0x2224, 0x3a14, 0x4638, 0x1600, 0x2e48,
+ 0x2324, 0x3914, 0x4538, 0x1700, 0x2f48,
+ 0x2328, 0x3814, 0x4438, 0x1704, 0x2f4c,
+ 0x2228, 0x3714, 0x4338, 0x1604, 0x2e4c,
+ 0x2128, 0x3614, 0x4238, 0x1504, 0x2d4c,
+ 0x2028, 0x3618, 0x423c, 0x1404, 0x2c4c,
+ 0x1f28, 0x3718, 0x433c, 0x1304, 0x2b4c,
+ 0x1e28, 0x3818, 0x443c, 0x1204, 0x2a4c,
+ 0x1e2c, 0x3918, 0x453c, 0x1208, 0x2a50,
+ 0x1f2c, 0x3a18, 0x463c, 0x1308, 0x2b50,
+ 0x202c, 0x3b18, 0x473c, 0x1408, 0x2c50,
+ 0x212c, 0x3b1c, 0x4740, 0x1508, 0x2d50,
+ 0x222c, 0x3a1c, 0x4640, 0x1608, 0x2e50,
+ 0x232c, 0x391c, 0x4540, 0x1708, 0x2f50,
+ 0x2330, 0x381c, 0x4440, 0x170c, 0x2f54,
+ 0x2230, 0x371c, 0x4340, 0x160c, 0x2e54,
+ 0x2130, 0x361c, 0x4240, 0x150c, 0x2d54,
+ 0x2030, 0x3620, 0x4244, 0x140c, 0x2c54,
+ 0x1f30, 0x3720, 0x4344, 0x130c, 0x2b54,
+ 0x1e30, 0x3820, 0x4444, 0x120c, 0x2a54,
+ 0x1e34, 0x3920, 0x4544, 0x1210, 0x2a58,
+ 0x1f34, 0x3a20, 0x4644, 0x1310, 0x2c58,
+ 0x2034, 0x3b20, 0x4744, 0x1410, 0x2e58,
+ 0x2424, 0x3f10, 0x0334, 0x1800, 0x3048,
+ 0x2524, 0x4010, 0x0434, 0x1900, 0x3148,
+ 0x2624, 0x4110, 0x0534, 0x1a00, 0x3248,
+ 0x2724, 0x4114, 0x0538, 0x1b00, 0x3348,
+ 0x2824, 0x4014, 0x0438, 0x1c00, 0x3448,
+ 0x2924, 0x3f14, 0x0338, 0x1d00, 0x3548,
+ 0x2928, 0x3e14, 0x0238, 0x1d04, 0x354c,
+ 0x2828, 0x3d14, 0x0138, 0x1c04, 0x344c,
+ 0x2728, 0x3c14, 0x0038, 0x1b04, 0x334c,
+ 0x2628, 0x3c18, 0x003c, 0x1a04, 0x324c,
+ 0x2528, 0x3d18, 0x013c, 0x1904, 0x314c,
+ 0x2428, 0x3e18, 0x023c, 0x1804, 0x304c,
+ 0x242c, 0x3f18, 0x033c, 0x1808, 0x3050,
+ 0x252c, 0x4018, 0x043c, 0x1908, 0x3150,
+ 0x262c, 0x4118, 0x053c, 0x1a08, 0x3250,
+ 0x272c, 0x411c, 0x0540, 0x1b08, 0x3350,
+ 0x282c, 0x401c, 0x0440, 0x1c08, 0x3450,
+ 0x292c, 0x3f1c, 0x0340, 0x1d08, 0x3550,
+ 0x2930, 0x3e1c, 0x0240, 0x1d0c, 0x3554,
+ 0x2830, 0x3d1c, 0x0140, 0x1c0c, 0x3454,
+ 0x2730, 0x3c1c, 0x0040, 0x1b0c, 0x3354,
+ 0x2630, 0x3c20, 0x0044, 0x1a0c, 0x3254,
+ 0x2530, 0x3d20, 0x0144, 0x190c, 0x3154,
+ 0x2430, 0x3e20, 0x0244, 0x180c, 0x3054,
+ 0x2434, 0x3f20, 0x0344, 0x1810, 0x3058,
+ 0x2534, 0x4020, 0x0444, 0x1910, 0x3258,
+ 0x2634, 0x4120, 0x0544, 0x1a10, 0x3458,
+ 0x2a24, 0x4510, 0x0934, 0x1e00, 0x3648,
+ 0x2b24, 0x4610, 0x0a34, 0x1f00, 0x3748,
+ 0x2c24, 0x4710, 0x0b34, 0x2000, 0x3848,
+ 0x2d24, 0x4714, 0x0b38, 0x2100, 0x3948,
+ 0x2e24, 0x4614, 0x0a38, 0x2200, 0x3a48,
+ 0x2f24, 0x4514, 0x0938, 0x2300, 0x3b48,
+ 0x2f28, 0x4414, 0x0838, 0x2304, 0x3b4c,
+ 0x2e28, 0x4314, 0x0738, 0x2204, 0x3a4c,
+ 0x2d28, 0x4214, 0x0638, 0x2104, 0x394c,
+ 0x2c28, 0x4218, 0x063c, 0x2004, 0x384c,
+ 0x2b28, 0x4318, 0x073c, 0x1f04, 0x374c,
+ 0x2a28, 0x4418, 0x083c, 0x1e04, 0x364c,
+ 0x2a2c, 0x4518, 0x093c, 0x1e08, 0x3650,
+ 0x2b2c, 0x4618, 0x0a3c, 0x1f08, 0x3750,
+ 0x2c2c, 0x4718, 0x0b3c, 0x2008, 0x3850,
+ 0x2d2c, 0x471c, 0x0b40, 0x2108, 0x3950,
+ 0x2e2c, 0x461c, 0x0a40, 0x2208, 0x3a50,
+ 0x2f2c, 0x451c, 0x0940, 0x2308, 0x3b50,
+ 0x2f30, 0x441c, 0x0840, 0x230c, 0x3b54,
+ 0x2e30, 0x431c, 0x0740, 0x220c, 0x3a54,
+ 0x2d30, 0x421c, 0x0640, 0x210c, 0x3954,
+ 0x2c30, 0x4220, 0x0644, 0x200c, 0x3854,
+ 0x2b30, 0x4320, 0x0744, 0x1f0c, 0x3754,
+ 0x2a30, 0x4420, 0x0844, 0x1e0c, 0x3654,
+ 0x2a34, 0x4520, 0x0944, 0x1e10, 0x3658,
+ 0x2b34, 0x4620, 0x0a44, 0x1f10, 0x3858,
+ 0x2c34, 0x4720, 0x0b44, 0x2010, 0x3a58,
+ 0x3024, 0x0310, 0x0f34, 0x2400, 0x3c48,
+ 0x3124, 0x0410, 0x1034, 0x2500, 0x3d48,
+ 0x3224, 0x0510, 0x1134, 0x2600, 0x3e48,
+ 0x3324, 0x0514, 0x1138, 0x2700, 0x3f48,
+ 0x3424, 0x0414, 0x1038, 0x2800, 0x4048,
+ 0x3524, 0x0314, 0x0f38, 0x2900, 0x4148,
+ 0x3528, 0x0214, 0x0e38, 0x2904, 0x414c,
+ 0x3428, 0x0114, 0x0d38, 0x2804, 0x404c,
+ 0x3328, 0x0014, 0x0c38, 0x2704, 0x3f4c,
+ 0x3228, 0x0018, 0x0c3c, 0x2604, 0x3e4c,
+ 0x3128, 0x0118, 0x0d3c, 0x2504, 0x3d4c,
+ 0x3028, 0x0218, 0x0e3c, 0x2404, 0x3c4c,
+ 0x302c, 0x0318, 0x0f3c, 0x2408, 0x3c50,
+ 0x312c, 0x0418, 0x103c, 0x2508, 0x3d50,
+ 0x322c, 0x0518, 0x113c, 0x2608, 0x3e50,
+ 0x332c, 0x051c, 0x1140, 0x2708, 0x3f50,
+ 0x342c, 0x041c, 0x1040, 0x2808, 0x4050,
+ 0x352c, 0x031c, 0x0f40, 0x2908, 0x4150,
+ 0x3530, 0x021c, 0x0e40, 0x290c, 0x4154,
+ 0x3430, 0x011c, 0x0d40, 0x280c, 0x4054,
+ 0x3330, 0x001c, 0x0c40, 0x270c, 0x3f54,
+ 0x3230, 0x0020, 0x0c44, 0x260c, 0x3e54,
+ 0x3130, 0x0120, 0x0d44, 0x250c, 0x3d54,
+ 0x3030, 0x0220, 0x0e44, 0x240c, 0x3c54,
+ 0x3034, 0x0320, 0x0f44, 0x2410, 0x3c58,
+ 0x3134, 0x0420, 0x1044, 0x2510, 0x3e58,
+ 0x3234, 0x0520, 0x1144, 0x2610, 0x4058,
+ 0x3624, 0x0910, 0x1534, 0x2a00, 0x4248,
+ 0x3724, 0x0a10, 0x1634, 0x2b00, 0x4348,
+ 0x3824, 0x0b10, 0x1734, 0x2c00, 0x4448,
+ 0x3924, 0x0b14, 0x1738, 0x2d00, 0x4548,
+ 0x3a24, 0x0a14, 0x1638, 0x2e00, 0x4648,
+ 0x3b24, 0x0914, 0x1538, 0x2f00, 0x4748,
+ 0x3b28, 0x0814, 0x1438, 0x2f04, 0x474c,
+ 0x3a28, 0x0714, 0x1338, 0x2e04, 0x464c,
+ 0x3928, 0x0614, 0x1238, 0x2d04, 0x454c,
+ 0x3828, 0x0618, 0x123c, 0x2c04, 0x444c,
+ 0x3728, 0x0718, 0x133c, 0x2b04, 0x434c,
+ 0x3628, 0x0818, 0x143c, 0x2a04, 0x424c,
+ 0x362c, 0x0918, 0x153c, 0x2a08, 0x4250,
+ 0x372c, 0x0a18, 0x163c, 0x2b08, 0x4350,
+ 0x382c, 0x0b18, 0x173c, 0x2c08, 0x4450,
+ 0x392c, 0x0b1c, 0x1740, 0x2d08, 0x4550,
+ 0x3a2c, 0x0a1c, 0x1640, 0x2e08, 0x4650,
+ 0x3b2c, 0x091c, 0x1540, 0x2f08, 0x4750,
+ 0x3b30, 0x081c, 0x1440, 0x2f0c, 0x4754,
+ 0x3a30, 0x071c, 0x1340, 0x2e0c, 0x4654,
+ 0x3930, 0x061c, 0x1240, 0x2d0c, 0x4554,
+ 0x3830, 0x0620, 0x1244, 0x2c0c, 0x4454,
+ 0x3730, 0x0720, 0x1344, 0x2b0c, 0x4354,
+ 0x3630, 0x0820, 0x1444, 0x2a0c, 0x4254,
+ 0x3634, 0x0920, 0x1544, 0x2a10, 0x4258,
+ 0x3734, 0x0a20, 0x1644, 0x2b10, 0x4458,
+ 0x3834, 0x0b20, 0x1744, 0x2c10, 0x4658,
+ 0x3c24, 0x0f10, 0x1b34, 0x3000, 0x0048,
+ 0x3d24, 0x1010, 0x1c34, 0x3100, 0x0148,
+ 0x3e24, 0x1110, 0x1d34, 0x3200, 0x0248,
+ 0x3f24, 0x1114, 0x1d38, 0x3300, 0x0348,
+ 0x4024, 0x1014, 0x1c38, 0x3400, 0x0448,
+ 0x4124, 0x0f14, 0x1b38, 0x3500, 0x0548,
+ 0x4128, 0x0e14, 0x1a38, 0x3504, 0x054c,
+ 0x4028, 0x0d14, 0x1938, 0x3404, 0x044c,
+ 0x3f28, 0x0c14, 0x1838, 0x3304, 0x034c,
+ 0x3e28, 0x0c18, 0x183c, 0x3204, 0x024c,
+ 0x3d28, 0x0d18, 0x193c, 0x3104, 0x014c,
+ 0x3c28, 0x0e18, 0x1a3c, 0x3004, 0x004c,
+ 0x3c2c, 0x0f18, 0x1b3c, 0x3008, 0x0050,
+ 0x3d2c, 0x1018, 0x1c3c, 0x3108, 0x0150,
+ 0x3e2c, 0x1118, 0x1d3c, 0x3208, 0x0250,
+ 0x3f2c, 0x111c, 0x1d40, 0x3308, 0x0350,
+ 0x402c, 0x101c, 0x1c40, 0x3408, 0x0450,
+ 0x412c, 0x0f1c, 0x1b40, 0x3508, 0x0550,
+ 0x4130, 0x0e1c, 0x1a40, 0x350c, 0x0554,
+ 0x4030, 0x0d1c, 0x1940, 0x340c, 0x0454,
+ 0x3f30, 0x0c1c, 0x1840, 0x330c, 0x0354,
+ 0x3e30, 0x0c20, 0x1844, 0x320c, 0x0254,
+ 0x3d30, 0x0d20, 0x1944, 0x310c, 0x0154,
+ 0x3c30, 0x0e20, 0x1a44, 0x300c, 0x0054,
+ 0x3c34, 0x0f20, 0x1b44, 0x3010, 0x0058,
+ 0x3d34, 0x1020, 0x1c44, 0x3110, 0x0258,
+ 0x3e34, 0x1120, 0x1d44, 0x3210, 0x0458,
+ 0x4224, 0x1510, 0x2134, 0x3600, 0x0648,
+ 0x4324, 0x1610, 0x2234, 0x3700, 0x0748,
+ 0x4424, 0x1710, 0x2334, 0x3800, 0x0848,
+ 0x4524, 0x1714, 0x2338, 0x3900, 0x0948,
+ 0x4624, 0x1614, 0x2238, 0x3a00, 0x0a48,
+ 0x4724, 0x1514, 0x2138, 0x3b00, 0x0b48,
+ 0x4728, 0x1414, 0x2038, 0x3b04, 0x0b4c,
+ 0x4628, 0x1314, 0x1f38, 0x3a04, 0x0a4c,
+ 0x4528, 0x1214, 0x1e38, 0x3904, 0x094c,
+ 0x4428, 0x1218, 0x1e3c, 0x3804, 0x084c,
+ 0x4328, 0x1318, 0x1f3c, 0x3704, 0x074c,
+ 0x4228, 0x1418, 0x203c, 0x3604, 0x064c,
+ 0x422c, 0x1518, 0x213c, 0x3608, 0x0650,
+ 0x432c, 0x1618, 0x223c, 0x3708, 0x0750,
+ 0x442c, 0x1718, 0x233c, 0x3808, 0x0850,
+ 0x452c, 0x171c, 0x2340, 0x3908, 0x0950,
+ 0x462c, 0x161c, 0x2240, 0x3a08, 0x0a50,
+ 0x472c, 0x151c, 0x2140, 0x3b08, 0x0b50,
+ 0x4730, 0x141c, 0x2040, 0x3b0c, 0x0b54,
+ 0x4630, 0x131c, 0x1f40, 0x3a0c, 0x0a54,
+ 0x4530, 0x121c, 0x1e40, 0x390c, 0x0954,
+ 0x4430, 0x1220, 0x1e44, 0x380c, 0x0854,
+ 0x4330, 0x1320, 0x1f44, 0x370c, 0x0754,
+ 0x4230, 0x1420, 0x2044, 0x360c, 0x0654,
+ 0x4234, 0x1520, 0x2144, 0x3610, 0x0658,
+ 0x4334, 0x1620, 0x2244, 0x3710, 0x0858,
+ 0x4434, 0x1720, 0x2344, 0x3810, 0x0a58,
+ 0x0024, 0x1b10, 0x2734, 0x3c00, 0x0c48,
+ 0x0124, 0x1c10, 0x2834, 0x3d00, 0x0d48,
+ 0x0224, 0x1d10, 0x2934, 0x3e00, 0x0e48,
+ 0x0324, 0x1d14, 0x2938, 0x3f00, 0x0f48,
+ 0x0424, 0x1c14, 0x2838, 0x4000, 0x1048,
+ 0x0524, 0x1b14, 0x2738, 0x4100, 0x1148,
+ 0x0528, 0x1a14, 0x2638, 0x4104, 0x114c,
+ 0x0428, 0x1914, 0x2538, 0x4004, 0x104c,
+ 0x0328, 0x1814, 0x2438, 0x3f04, 0x0f4c,
+ 0x0228, 0x1818, 0x243c, 0x3e04, 0x0e4c,
+ 0x0128, 0x1918, 0x253c, 0x3d04, 0x0d4c,
+ 0x0028, 0x1a18, 0x263c, 0x3c04, 0x0c4c,
+ 0x002c, 0x1b18, 0x273c, 0x3c08, 0x0c50,
+ 0x012c, 0x1c18, 0x283c, 0x3d08, 0x0d50,
+ 0x022c, 0x1d18, 0x293c, 0x3e08, 0x0e50,
+ 0x032c, 0x1d1c, 0x2940, 0x3f08, 0x0f50,
+ 0x042c, 0x1c1c, 0x2840, 0x4008, 0x1050,
+ 0x052c, 0x1b1c, 0x2740, 0x4108, 0x1150,
+ 0x0530, 0x1a1c, 0x2640, 0x410c, 0x1154,
+ 0x0430, 0x191c, 0x2540, 0x400c, 0x1054,
+ 0x0330, 0x181c, 0x2440, 0x3f0c, 0x0f54,
+ 0x0230, 0x1820, 0x2444, 0x3e0c, 0x0e54,
+ 0x0130, 0x1920, 0x2544, 0x3d0c, 0x0d54,
+ 0x0030, 0x1a20, 0x2644, 0x3c0c, 0x0c54,
+ 0x0034, 0x1b20, 0x2744, 0x3c10, 0x0c58,
+ 0x0134, 0x1c20, 0x2844, 0x3d10, 0x0e58,
+ 0x0234, 0x1d20, 0x2944, 0x3e10, 0x1058,
+ 0x0624, 0x2110, 0x2d34, 0x4200, 0x1248,
+ 0x0724, 0x2210, 0x2e34, 0x4300, 0x1348,
+ 0x0824, 0x2310, 0x2f34, 0x4400, 0x1448,
+ 0x0924, 0x2314, 0x2f38, 0x4500, 0x1548,
+ 0x0a24, 0x2214, 0x2e38, 0x4600, 0x1648,
+ 0x0b24, 0x2114, 0x2d38, 0x4700, 0x1748,
+ 0x0b28, 0x2014, 0x2c38, 0x4704, 0x174c,
+ 0x0a28, 0x1f14, 0x2b38, 0x4604, 0x164c,
+ 0x0928, 0x1e14, 0x2a38, 0x4504, 0x154c,
+ 0x0828, 0x1e18, 0x2a3c, 0x4404, 0x144c,
+ 0x0728, 0x1f18, 0x2b3c, 0x4304, 0x134c,
+ 0x0628, 0x2018, 0x2c3c, 0x4204, 0x124c,
+ 0x062c, 0x2118, 0x2d3c, 0x4208, 0x1250,
+ 0x072c, 0x2218, 0x2e3c, 0x4308, 0x1350,
+ 0x082c, 0x2318, 0x2f3c, 0x4408, 0x1450,
+ 0x092c, 0x231c, 0x2f40, 0x4508, 0x1550,
+ 0x0a2c, 0x221c, 0x2e40, 0x4608, 0x1650,
+ 0x0b2c, 0x211c, 0x2d40, 0x4708, 0x1750,
+ 0x0b30, 0x201c, 0x2c40, 0x470c, 0x1754,
+ 0x0a30, 0x1f1c, 0x2b40, 0x460c, 0x1654,
+ 0x0930, 0x1e1c, 0x2a40, 0x450c, 0x1554,
+ 0x0830, 0x1e20, 0x2a44, 0x440c, 0x1454,
+ 0x0730, 0x1f20, 0x2b44, 0x430c, 0x1354,
+ 0x0630, 0x2020, 0x2c44, 0x420c, 0x1254,
+ 0x0634, 0x2120, 0x2d44, 0x4210, 0x1258,
+ 0x0734, 0x2220, 0x2e44, 0x4310, 0x1458,
+ 0x0834, 0x2320, 0x2f44, 0x4410, 0x1658,
+};
+
+static const uint16_t dv_place_411[1350] = {
0x0c24, 0x2710, 0x3334, 0x0000, 0x1848,
0x0d24, 0x2810, 0x3434, 0x0100, 0x1948,
0x0e24, 0x2910, 0x3534, 0x0200, 0x1a48,
@@ -906,7 +1238,7 @@ static const UINT16 dv_place_411[1350] = {
0x0834, 0x2320, 0x2f44, 0x3810, 0x1658,
};
-static const UINT16 dv_place_audio60[10][9] = {
+static const uint16_t dv_place_audio60[10][9] = {
{ 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
{ 6, 36, 66, 26, 56, 86, 16, 46, 76 },
{ 12, 42, 72, 2, 32, 62, 22, 52, 82 },
@@ -920,7 +1252,7 @@ static const UINT16 dv_place_audio60[10][9] = {
{ 25, 55, 85, 15, 45, 75, 5, 35, 65 },
};
-static const UINT16 dv_place_audio50[12][9] = {
+static const uint16_t dv_place_audio50[12][9] = {
{ 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */
{ 6, 42, 78, 32, 68, 104, 22, 58, 94},
{ 12, 48, 84, 2, 38, 74, 28, 64, 100},
diff --git a/src/libffmpeg/libavcodec/error_resilience.c b/src/libffmpeg/libavcodec/error_resilience.c
index 3cb8d40bc..77488cd58 100644
--- a/src/libffmpeg/libavcodec/error_resilience.c
+++ b/src/libffmpeg/libavcodec/error_resilience.c
@@ -17,10 +17,16 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file error_resilience.c
+ * Error resilience / concealment.
+ */
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
+#include "common.h"
/**
* replaces the current MB with a flat dc only version.
@@ -54,7 +60,7 @@ static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t
}
}
-static void filter181(INT16 *data, int width, int height, int stride){
+static void filter181(int16_t *data, int width, int height, int stride){
int x,y;
/* horizontal filter */
@@ -95,7 +101,7 @@ static void filter181(INT16 *data, int width, int height, int stride){
* @param w width in 8 pixel blocks
* @param h height in 8 pixel blocks
*/
-static void guess_dc(MpegEncContext *s, INT16 *dc, int w, int h, int stride, int is_luma){
+static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, int is_luma){
int b_x, b_y;
for(b_y=0; b_y<h; b_y++){
@@ -103,7 +109,7 @@ static void guess_dc(MpegEncContext *s, INT16 *dc, int w, int h, int stride, int
int color[4]={1024,1024,1024,1024};
int distance[4]={9999,9999,9999,9999};
int mb_index, error, j;
- INT64 guess, weight_sum;
+ int64_t guess, weight_sum;
mb_index= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_width;
@@ -163,8 +169,8 @@ static void guess_dc(MpegEncContext *s, INT16 *dc, int w, int h, int stride, int
weight_sum=0;
guess=0;
for(j=0; j<4; j++){
- INT64 weight= 256*256*256*16/distance[j];
- guess+= weight*(INT64)color[j];
+ int64_t weight= 256*256*256*16/distance[j];
+ guess+= weight*(int64_t)color[j];
weight_sum+= weight;
}
guess= (guess + weight_sum/2) / weight_sum;
@@ -179,9 +185,9 @@ static void guess_dc(MpegEncContext *s, INT16 *dc, int w, int h, int stride, int
* @param w width in 8 pixel blocks
* @param h height in 8 pixel blocks
*/
-static void h_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stride, int is_luma){
+static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){
int b_x, b_y;
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
for(b_y=0; b_y<h; b_y++){
for(b_x=0; b_x<w-1; b_x++){
@@ -193,8 +199,8 @@ static void h_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stri
int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR);
int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR);
int offset= b_x*8 + b_y*stride*8;
- INT16 *left_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x <<(1-is_luma))];
- INT16 *right_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((b_x+1)<<(1-is_luma))];
+ int16_t *left_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x <<(1-is_luma))];
+ int16_t *right_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((b_x+1)<<(1-is_luma))];
if(!(left_damage||right_damage)) continue; // both undamaged
@@ -239,9 +245,9 @@ static void h_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stri
* @param w width in 8 pixel blocks
* @param h height in 8 pixel blocks
*/
-static void v_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stride, int is_luma){
+static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){
int b_x, b_y;
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
for(b_y=0; b_y<h-1; b_y++){
for(b_x=0; b_x<w; b_x++){
@@ -253,8 +259,8 @@ static void v_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stri
int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR);
int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR);
int offset= b_x*8 + b_y*stride*8;
- INT16 *top_mv= s->motion_val[s->block_wrap[0]*(( b_y <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
- INT16 *bottom_mv= s->motion_val[s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
+ int16_t *top_mv= s->motion_val[s->block_wrap[0]*(( b_y <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
+ int16_t *bottom_mv= s->motion_val[s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
if(!(top_damage||bottom_damage)) continue; // both undamaged
@@ -295,7 +301,7 @@ static void v_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stri
}
static void guess_mv(MpegEncContext *s){
- UINT8 fixed[s->mb_num];
+ uint8_t fixed[s->mb_num];
#define MV_FROZEN 3
#define MV_CHANGED 2
#define MV_UNCHANGED 1
@@ -464,7 +470,7 @@ int score_sum=0;
s->mb_y= mb_y;
for(j=0; j<pred_count; j++){
int score=0;
- UINT8 *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
+ uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
@@ -529,7 +535,7 @@ score_sum+= best_score;
static int is_intra_more_likely(MpegEncContext *s){
int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
- if(s->last_picture.data[0]==NULL) return 1; //no previous frame available -> use spatial prediction
+ if(s->last_picture_ptr==NULL) return 1; //no previous frame available -> use spatial prediction
undamaged_count=0;
for(i=0; i<s->mb_num; i++){
@@ -558,8 +564,8 @@ static int is_intra_more_likely(MpegEncContext *s){
if((j%skip_amount) != 0) continue; //skip a few to speed things up
if(s->pict_type==I_TYPE){
- UINT8 *mb_ptr = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
- UINT8 *last_mb_ptr= s->last_picture.data [0] + mb_x*16 + mb_y*16*s->linesize;
+ uint8_t *mb_ptr = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
+ uint8_t *last_mb_ptr= s->last_picture.data [0] + mb_x*16 + mb_y*16*s->linesize;
is_intra_likely += s->dsp.pix_abs16x16(last_mb_ptr, mb_ptr , s->linesize);
is_intra_likely -= s->dsp.pix_abs16x16(last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize);
@@ -575,12 +581,91 @@ static int is_intra_more_likely(MpegEncContext *s){
return is_intra_likely > 0;
}
-void ff_error_resilience(MpegEncContext *s){
+void ff_er_frame_start(MpegEncContext *s){
+ if(!s->error_resilience) return;
+
+ memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(uint8_t));
+}
+
+/**
+ * adds a slice.
+ * @param endx x component of the last macroblock, can be -1 for the last of the previous line
+ * @param status the status at the end (MV_END, AC_ERROR, ...), it is assumed that no earlier end or
+ * error of the same type occured
+ */
+void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status){
+ const int start_xy= clip(startx + starty * s->mb_width, 0, s->mb_num-1);
+ const int end_xy = clip(endx + endy * s->mb_width, 0, s->mb_num);
+ const int mb_count= end_xy - start_xy;
+ int mask= -1;
+
+ if(!s->error_resilience) return;
+
+ mask &= ~VP_START;
+ if(status & (AC_ERROR|AC_END)) mask &= ~(AC_ERROR|AC_END);
+ if(status & (DC_ERROR|DC_END)) mask &= ~(DC_ERROR|DC_END);
+ if(status & (MV_ERROR|MV_END)) mask &= ~(MV_ERROR|MV_END);
+
+ if(mask == ~0x7F){
+ memset(&s->error_status_table[start_xy], 0, mb_count * sizeof(uint8_t));
+ }else{
+ int i;
+ for(i=start_xy; i<end_xy; i++){
+ s->error_status_table[i] &= mask;
+ }
+ }
+
+ s->error_status_table[start_xy] |= VP_START;
+
+ if(end_xy < s->mb_num){
+ s->error_status_table[end_xy] &= mask;
+ s->error_status_table[end_xy] |= status;
+ }
+}
+
+void ff_er_frame_end(MpegEncContext *s){
int i, mb_x, mb_y, error, error_type;
int distance;
int threshold_part[4]= {100,100,100};
int threshold= 50;
int is_intra_likely;
+ int num_end_markers=0;
+
+ if(!s->error_resilience) return;
+
+ error=0;
+ for(i=0; i<s->mb_num; i++){
+ int status= s->error_status_table[i];
+
+ if(status==0) continue;
+
+ if(status&(DC_ERROR|AC_ERROR|MV_ERROR))
+ error=1;
+ if(status&VP_START){
+ if(num_end_markers)
+ error=1;
+ num_end_markers=3;
+ }
+ if(status&AC_END)
+ num_end_markers--;
+ if(status&DC_END)
+ num_end_markers--;
+ if(status&MV_END)
+ num_end_markers--;
+ }
+ if(num_end_markers==0 && error==0)
+ return;
+
+ fprintf(stderr, "concealing errors\n");
+
+ if(s->avctx->debug&FF_DEBUG_ER){
+ for(i=0; i<s->mb_num; i++){
+ int status= s->error_status_table[i];
+
+ if(i%s->mb_width == 0) printf("\n");
+ printf("%2X ", status);
+ }
+ }
#if 1
/* handle overlapping slices */
@@ -795,8 +880,8 @@ void ff_error_resilience(MpegEncContext *s){
for(mb_y=0; mb_y<s->mb_height; mb_y++){
for(mb_x=0; mb_x<s->mb_width; mb_x++){
int dc, dcu, dcv, y, n;
- INT16 *dc_ptr;
- UINT8 *dest_y, *dest_cb, *dest_cr;
+ int16_t *dc_ptr;
+ uint8_t *dest_y, *dest_cb, *dest_cr;
i++;
error= s->error_status_table[i];
@@ -846,7 +931,7 @@ void ff_error_resilience(MpegEncContext *s){
i= -1;
for(mb_y=0; mb_y<s->mb_height; mb_y++){
for(mb_x=0; mb_x<s->mb_width; mb_x++){
- UINT8 *dest_y, *dest_cb, *dest_cr;
+ uint8_t *dest_y, *dest_cb, *dest_cr;
i++;
error= s->error_status_table[i];
diff --git a/src/libffmpeg/libavcodec/eval.c b/src/libffmpeg/libavcodec/eval.c
index bcaf4f59b..28a492cd4 100644
--- a/src/libffmpeg/libavcodec/eval.c
+++ b/src/libffmpeg/libavcodec/eval.c
@@ -19,10 +19,16 @@
*
*/
- /*
+/**
+ * @file eval.c
+ * simple arithmetic expression evaluator.
+ *
* see http://joe.hotchkiss.com/programming/eval/eval.html
*/
+#include "avcodec.h"
+#include "mpegvideo.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -43,9 +49,9 @@ typedef struct Parser{
int stack_index;
char *s;
double *const_value;
- char **const_name; // NULL terminated
+ const char **const_name; // NULL terminated
double (**func1)(void *, double a); // NULL terminated
- char **func1_name; // NULL terminated
+ const char **func1_name; // NULL terminated
double (**func2)(void *, double a, double b); // NULL terminated
char **func2_name; // NULL terminated
void *opaque;
@@ -71,7 +77,7 @@ static double pop(Parser *p){
return p->stack[ --p->stack_index ];
}
-static int strmatch(char *s, char *prefix){
+static int strmatch(const char *s, const char *prefix){
int i;
for(i=0; prefix[i]; i++){
if(prefix[i] != s[i]) return 0;
@@ -126,7 +132,7 @@ static void evalPrimary(Parser *p){
else if( strmatch(next, "log" ) ) d= log(d);
else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
- else if( strmatch(next, "abs" ) ) d= abs(d);
+ else if( strmatch(next, "abs" ) ) d= fabs(d);
else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2;
else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2;
else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0;
@@ -228,8 +234,8 @@ static void evalExpression(Parser *p){
}
}
-double ff_eval(char *s, double *const_value, char **const_name,
- double (**func1)(void *, double), char **func1_name,
+double ff_eval(char *s, double *const_value, const char **const_name,
+ double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
void *opaque){
Parser p;
diff --git a/src/libffmpeg/libavcodec/fdctref.c b/src/libffmpeg/libavcodec/fdctref.c
index ae376f794..d728727ce 100644
--- a/src/libffmpeg/libavcodec/fdctref.c
+++ b/src/libffmpeg/libavcodec/fdctref.c
@@ -1,4 +1,7 @@
-/* fdctref.c, forward discrete cosine transform, double precision */
+/**
+ * @file fdctref.c
+ * forward discrete cosine transform, double precision.
+ */
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
diff --git a/src/libffmpeg/libavcodec/fft.c b/src/libffmpeg/libavcodec/fft.c
index 65eb575f3..3b5244a07 100644
--- a/src/libffmpeg/libavcodec/fft.c
+++ b/src/libffmpeg/libavcodec/fft.c
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file fft.c
+ * FFT/IFFT transforms.
+ */
+
#include "dsputil.h"
/**
diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c
index f50920011..a054ebfb0 100644
--- a/src/libffmpeg/libavcodec/h263.c
+++ b/src/libffmpeg/libavcodec/h263.c
@@ -25,8 +25,7 @@
/**
* @file h263.c
- * @brief h263/mpeg4 codec
- *
+ * h263/mpeg4 codec.
*/
//#define DEBUG
@@ -36,7 +35,9 @@
#include "mpegvideo.h"
#include "h263data.h"
#include "mpeg4data.h"
-#include "xineutils.h"
+
+//#undef NDEBUG
+//#include <assert.h>
#if 1
#define PRINT_MB_TYPE(a) {}
@@ -59,7 +60,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block,
static void h263_encode_motion(MpegEncContext * s, int val, int fcode);
static void h263p_encode_umotion(MpegEncContext * s, int val);
static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block,
- int n, int dc, UINT8 *scan_table,
+ int n, int dc, uint8_t *scan_table,
PutBitContext *dc_pb, PutBitContext *ac_pb);
#endif
@@ -69,24 +70,26 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded);
static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
- int n, int coded, int intra);
-static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr);
+ int n, int coded, int intra, int rvlc);
+static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr);
+#ifdef CONFIG_ENCODERS
static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
int dir);
+#endif //CONFIG_ENCODERS
static void mpeg4_decode_sprite_trajectory(MpegEncContext * s);
-static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr, int *dir_ptr);
-
-extern UINT32 inverse[256];
+static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr);
-static UINT8 uni_DCtab_lum_len[512];
-static UINT8 uni_DCtab_chrom_len[512];
-static UINT16 uni_DCtab_lum_bits[512];
-static UINT16 uni_DCtab_chrom_bits[512];
+extern uint32_t inverse[256];
#ifdef CONFIG_ENCODERS
-static UINT16 (*mv_penalty)[MAX_MV*2+1]= NULL;
-static UINT8 fcode_tab[MAX_MV*2+1];
-static UINT8 umv_fcode_tab[MAX_MV*2+1];
+static uint8_t uni_DCtab_lum_len[512];
+static uint8_t uni_DCtab_chrom_len[512];
+static uint16_t uni_DCtab_lum_bits[512];
+static uint16_t uni_DCtab_chrom_bits[512];
+
+static uint16_t (*mv_penalty)[MAX_MV*2+1]= NULL;
+static uint8_t fcode_tab[MAX_MV*2+1];
+static uint8_t umv_fcode_tab[MAX_MV*2+1];
static uint32_t uni_mpeg4_intra_rl_bits[64*64*2*2];
static uint8_t uni_mpeg4_intra_rl_len [64*64*2*2];
@@ -127,6 +130,8 @@ int h263_get_picture_format(int width, int height)
return format;
}
+#ifdef CONFIG_ENCODERS
+
static void float_aspect_to_info(MpegEncContext * s, float aspect){
int i;
@@ -159,8 +164,8 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
s->gob_number = 0;
put_bits(&s->pb, 22, 0x20); /* PSC */
- put_bits(&s->pb, 8, (((INT64)s->picture_number * 30 * FRAME_RATE_BASE) /
- s->frame_rate) & 0xff);
+ put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->frame_rate_base) /
+ s->avctx->frame_rate) & 0xff);
put_bits(&s->pb, 1, 1); /* marker */
put_bits(&s->pb, 1, 0); /* h263 id */
@@ -193,7 +198,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 3, format);
put_bits(&s->pb,1,0); /* Custom PCF: off */
- s->umvplus = (s->pict_type == P_TYPE) && s->unrestricted_mv;
+ s->umvplus = s->unrestricted_mv;
put_bits(&s->pb, 1, s->umvplus); /* Unrestricted Motion Vector */
put_bits(&s->pb,1,0); /* SAC: off */
put_bits(&s->pb,1,0); /* Advanced Prediction Mode: off */
@@ -235,7 +240,9 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
/* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
if (s->umvplus)
- put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
+// put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
+ put_bits(&s->pb,2,1); /* unlimited */
+
put_bits(&s->pb, 5, s->qscale);
}
@@ -278,7 +285,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
int8_t * const qscale_table= s->current_picture.qscale_table;
for(n=0; n<6; n++){
- INT16 *ac_val, *ac_val1;
+ int16_t *ac_val, *ac_val1;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val1= ac_val;
@@ -289,19 +296,19 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
/* same qscale */
for(i=1; i<8; i++){
- const int level= block[n][s->idct_permutation[i ]];
+ const int level= block[n][s->dsp.idct_permutation[i ]];
score0+= ABS(level);
score1+= ABS(level - ac_val[i+8]);
- ac_val1[i ]= block[n][s->idct_permutation[i<<3]];
+ ac_val1[i ]= block[n][s->dsp.idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
}else{
/* different qscale, we must rescale */
for(i=1; i<8; i++){
- const int level= block[n][s->idct_permutation[i ]];
+ const int level= block[n][s->dsp.idct_permutation[i ]];
score0+= ABS(level);
score1+= ABS(level - ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale));
- ac_val1[i ]= block[n][s->idct_permutation[i<<3]];
+ ac_val1[i ]= block[n][s->dsp.idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
}
@@ -312,20 +319,20 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
/* same qscale */
for(i=1; i<8; i++){
- const int level= block[n][s->idct_permutation[i<<3]];
+ const int level= block[n][s->dsp.idct_permutation[i<<3]];
score0+= ABS(level);
score1+= ABS(level - ac_val[i]);
ac_val1[i ]= level;
- ac_val1[i+8]= block[n][s->idct_permutation[i ]];
+ ac_val1[i+8]= block[n][s->dsp.idct_permutation[i ]];
}
}else{
/* different qscale, we must rescale */
for(i=1; i<8; i++){
- const int level= block[n][s->idct_permutation[i<<3]];
+ const int level= block[n][s->dsp.idct_permutation[i<<3]];
score0+= ABS(level);
score1+= ABS(level - ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale));
ac_val1[i ]= level;
- ac_val1[i+8]= block[n][s->idct_permutation[i ]];
+ ac_val1[i+8]= block[n][s->dsp.idct_permutation[i ]];
}
}
}
@@ -395,23 +402,28 @@ void ff_clean_mpeg4_qscales(MpegEncContext *s){
}
}
+#endif //CONFIG_ENCODERS
+
void ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
const int mb_index= s->mb_x + s->mb_y*s->mb_width;
int xy= s->block_index[0];
uint16_t time_pp= s->pp_time;
uint16_t time_pb= s->pb_time;
int i;
-
+
//FIXME avoid divides
switch(s->co_located_type_table[mb_index]){
case 0:
- s->mv_type= MV_TYPE_16X16;
- s->mv[0][0][0] = s->motion_val[xy][0]*time_pb/time_pp + mx;
- s->mv[0][0][1] = s->motion_val[xy][1]*time_pb/time_pp + my;
- s->mv[1][0][0] = mx ? s->mv[0][0][0] - s->motion_val[xy][0]
+ s->mv[0][0][0] = s->mv[0][1][0] = s->mv[0][2][0] = s->mv[0][3][0] = s->motion_val[xy][0]*time_pb/time_pp + mx;
+ s->mv[0][0][1] = s->mv[0][1][1] = s->mv[0][2][1] = s->mv[0][3][1] = s->motion_val[xy][1]*time_pb/time_pp + my;
+ s->mv[1][0][0] = s->mv[1][1][0] = s->mv[1][2][0] = s->mv[1][3][0] = mx ? s->mv[0][0][0] - s->motion_val[xy][0]
: s->motion_val[xy][0]*(time_pb - time_pp)/time_pp;
- s->mv[1][0][1] = my ? s->mv[0][0][1] - s->motion_val[xy][1]
+ s->mv[1][0][1] = s->mv[1][1][1] = s->mv[1][2][1] = s->mv[1][3][1] = my ? s->mv[0][0][1] - s->motion_val[xy][1]
: s->motion_val[xy][1]*(time_pb - time_pp)/time_pp;
+ if((s->avctx->workaround_bugs & FF_BUG_DIRECT_BLOCKSIZE) || !s->quarter_sample)
+ s->mv_type= MV_TYPE_16X16;
+ else
+ s->mv_type= MV_TYPE_8X8;
break;
case CO_LOCATED_TYPE_4MV:
s->mv_type = MV_TYPE_8X8;
@@ -451,7 +463,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
{
- int cbpc, cbpy, i, pred_x, pred_y;
+ int cbpc, cbpy, pred_x, pred_y;
int bits;
PutBitContext * const pb2 = s->data_partitioning ? &s->pb2 : &s->pb;
PutBitContext * const tex_pb = s->data_partitioning && s->pict_type!=B_TYPE ? &s->tex_pb : &s->pb;
@@ -462,7 +474,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
// printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
if (!s->mb_intra) {
/* compute cbp */
- int cbp = 0;
+ int i, cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 0)
cbp |= 1 << (5 - i);
@@ -479,11 +491,9 @@ void mpeg4_encode_mb(MpegEncContext * s,
s->last_mv[1][0][1]= 0;
}
- XINE_ASSERT(s->dquant>=-2 && s->dquant<=2,
- "value 's->dquant' is not within rang of -2 to 2: %d",
- s->dquant);
- XINE_ASSERT((s->dquant&1)==0,"?");
- XINE_ASSERT(mb_type>=0, "value 'mb_type' is < 0: %d", mb_type);
+ assert(s->dquant>=-2 && s->dquant<=2);
+ assert((s->dquant&1)==0);
+ assert(mb_type>=0);
/* nothing to do if this MB was skiped in the next P Frame */
if(s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x]){ //FIXME avoid DCT & ...
@@ -501,9 +511,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
if ((cbp | motion_x | motion_y | mb_type) ==0) {
/* direct MB with MV={0,0} */
- XINE_ASSERT(s->dquant==0,
- "value 's->dquant' is not 0: %d",
- s->dquant);
+ assert(s->dquant==0);
put_bits(&s->pb, 1, 1); /* mb not coded modb1=1 */
@@ -727,11 +735,12 @@ void mpeg4_encode_mb(MpegEncContext * s,
int dc_diff[6]; //dc values with the dc prediction subtracted
int dir[6]; //prediction direction
int zigzag_last_index[6];
- UINT8 *scan_table[6];
+ uint8_t *scan_table[6];
+ int i;
for(i=0; i<6; i++){
const int level= block[i][0];
- UINT16 *dc_ptr;
+ uint16_t *dc_ptr;
dc_diff[i]= level - ff_mpeg4_pred_dc(s, i, &dc_ptr, &dir[i]);
if (i < 4) {
@@ -745,7 +754,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
if(s->ac_pred){
for(i=0; i<6; i++){
- UINT8 *st;
+ uint8_t *st;
int last_index;
mpeg4_inv_pred_ac(s, block[i], i, dir[i]);
@@ -815,16 +824,16 @@ void mpeg4_encode_mb(MpegEncContext * s,
if(s->ac_pred){
for(i=0; i<6; i++){
int j;
- INT16 *ac_val;
+ int16_t *ac_val;
ac_val = s->ac_val[0][0] + s->block_index[i] * 16;
if(dir[i]){
for(j=1; j<8; j++)
- block[i][s->idct_permutation[j ]]= ac_val[j+8];
+ block[i][s->dsp.idct_permutation[j ]]= ac_val[j+8];
}else{
for(j=1; j<8; j++)
- block[i][s->idct_permutation[j<<3]]= ac_val[j ];
+ block[i][s->dsp.idct_permutation[j<<3]]= ac_val[j ];
}
s->block_last_index[i]= zigzag_last_index[i];
}
@@ -837,9 +846,9 @@ void h263_encode_mb(MpegEncContext * s,
int motion_x, int motion_y)
{
int cbpc, cbpy, i, cbp, pred_x, pred_y;
- INT16 pred_dc;
- INT16 rec_intradc[6];
- UINT16 *dc_ptr[6];
+ int16_t pred_dc;
+ int16_t rec_intradc[6];
+ uint16_t *dc_ptr[6];
const int dquant_code[5]= {1,0,9,2,3};
//printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
@@ -888,7 +897,7 @@ void h263_encode_mb(MpegEncContext * s,
for(i=0; i<6; i++) {
/* Predict DC */
if (s->h263_aic && s->mb_intra) {
- INT16 level = block[i][0];
+ int16_t level = block[i][0];
pred_dc = h263_pred_dc(s, i, &dc_ptr[i]);
level -= pred_dc;
@@ -963,10 +972,10 @@ void h263_encode_mb(MpegEncContext * s,
}
#endif
-static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr)
+static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr)
{
int x, y, wrap, a, c, pred_dc, scale;
- INT16 *dc_val, *ac_val;
+ int16_t *dc_val, *ac_val;
/* find prediction */
if (n < 4) {
@@ -1008,11 +1017,10 @@ static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr)
return pred_dc;
}
-
-void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
+static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
{
int x, y, wrap, a, c, pred_dc, scale, i;
- INT16 *dc_val, *ac_val, *ac_val1;
+ int16_t *dc_val, *ac_val, *ac_val1;
/* find prediction */
if (n < 4) {
@@ -1050,7 +1058,7 @@ void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
if (a != 1024) {
ac_val -= 16;
for(i=1;i<8;i++) {
- block[s->idct_permutation[i<<3]] += ac_val[i];
+ block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
}
pred_dc = a;
}
@@ -1059,7 +1067,7 @@ void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
if (c != 1024) {
ac_val -= 16 * wrap;
for(i=1;i<8;i++) {
- block[s->idct_permutation[i ]] += ac_val[i + 8];
+ block[s->dsp.idct_permutation[i ]] += ac_val[i + 8];
}
pred_dc = c;
}
@@ -1087,17 +1095,17 @@ void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
/* left copy */
for(i=1;i<8;i++)
- ac_val1[i ] = block[s->idct_permutation[i<<3]];
+ ac_val1[i ] = block[s->dsp.idct_permutation[i<<3]];
/* top copy */
for(i=1;i<8;i++)
- ac_val1[8 + i] = block[s->idct_permutation[i ]];
+ ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];
}
-INT16 *h263_pred_motion(MpegEncContext * s, int block,
+int16_t *h263_pred_motion(MpegEncContext * s, int block,
int *px, int *py)
{
int xy, wrap;
- INT16 *A, *B, *C, *mot_val;
+ int16_t *A, *B, *C, *mot_val;
static const int off[4]= {2, 1, 1, -1};
wrap = s->block_wrap[0];
@@ -1181,7 +1189,7 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code)
val -= 2*l;
}
- XINE_ASSERT(val>=-l && val<l);
+ assert(val>=-l && val<l);
if (val >= 0) {
sign = 0;
@@ -1247,7 +1255,7 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s)
int mv;
if(mv_penalty==NULL)
- mv_penalty= av_mallocz( sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1) );
+ mv_penalty= av_mallocz( sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
for(f_code=1; f_code<=MAX_FCODE; f_code++){
for(mv=-MAX_MV; mv<=MAX_MV; mv++){
@@ -1288,6 +1296,8 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s)
}
#endif
+#ifdef CONFIG_ENCODERS
+
static void init_uni_dc_tab(void)
{
int level, uni_code, uni_len;
@@ -1340,12 +1350,14 @@ static void init_uni_dc_tab(void)
}
}
+#endif //CONFIG_ENCODERS
+
#ifdef CONFIG_ENCODERS
-static void init_uni_mpeg4_rl_tab(RLTable *rl, UINT32 *bits_tab, UINT8 *len_tab){
+static void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){
int slevel, run, last;
- XINE_ASSERT(MAX_LEVEL >= 64, "MAX_LEVEL is < 64: %d", MAX_LEVEL);
- XINE_ASSERT(MAX_RUN >= 63, "MAX_RUN is < 63: %d", MAX_RUN);
+ assert(MAX_LEVEL >= 64);
+ assert(MAX_RUN >= 63);
for(slevel=-64; slevel<64; slevel++){
if(slevel==0) continue;
@@ -1462,24 +1474,16 @@ void h263_encode_init(MpegEncContext *s)
break;
case CODEC_ID_H263P:
s->fcode_tab= umv_fcode_tab;
- s->min_qcoeff= -128;
+ s->min_qcoeff= -127;
s->max_qcoeff= 127;
break;
//Note for mpeg4 & h263 the dc-scale table will be set per frame as needed later
default: //nothing needed default table allready set in mpegvideo.c
- s->min_qcoeff= -128;
+ s->min_qcoeff= -127;
s->max_qcoeff= 127;
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
-
- if(s->mpeg_quant){
- s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
- s->inter_quant_bias= 0;
- }else{
- s->intra_quant_bias=0;
- s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x
- }
}
/**
@@ -1495,26 +1499,26 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
rl = &rl_inter;
if (s->mb_intra && !s->h263_aic) {
/* DC coef */
- level = block[0];
+ level = block[0];
/* 255 cannot be represented, so we clamp */
if (level > 254) {
level = 254;
block[0] = 254;
}
/* 0 cannot be represented also */
- else if (!level) {
+ else if (level < 1) {
level = 1;
block[0] = 1;
}
- if (level == 128)
- put_bits(&s->pb, 8, 0xff);
- else
- put_bits(&s->pb, 8, level & 0xff);
- i = 1;
+ if (level == 128) //FIXME check rv10
+ put_bits(&s->pb, 8, 0xff);
+ else
+ put_bits(&s->pb, 8, level & 0xff);
+ i = 1;
} else {
- i = 0;
- if (s->h263_aic && s->mb_intra)
- rl = &rl_intra_aic;
+ i = 0;
+ if (s->h263_aic && s->mb_intra)
+ rl = &rl_intra_aic;
}
/* AC coefs */
@@ -1537,7 +1541,16 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
if (code == rl->n) {
put_bits(&s->pb, 1, last);
put_bits(&s->pb, 6, run);
- put_bits(&s->pb, 8, slevel & 0xff);
+
+ assert(slevel != 0);
+
+ if(slevel < 128 && slevel > -128)
+ put_bits(&s->pb, 8, slevel & 0xff);
+ else{
+ put_bits(&s->pb, 8, 128);
+ put_bits(&s->pb, 5, slevel & 0x1f);
+ put_bits(&s->pb, 6, (slevel>>5)&0x3f);
+ }
} else {
put_bits(&s->pb, 1, sign);
}
@@ -1547,6 +1560,8 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
}
#endif
+#ifdef CONFIG_ENCODERS
+
/***************************************************/
/**
* add mpeg4 stuffing bits (01...1)
@@ -1564,16 +1579,16 @@ void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
int time_div, time_mod;
if(s->pict_type==I_TYPE){ //we will encode a vol header
- s->time_increment_resolution= s->frame_rate/ff_gcd(s->frame_rate, FRAME_RATE_BASE);
- if(s->time_increment_resolution>=256*256) s->time_increment_resolution= 256*128;
-
+ int dummy;
+ av_reduce(&s->time_increment_resolution, &dummy, s->avctx->frame_rate, s->avctx->frame_rate_base, (1<<16)-1);
+
s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1;
}
if(s->current_picture.pts)
s->time= (s->current_picture.pts*s->time_increment_resolution + 500*1000)/(1000*1000);
else
- s->time= picture_number*(INT64)FRAME_RATE_BASE*s->time_increment_resolution/s->frame_rate;
+ s->time= av_rescale(picture_number*(int64_t)s->avctx->frame_rate_base, s->time_increment_resolution, s->avctx->frame_rate);
time_div= s->time/s->time_increment_resolution;
time_mod= s->time%s->time_increment_resolution;
@@ -1644,7 +1659,6 @@ static void mpeg4_encode_visual_object_header(MpegEncContext * s){
static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number)
{
int vo_ver_id;
- char buf[255];
if(s->max_b_frames || s->quarter_sample){
vo_ver_id= 5;
@@ -1728,11 +1742,10 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
ff_mpeg4_stuffing(&s->pb);
/* user data */
- if(!ff_bit_exact){
+ if(!(s->flags & CODEC_FLAG_BITEXACT)){
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, 0x1B2); /* user_data */
- sprintf(buf, "FFmpeg%sb%s", FFMPEG_VERSION, LIBAVCODEC_BUILD_STR);
- put_string(&s->pb, buf);
+ put_string(&s->pb, LIBAVCODEC_IDENT);
ff_mpeg4_stuffing(&s->pb);
}
}
@@ -1796,6 +1809,8 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
s->v_edge_pos= s->height;
}
+#endif //CONFIG_ENCODERS
+
/**
* change qscale by given dquant and update qscale dependant variables.
*/
@@ -1819,10 +1834,10 @@ static void change_qscale(MpegEncContext * s, int dquant)
* @param dir_ptr pointer to an integer where the prediction direction will be stored
* @return the quantized predicted dc
*/
-static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr, int *dir_ptr)
+static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred, scale;
- UINT16 *dc_val;
+ uint16_t *dc_val;
int dummy;
/* find prediction */
@@ -1885,7 +1900,7 @@ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
int dir)
{
int i;
- INT16 *ac_val, *ac_val1;
+ int16_t *ac_val, *ac_val1;
int8_t * const qscale_table= s->current_picture.qscale_table;
/* find prediction */
@@ -1900,12 +1915,12 @@ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i<<3]] += ac_val[i];
+ block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i<<3]] += ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
+ block[s->dsp.idct_permutation[i<<3]] += ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
}
}
} else {
@@ -1916,31 +1931,33 @@ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i]] += ac_val[i + 8];
+ block[s->dsp.idct_permutation[i]] += ac_val[i + 8];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
+ block[s->dsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
}
}
}
}
/* left copy */
for(i=1;i<8;i++)
- ac_val1[i ] = block[s->idct_permutation[i<<3]];
+ ac_val1[i ] = block[s->dsp.idct_permutation[i<<3]];
/* top copy */
for(i=1;i<8;i++)
- ac_val1[8 + i] = block[s->idct_permutation[i ]];
+ ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];
}
+#ifdef CONFIG_ENCODERS
+
static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
int dir)
{
int i;
- INT16 *ac_val;
+ int16_t *ac_val;
int8_t * const qscale_table= s->current_picture.qscale_table;
/* find prediction */
@@ -1953,12 +1970,12 @@ static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i<<3]] -= ac_val[i];
+ block[s->dsp.idct_permutation[i<<3]] -= ac_val[i];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i<<3]] -= ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
+ block[s->dsp.idct_permutation[i<<3]] -= ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
}
}
} else {
@@ -1968,12 +1985,12 @@ static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i]] -= ac_val[i + 8];
+ block[s->dsp.idct_permutation[i]] -= ac_val[i + 8];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
- block[s->idct_permutation[i]] -= ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
+ block[s->dsp.idct_permutation[i]] -= ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
}
}
}
@@ -2023,21 +2040,21 @@ static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
}
#endif
}
-#ifdef CONFIG_ENCODERS
+
/**
* encodes a 8x8 block
* @param n block index (0-3 are luma, 4-5 are chroma)
*/
static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n, int intra_dc,
- UINT8 *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
+ uint8_t *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
{
int i, last_non_zero;
#if 0 //variables for the outcommented version
int code, sign, last;
#endif
const RLTable *rl;
- UINT32 *bits_tab;
- UINT8 *len_tab;
+ uint32_t *bits_tab;
+ uint8_t *len_tab;
const int last_index = s->block_last_index[n];
if (s->mb_intra) { //Note gcc (3.2.1 at least) will optimize this away
@@ -2145,11 +2162,11 @@ static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n
}
static inline int mpeg4_get_block_length(MpegEncContext * s, DCTELEM * block, int n, int intra_dc,
- UINT8 *scan_table)
+ uint8_t *scan_table)
{
int i, last_non_zero;
const RLTable *rl;
- UINT8 *len_tab;
+ uint8_t *len_tab;
const int last_index = s->block_last_index[n];
int len=0;
@@ -2283,9 +2300,13 @@ void h263_decode_init_vlc(MpegEncContext *s)
&mvtab[0][0], 2, 1);
init_rl(&rl_inter);
init_rl(&rl_intra);
+ init_rl(&rvlc_rl_inter);
+ init_rl(&rvlc_rl_intra);
init_rl(&rl_intra_aic);
init_vlc_rl(&rl_inter);
init_vlc_rl(&rl_intra);
+ init_vlc_rl(&rvlc_rl_inter);
+ init_vlc_rl(&rvlc_rl_intra);
init_vlc_rl(&rl_intra_aic);
init_vlc(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
&DCtab_lum[0][1], 2, 1,
@@ -2361,6 +2382,8 @@ static inline void memsetw(short *tab, int val, int n)
tab[i] = val;
}
+#ifdef CONFIG_ENCODERS
+
void ff_mpeg4_init_partitions(MpegEncContext *s)
{
init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL);
@@ -2392,6 +2415,8 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s)
s->last_bits= get_bit_count(&s->pb);
}
+#endif //CONFIG_ENCODERS
+
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){
switch(s->pict_type){
case I_TYPE:
@@ -2406,6 +2431,8 @@ int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){
}
}
+#ifdef CONFIG_ENCODERS
+
void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
{
int mb_num_bits= av_log2(s->mb_num - 1) + 1;
@@ -2419,6 +2446,8 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
put_bits(&s->pb, 1, 0); /* no HEC */
}
+#endif //CONFIG_ENCODERS
+
/**
* check if the next stuff is a resync marker or the end.
* @return 0 if not
@@ -2562,14 +2591,14 @@ void ff_mpeg4_clean_buffers(MpegEncContext *s)
#endif
/* clean AC */
- memset(s->ac_val[0] + l_xy, 0, (l_wrap*2+1)*16*sizeof(INT16));
- memset(s->ac_val[1] + c_xy, 0, (c_wrap +1)*16*sizeof(INT16));
- memset(s->ac_val[2] + c_xy, 0, (c_wrap +1)*16*sizeof(INT16));
+ memset(s->ac_val[0] + l_xy, 0, (l_wrap*2+1)*16*sizeof(int16_t));
+ memset(s->ac_val[1] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
+ memset(s->ac_val[2] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
/* clean MV */
// we cant clear the MVs as they might be needed by a b frame
-// memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(INT16));
-// memset(s->motion_val, 0, 2*sizeof(INT16)*(2 + s->mb_width*2)*(2 + s->mb_height*2));
+// memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(int16_t));
+// memset(s->motion_val, 0, 2*sizeof(int16_t)*(2 + s->mb_width*2)*(2 + s->mb_height*2));
s->last_mv[0][0][0]=
s->last_mv[0][0][1]=
s->last_mv[1][0][0]=
@@ -2669,7 +2698,7 @@ static inline int get_amv(MpegEncContext *s, int n){
*/
static int mpeg4_decode_partition_a(MpegEncContext *s){
int mb_num;
- static const INT8 quant_tab[4] = { -1, -2, 1, 2 };
+ static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
/* decode first partition */
mb_num=0;
@@ -2723,11 +2752,9 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
if(dc_pred_dir) dir|=1;
}
s->pred_dir_table[xy]= dir;
-
- s->error_status_table[xy]= AC_ERROR;
}else{ /* P/S_TYPE */
int mx, my, pred_x, pred_y, bits;
- INT16 * const mot_val= s->motion_val[s->block_index[0]];
+ int16_t * const mot_val= s->motion_val[s->block_index[0]];
const int stride= s->block_wrap[0]*2;
bits= show_bits(&s->gb, 17);
@@ -2753,8 +2780,6 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
if(s->mbintra_table[xy])
ff_clean_intra_table_entries(s);
-
- s->error_status_table[xy]= AC_ERROR;
continue;
}
cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
@@ -2778,7 +2803,6 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
mot_val[0+stride]= mot_val[2+stride]= 0;
mot_val[1 ]= mot_val[3 ]=
mot_val[1+stride]= mot_val[3+stride]= 0;
- s->error_status_table[xy]= DC_ERROR|AC_ERROR;
}else{
if(s->mbintra_table[xy])
ff_clean_intra_table_entries(s);
@@ -2815,7 +2839,7 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
PRINT_MB_TYPE("4");
s->mb_type[xy]= MB_TYPE_INTER4V;
for(i=0;i<4;i++) {
- INT16 *mot_val= h263_pred_motion(s, i, &pred_x, &pred_y);
+ int16_t *mot_val= h263_pred_motion(s, i, &pred_x, &pred_y);
mx = h263_decode_motion(s, pred_x, s->f_code);
if (mx >= 0xffff)
return -1;
@@ -2827,7 +2851,6 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
mot_val[1] = my;
}
}
- s->error_status_table[xy]= AC_ERROR;
}
}
}
@@ -2843,7 +2866,7 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
*/
static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
int mb_num=0;
- static const INT8 quant_tab[4] = { -1, -2, 1, 2 };
+ static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
s->mb_x= s->resync_mb_x;
s->first_slice_line=1;
@@ -2896,7 +2919,6 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
s->cbp_table[xy]&= 3; //remove dquant
s->cbp_table[xy]|= cbpy<<2;
s->pred_dir_table[xy]= dir | (ac_pred<<7);
- s->error_status_table[xy]&= ~DC_ERROR;
}else if(s->mb_type[xy]&MB_TYPE_SKIPED){
s->current_picture.qscale_table[xy]= s->qscale;
s->cbp_table[xy]= 0;
@@ -2931,13 +2953,18 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
int ff_mpeg4_decode_partitions(MpegEncContext *s)
{
int mb_num;
+ const int part_a_error= s->pict_type==I_TYPE ? (DC_ERROR|MV_ERROR) : MV_ERROR;
+ const int part_a_end = s->pict_type==I_TYPE ? (DC_END |MV_END) : MV_END;
mb_num= mpeg4_decode_partition_a(s);
- if(mb_num<0)
+ if(mb_num<0){
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
return -1;
+ }
if(s->resync_mb_x + s->resync_mb_y*s->mb_width + mb_num > s->mb_num){
fprintf(stderr, "slice below monitor ...\n");
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
return -1;
}
@@ -2947,21 +2974,23 @@ int ff_mpeg4_decode_partitions(MpegEncContext *s)
if(get_bits(&s->gb, 19)!=DC_MARKER){
fprintf(stderr, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y);
return -1;
- }else
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width-1]|= MV_END|DC_END;
+ }
}else{
if(get_bits(&s->gb, 17)!=MOTION_MARKER){
fprintf(stderr, "marker missing after first P partition at %d %d\n", s->mb_x, s->mb_y);
return -1;
- }else
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width-1]|= MV_END;
+ }
}
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, part_a_end);
if( mpeg4_decode_partition_b(s, mb_num) < 0){
+ if(s->pict_type==P_TYPE)
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, DC_ERROR);
return -1;
+ }else{
+ if(s->pict_type==P_TYPE)
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, DC_END);
}
-
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width-1]|= DC_END;
return 0;
}
@@ -3007,15 +3036,6 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
}
}else if(s->mb_intra){
s->ac_pred = s->pred_dir_table[xy]>>7;
-
- /* decode each block */
- for (i = 0; i < 6; i++) {
- if(mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0){
- fprintf(stderr, "texture corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- cbp+=cbp;
- }
}else if(!s->mb_intra){
// s->mcsel= 0; //FIXME do we need to init that
@@ -3025,32 +3045,24 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
} else {
s->mv_type = MV_TYPE_16X16;
}
- /* decode each block */
- for (i = 0; i < 6; i++) {
- if(mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0){
- fprintf(stderr, "texture corrupted at %d %d (trying to continue with mc/dc only)\n", s->mb_x, s->mb_y);
- return -1;
- }
- cbp+=cbp;
- }
}
} else { /* I-Frame */
- int i;
s->mb_intra = 1;
s->ac_pred = s->pred_dir_table[xy]>>7;
-
+ }
+
+ if (!(mb_type&MB_TYPE_SKIPED)) {
+ int i;
/* decode each block */
for (i = 0; i < 6; i++) {
- if(mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0){
- fprintf(stderr, "texture corrupted at %d %d (trying to continue with dc only)\n", s->mb_x, s->mb_y);
+ if(mpeg4_decode_block(s, block[i], i, cbp&32, s->mb_intra, s->rvlc) < 0){
+ fprintf(stderr, "texture corrupted at %d %d %d\n", s->mb_x, s->mb_y, s->mb_intra);
return -1;
}
cbp+=cbp;
}
}
- s->error_status_table[xy]&= ~AC_ERROR;
-
/* per-MB end of slice check */
if(--s->mb_num_left <= 0){
@@ -3071,10 +3083,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
DCTELEM block[6][64])
{
int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
- INT16 *mot_val;
- static INT8 quant_tab[4] = { -1, -2, 1, 2 };
-
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0;
+ int16_t *mot_val;
+ static int8_t quant_tab[4] = { -1, -2, 1, 2 };
if(s->mb_x==0) PRINT_MB_TYPE("\n");
@@ -3163,7 +3173,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
/* 16x16 motion prediction */
s->mv_type = MV_TYPE_16X16;
h263_pred_motion(s, 0, &pred_x, &pred_y);
- if (s->umvplus_dec)
+ if (s->umvplus)
mx = h263p_decode_umotion(s, pred_x);
else
mx = h263_decode_motion(s, pred_x, s->f_code);
@@ -3171,7 +3181,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
if (mx >= 0xffff)
return -1;
- if (s->umvplus_dec)
+ if (s->umvplus)
my = h263p_decode_umotion(s, pred_y);
else
my = h263_decode_motion(s, pred_y, s->f_code);
@@ -3181,7 +3191,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
s->mv[0][0][0] = mx;
s->mv[0][0][1] = my;
- if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
}
} else {
@@ -3189,14 +3199,14 @@ int ff_h263_decode_mb(MpegEncContext *s,
s->mv_type = MV_TYPE_8X8;
for(i=0;i<4;i++) {
mot_val = h263_pred_motion(s, i, &pred_x, &pred_y);
- if (s->umvplus_dec)
+ if (s->umvplus)
mx = h263p_decode_umotion(s, pred_x);
else
mx = h263_decode_motion(s, pred_x, s->f_code);
if (mx >= 0xffff)
return -1;
- if (s->umvplus_dec)
+ if (s->umvplus)
my = h263p_decode_umotion(s, pred_y);
else
my = h263_decode_motion(s, pred_y, s->f_code);
@@ -3204,7 +3214,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
return -1;
s->mv[0][i][0] = mx;
s->mv[0][i][1] = my;
- if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
mot_val[0] = mx;
mot_val[1] = my;
@@ -3214,7 +3224,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
int modb1; // first bit of modb
int modb2; // second bit of modb
int mb_type;
-
+
s->mb_intra = 0; //B-frames never contain intra blocks
s->mcsel=0; // ... true gmc blocks
@@ -3377,7 +3387,7 @@ intra:
/* decode each block */
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0)
+ if (mpeg4_decode_block(s, block[i], i, cbp&32, 1, 0) < 0)
return -1;
cbp+=cbp;
}
@@ -3394,7 +3404,7 @@ intra:
/* decode each block */
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0)
+ if (mpeg4_decode_block(s, block[i], i, cbp&32, 0, 0) < 0)
return -1;
cbp+=cbp;
}
@@ -3498,7 +3508,7 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
{
int code, level, i, j, last, run;
RLTable *rl = &rl_inter;
- const UINT8 *scan_table;
+ const uint8_t *scan_table;
scan_table = s->intra_scantable.permutated;
if (s->h263_aic && s->mb_intra) {
@@ -3512,7 +3522,8 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
}
} else if (s->mb_intra) {
/* DC coef */
- if (s->h263_rv10 && s->rv10_version == 3 && s->pict_type == I_TYPE) {
+ if(s->h263_rv10){
+ if (s->rv10_version == 3 && s->pict_type == I_TYPE) {
int component, diff;
component = (n <= 3 ? 0 : n - 4 + 1);
level = s->last_dc[component];
@@ -3526,8 +3537,15 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
} else {
s->rv10_first_dc_coded[component] = 1;
}
- } else {
+ } else {
+ level = get_bits(&s->gb, 8);
+ }
+ }else{
level = get_bits(&s->gb, 8);
+ if((level&0x7F) == 0){
+ fprintf(stderr, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
+ return -1;
+ }
if (level == 255)
level = 128;
}
@@ -3553,11 +3571,17 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
/* escape */
last = get_bits1(&s->gb);
run = get_bits(&s->gb, 6);
- level = (INT8)get_bits(&s->gb, 8);
- if (s->h263_rv10 && level == -128) {
- /* XXX: should patch encoder too */
- level = get_bits(&s->gb, 12);
- level= (level + ((-1)<<11)) ^ ((-1)<<11); //sign extension
+ level = (int8_t)get_bits(&s->gb, 8);
+ if(level == -128){
+ if (s->h263_rv10) {
+ /* XXX: should patch encoder too */
+ level = get_bits(&s->gb, 12);
+ level= (level + ((-1)<<11)) ^ ((-1)<<11); //sign extension
+ }else{
+ level = get_bits(&s->gb, 5);
+ level += get_bits(&s->gb, 6)<<5;
+ level= (level + ((-1)<<10)) ^ ((-1)<<10); //sign extension
+ }
}
} else {
run = rl->table_run[code];
@@ -3595,7 +3619,7 @@ not_coded:
static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
{
int level, pred, code;
- UINT16 *dc_val;
+ uint16_t *dc_val;
if (n < 4)
code = get_vlc2(&s->gb, dc_lum.table, DC_VLC_BITS, 1);
@@ -3648,15 +3672,17 @@ static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
* @return <0 if an error occured
*/
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
- int n, int coded, int intra)
+ int n, int coded, int intra, int rvlc)
{
int level, i, last, run;
int dc_pred_dir;
RLTable * rl;
RL_VLC_ELEM * rl_vlc;
- const UINT8 * scan_table;
+ const uint8_t * scan_table;
int qmul, qadd;
+ //Note intra & rvlc should be optimized away if this is inlined
+
if(intra) {
/* DC coef */
if(s->partitioned_frame){
@@ -3673,8 +3699,14 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
i = 0;
if (!coded)
goto not_coded;
- rl = &rl_intra;
- rl_vlc = rl_intra.rl_vlc[0];
+
+ if(rvlc){
+ rl = &rvlc_rl_intra;
+ rl_vlc = rvlc_rl_intra.rl_vlc[0];
+ }else{
+ rl = &rl_intra;
+ rl_vlc = rl_intra.rl_vlc[0];
+ }
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable.permutated; /* left */
@@ -3691,18 +3723,27 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
s->block_last_index[n] = i;
return 0;
}
- rl = &rl_inter;
+ if(rvlc) rl = &rvlc_rl_inter;
+ else rl = &rl_inter;
scan_table = s->intra_scantable.permutated;
if(s->mpeg_quant){
qmul=1;
qadd=0;
- rl_vlc = rl_inter.rl_vlc[0];
+ if(rvlc){
+ rl_vlc = rvlc_rl_inter.rl_vlc[0];
+ }else{
+ rl_vlc = rl_inter.rl_vlc[0];
+ }
}else{
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
- rl_vlc = rl_inter.rl_vlc[s->qscale];
+ if(rvlc){
+ rl_vlc = rvlc_rl_inter.rl_vlc[s->qscale];
+ }else{
+ rl_vlc = rl_inter.rl_vlc[s->qscale];
+ }
}
}
{
@@ -3711,9 +3752,39 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
if (level==0) {
+ /* escape */
+ if(rvlc){
+ if(SHOW_UBITS(re, &s->gb, 1)==0){
+ fprintf(stderr, "1. marker bit missing in rvlc esc\n");
+ return -1;
+ }; SKIP_CACHE(re, &s->gb, 1);
+
+ last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
+ run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
+ SKIP_COUNTER(re, &s->gb, 1+1+6);
+ UPDATE_CACHE(re, &s->gb);
+
+ if(SHOW_UBITS(re, &s->gb, 1)==0){
+ fprintf(stderr, "2. marker bit missing in rvlc esc\n");
+ return -1;
+ }; SKIP_CACHE(re, &s->gb, 1);
+
+ level= SHOW_UBITS(re, &s->gb, 11); SKIP_CACHE(re, &s->gb, 11);
+
+ if(SHOW_UBITS(re, &s->gb, 5)!=0x10){
+ fprintf(stderr, "reverse esc missing\n");
+ return -1;
+ }; SKIP_CACHE(re, &s->gb, 5);
+
+ level= level * qmul + qadd;
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_CACHE(re, &s->gb, 1);
+ SKIP_COUNTER(re, &s->gb, 1+11+5+1);
+
+ i+= run + 1;
+ if(last) i+=192;
+ }else{
int cache;
cache= GET_CACHE(re, &s->gb);
- /* escape */
if (cache&0x80000000) {
if (cache&0x40000000) {
/* third escape */
@@ -3795,6 +3866,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
+ }
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
@@ -3906,7 +3978,7 @@ int h263_decode_picture_header(MpegEncContext *s)
format = get_bits(&s->gb, 3);
dprintf("ufep=1, format: %d\n", format);
skip_bits(&s->gb,1); /* Custom PCF */
- s->umvplus_dec = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
+ s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
skip_bits1(&s->gb); /* Syntax-based Arithmetic Coding (SAC) */
if (get_bits1(&s->gb) != 0) {
s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */
@@ -3977,8 +4049,9 @@ int h263_decode_picture_header(MpegEncContext *s)
return -1;
s->width = width;
s->height = height;
- if (s->umvplus_dec) {
- skip_bits1(&s->gb); /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
+ if (s->umvplus) {
+ if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
+ skip_bits1(&s->gb);
}
}
@@ -4007,7 +4080,7 @@ static void mpeg4_decode_sprite_trajectory(MpegEncContext * s)
int a= 2<<s->sprite_warping_accuracy;
int rho= 3-s->sprite_warping_accuracy;
int r=16/a;
- int vop_ref[4][2]= {{0,0}, {s->width,0}, {0, s->height}, {s->width, s->height}}; // only true for rectangle shapes
+ const int vop_ref[4][2]= {{0,0}, {s->width,0}, {0, s->height}, {s->width, s->height}}; // only true for rectangle shapes
int d[4][2]={{0,0}, {0,0}, {0,0}, {0,0}};
int sprite_ref[4][2];
int virtual_ref[2][2];
@@ -4351,11 +4424,11 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
// FIXME a bunch of grayscale shape things
if((s->mpeg_quant=get_bits1(gb))){ /* vol_quant_type */
- int i, j, v;
+ int i, v;
/* load default matrixes */
for(i=0; i<64; i++){
- int j= s->idct_permutation[i];
+ int j= s->dsp.idct_permutation[i];
v= ff_mpeg4_default_intra_matrix[i];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
@@ -4368,19 +4441,20 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
/* load custom intra matrix */
if(get_bits1(gb)){
int last=0;
- for(i=0; i<64; i++){
+ for(i=0; i<64; i++){
+ int j;
v= get_bits(gb, 8);
if(v==0) break;
last= v;
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
}
/* replicate last value */
for(; i<64; i++){
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
}
@@ -4389,19 +4463,20 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
/* load custom non intra matrix */
if(get_bits1(gb)){
int last=0;
- for(i=0; i<64; i++){
+ for(i=0; i<64; i++){
+ int j;
v= get_bits(gb, 8);
if(v==0) break;
last= v;
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j]= v;
s->chroma_inter_matrix[j]= v;
}
/* replicate last value */
for(; i<64; i++){
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j]= last;
s->chroma_inter_matrix[j]= last;
}
@@ -4421,9 +4496,6 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
s->data_partitioning= get_bits1(gb);
if(s->data_partitioning){
s->rvlc= get_bits1(gb);
- if(s->rvlc){
- printf("reversible vlc not supported\n");
- }
}
if(vo_ver_id != 1) {
@@ -4486,6 +4558,7 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
int i;
int e;
int ver, build, ver2, ver3;
+ char last;
buf[0]= show_bits(gb, 8);
for(i=1; i<256; i++){
@@ -4494,16 +4567,21 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
skip_bits(gb, 8);
}
buf[255]=0;
-
+
/* divx detection */
- e=sscanf(buf, "DivX%dBuild%d", &ver, &build);
- if(e!=2)
- e=sscanf(buf, "DivX%db%d", &ver, &build);
- if(e==2){
+ e=sscanf(buf, "DivX%dBuild%d%c", &ver, &build, &last);
+ if(e<2)
+ e=sscanf(buf, "DivX%db%d%c", &ver, &build, &last);
+ if(e>=2){
s->divx_version= ver;
s->divx_build= build;
+ s->divx_packed= e==3 && last=='p';
if(s->picture_number==0){
- printf("This file was encoded with DivX%d Build%d\n", ver, build);
+ printf("This file was encoded with DivX%d Build%d", ver, build);
+ if(s->divx_packed)
+ printf("p\n");
+ else
+ printf("\n");
}
}
@@ -4560,6 +4638,17 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
time_incr++;
check_marker(gb, "before time_increment");
+
+ if(s->picture_number==0 && (show_bits(gb, s->time_increment_bits+1)&1)==0){
+ printf("hmm, seems the headers arnt complete, trying to guess time_increment_bits\n");
+
+
+ for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){
+ if(show_bits(gb, s->time_increment_bits+1)&1) break;
+ }
+ printf("my guess is %d bits ;)\n",s->time_increment_bits);
+ }
+
time_increment= get_bits(gb, s->time_increment_bits);
//printf(" type:%d modulo_time_base:%d increment:%d\n", s->pict_type, time_incr, time_increment);
if(s->pict_type!=B_TYPE){
@@ -4596,13 +4685,8 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
if(s->avctx->debug&FF_DEBUG_PTS)
printf("MPEG4 PTS: %f\n", s->current_picture.pts/(1000.0*1000.0));
- if(check_marker(gb, "before vop_coded")==0 && s->picture_number==0){
- printf("hmm, seems the headers arnt complete, trying to guess time_increment_bits\n");
- for(s->time_increment_bits++ ;s->time_increment_bits<16; s->time_increment_bits++){
- if(get_bits1(gb)) break;
- }
- printf("my guess is %d bits ;)\n",s->time_increment_bits);
- }
+ check_marker(gb, "before vop_coded");
+
/* vop coded */
if (get_bits1(gb) != 1){
printf("vop not coded\n");
@@ -4724,7 +4808,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
- if(s->divx_version==0 || s->divx_version < 500){
+ if(!(s->workaround_bugs&FF_BUG_EDGE)){
s->h_edge_pos= s->width;
s->v_edge_pos= s->height;
}
diff --git a/src/libffmpeg/libavcodec/h263data.h b/src/libffmpeg/libavcodec/h263data.h
index 5aa1e18db..132ed98a9 100644
--- a/src/libffmpeg/libavcodec/h263data.h
+++ b/src/libffmpeg/libavcodec/h263data.h
@@ -1,11 +1,16 @@
+/**
+ * @file h263data.h
+ * H.263 tables.
+ */
+
/* intra MCBPC, mb_type = (intra), then (intraq) */
-const UINT8 intra_MCBPC_code[8] = { 1, 1, 2, 3, 1, 1, 2, 3 };
-const UINT8 intra_MCBPC_bits[8] = { 1, 3, 3, 3, 4, 6, 6, 6 };
+const uint8_t intra_MCBPC_code[8] = { 1, 1, 2, 3, 1, 1, 2, 3 };
+const uint8_t intra_MCBPC_bits[8] = { 1, 3, 3, 3, 4, 6, 6, 6 };
/* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */
/* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */
-const UINT8 inter_MCBPC_code[25] = {
+const uint8_t inter_MCBPC_code[25] = {
1, 3, 2, 5,
3, 4, 3, 3,
3, 7, 6, 5,
@@ -14,7 +19,7 @@ const UINT8 inter_MCBPC_code[25] = {
1, /* Stuffing */
2, 12, 14, 15,
};
-const UINT8 inter_MCBPC_bits[25] = {
+const uint8_t inter_MCBPC_bits[25] = {
1, 4, 4, 6,
5, 8, 8, 7,
3, 7, 7, 9,
@@ -25,14 +30,14 @@ const UINT8 inter_MCBPC_bits[25] = {
};
/* This is the old table
-static const UINT8 inter_MCBPC_code[20] = {
+static const uint8_t inter_MCBPC_code[20] = {
1, 3, 2, 5,
3, 4, 3, 3,
0, 1, 2, 3,
4, 4, 3, 2,
2, 5, 4, 5,
};
-static const UINT8 inter_MCBPC_bits[20] = {
+static const uint8_t inter_MCBPC_bits[20] = {
1, 4, 4, 6,
5, 8, 8, 7,
12, 12, 12, 12,
@@ -40,13 +45,13 @@ static const UINT8 inter_MCBPC_bits[20] = {
3, 7, 7, 8,
};*/
-const UINT8 cbpy_tab[16][2] =
+const uint8_t cbpy_tab[16][2] =
{
{3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4},
{2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2}
};
-const UINT8 mvtab[33][2] =
+const uint8_t mvtab[33][2] =
{
{1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
{11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10},
@@ -56,7 +61,7 @@ const UINT8 mvtab[33][2] =
};
/* third non intra table */
-const UINT16 inter_vlc[103][2] = {
+const uint16_t inter_vlc[103][2] = {
{ 0x2, 2 },{ 0xf, 4 },{ 0x15, 6 },{ 0x17, 7 },
{ 0x1f, 8 },{ 0x25, 9 },{ 0x24, 9 },{ 0x21, 10 },
{ 0x20, 10 },{ 0x7, 11 },{ 0x6, 11 },{ 0x20, 11 },
@@ -85,7 +90,7 @@ const UINT16 inter_vlc[103][2] = {
{ 0x5e, 12 },{ 0x5f, 12 },{ 0x3, 7 },
};
-const INT8 inter_level[102] = {
+const int8_t inter_level[102] = {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 1, 2, 3, 4,
5, 6, 1, 2, 3, 4, 1, 2,
@@ -101,7 +106,7 @@ const INT8 inter_level[102] = {
1, 1, 1, 1, 1, 1,
};
-const INT8 inter_run[102] = {
+const int8_t inter_run[102] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 2, 2, 2, 2, 3, 3,
@@ -125,7 +130,7 @@ static RLTable rl_inter = {
inter_level,
};
-const UINT16 intra_vlc_aic[103][2] = {
+const uint16_t intra_vlc_aic[103][2] = {
{ 0x2, 2 }, { 0x6, 3 }, { 0xe, 4 }, { 0xc, 5 },
{ 0xd, 5 }, { 0x10, 6 }, { 0x11, 6 }, { 0x12, 6 },
{ 0x16, 7 }, { 0x1b, 8 }, { 0x20, 9 }, { 0x21, 9 },
@@ -154,7 +159,7 @@ const UINT16 intra_vlc_aic[103][2] = {
{ 0x59, 12 }, { 0x5a, 12 }, { 0x3, 7 },
};
-const INT8 intra_run_aic[102] = {
+const int8_t intra_run_aic[102] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -170,7 +175,7 @@ const INT8 intra_run_aic[102] = {
18, 19, 20, 21, 22, 23,
};
-const INT8 intra_level_aic[102] = {
+const int8_t intra_level_aic[102] = {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
@@ -194,7 +199,7 @@ static RLTable rl_intra_aic = {
intra_level_aic,
};
-static const UINT16 h263_format[8][2] = {
+static const uint16_t h263_format[8][2] = {
{ 0, 0 },
{ 128, 96 },
{ 176, 144 },
@@ -203,7 +208,7 @@ static const UINT16 h263_format[8][2] = {
{ 1408, 1152 },
};
-static UINT8 h263_aic_dc_scale_table[32]={
+static uint8_t h263_aic_dc_scale_table[32]={
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
};
diff --git a/src/libffmpeg/libavcodec/h263dec.c b/src/libffmpeg/libavcodec/h263dec.c
index 5f6454d5a..2b9443908 100644
--- a/src/libffmpeg/libavcodec/h263dec.c
+++ b/src/libffmpeg/libavcodec/h263dec.c
@@ -1,5 +1,5 @@
/*
- * H263 decoder
+ * H.263 decoder
* Copyright (c) 2001 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
@@ -16,16 +16,15 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file h263dec.c
+ * H.263 decoder.
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "xineutils.h"
-
-#if 1
-#define PRINT_QP(a, b) {}
-#else
-#define PRINT_QP(a, b) printf(a, b)
-#endif
//#define DEBUG
//#define PRINT_FRAME_TIME
@@ -129,7 +128,7 @@ int ff_h263_decode_end(AVCodecContext *avctx)
static int get_consumed_bytes(MpegEncContext *s, int buf_size){
int pos= (get_bits_count(&s->gb)+7)>>3;
- if(s->divx_version>=500){
+ if(s->divx_packed){
//we would have to scan through the whole buf to handle the weird reordering ...
return buf_size;
}else if(s->flags&CODEC_FLAG_TRUNCATED){
@@ -145,6 +144,7 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size){
}
static int decode_slice(MpegEncContext *s){
+ const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
s->last_resync_gb= s->gb;
s->first_slice_line= 1;
@@ -175,8 +175,8 @@ static int decode_slice(MpegEncContext *s){
/* per-row end of slice checks */
if(s->msmpeg4_version){
if(s->resync_mb_y + s->slice_height == s->mb_y){
- const int xy= s->mb_x + s->mb_y*s->mb_width;
- s->error_status_table[xy-1]|= AC_END|DC_END|MV_END;
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
+
return 0;
}
}
@@ -206,47 +206,40 @@ static int decode_slice(MpegEncContext *s){
//printf("%d %d %06X\n", ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
ret= s->decode_mb(s, s->block);
- PRINT_QP("%2d", s->qscale);
MPV_decode_mb(s, s->block);
if(ret<0){
const int xy= s->mb_x + s->mb_y*s->mb_width;
if(ret==SLICE_END){
//printf("%d %d %d %06X\n", s->mb_x, s->mb_y, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24));
- s->error_status_table[xy]|= AC_END;
- if(!s->partitioned_frame)
- s->error_status_table[xy]|= MV_END|DC_END;
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
s->padding_bug_score--;
if(++s->mb_x >= s->mb_width){
s->mb_x=0;
- ff_draw_horiz_band(s);
+ ff_draw_horiz_band(s, s->mb_y*16, 16);
s->mb_y++;
}
return 0;
}else if(ret==SLICE_NOEND){
fprintf(stderr,"Slice mismatch at MB: %d\n", xy);
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
return -1;
}
fprintf(stderr,"Error at MB: %d\n", xy);
- s->error_status_table[xy]|= AC_ERROR;
- if(!s->partitioned_frame)
- s->error_status_table[xy]|= DC_ERROR|MV_ERROR;
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
return -1;
}
}
- ff_draw_horiz_band(s);
-
- PRINT_QP("%s", "\n");
+ ff_draw_horiz_band(s, s->mb_y*16, 16);
s->mb_x= 0;
}
- XINE_ASSERT(s->mb_x==0, "s->mb_x (%d) != 0", s->mb_x);
- XINE_ASSERT(s->mb_y==s->mb_height, "s->mb_y (%d) != s->mb_height (%d)", s->mb_y, s->mb_height);
+ assert(s->mb_x==0 && s->mb_y==s->mb_height);
/* try to detect the padding bug */
if( s->codec_id==CODEC_ID_MPEG4
@@ -295,7 +288,7 @@ static int decode_slice(MpegEncContext *s){
else if(left<0){
fprintf(stderr, "overreading %d bits\n", -left);
}else
- s->error_status_table[s->mb_num-1]|= AC_END|MV_END|DC_END;
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
return 0;
}
@@ -303,6 +296,9 @@ static int decode_slice(MpegEncContext *s){
fprintf(stderr, "slice end not reached but screenspace end (%d left %06X)\n",
s->gb.size_in_bits - get_bits_count(&s->gb),
show_bits(&s->gb, 24));
+
+ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
+
return -1;
}
@@ -310,7 +306,7 @@ static int decode_slice(MpegEncContext *s){
* finds the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
-static int mpeg4_find_frame_end(MpegEncContext *s, UINT8 *buf, int buf_size){
+static int mpeg4_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
ParseContext *pc= &s->parse_context;
int vop_found, i;
uint32_t state;
@@ -343,6 +339,13 @@ static int mpeg4_find_frame_end(MpegEncContext *s, UINT8 *buf, int buf_size){
return -1;
}
+/**
+ * draws an line from (ex, ey) -> (sx, sy).
+ * @param w width of the image
+ * @param h height of the image
+ * @param stride stride/linesize of the image
+ * @param color color of the arrow
+ */
static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
int t, x, y, f;
@@ -379,6 +382,13 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h
}
}
+/**
+ * draws an arrow from (ex, ey) -> (sx, sy).
+ * @param w width of the image
+ * @param h height of the image
+ * @param stride stride/linesize of the image
+ * @param color color of the arrow
+ */
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
int dx= ex - sx;
int dy= ey - sy;
@@ -400,7 +410,7 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int ret,i;
@@ -479,16 +489,16 @@ retry:
else
s->workaround_bugs &= ~FF_BUG_NO_PADDING;
- if(s->avctx->fourcc == ff_get_fourcc("XVIX"))
+ if(s->avctx->codec_tag == ff_get_fourcc("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
#if 0
- if(s->avctx->fourcc == ff_get_fourcc("MP4S"))
+ if(s->avctx->codec_tag == ff_get_fourcc("MP4S"))
s->workaround_bugs|= FF_BUG_AC_VLC;
- if(s->avctx->fourcc == ff_get_fourcc("M4S2"))
+ if(s->avctx->codec_tag == ff_get_fourcc("M4S2"))
s->workaround_bugs|= FF_BUG_AC_VLC;
#endif
- if(s->avctx->fourcc == ff_get_fourcc("UMP4")){
+ if(s->avctx->codec_tag == ff_get_fourcc("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
s->workaround_bugs|= FF_BUG_AC_VLC;
}
@@ -501,10 +511,10 @@ retry:
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
- if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0)
+ if(s->avctx->codec_tag == ff_get_fourcc("XVID") && s->xvid_build==0)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
- if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0)
+ if(s->avctx->codec_tag == ff_get_fourcc("XVID") && s->xvid_build==0)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build && s->xvid_build<=3)
@@ -513,9 +523,6 @@ retry:
if(s->xvid_build && s->xvid_build<=1)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
- if(s->xvid_build && s->xvid_build>=8)
- s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
-
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
@@ -524,10 +531,22 @@ retry:
if(s->lavc_build && s->lavc_build<4653)
s->workaround_bugs|= FF_BUG_STD_QPEL;
+ if(s->lavc_build && s->lavc_build<4655)
+ s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
+
+ if(s->divx_version)
+ s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
//printf("padding_bug_score: %d\n", s->padding_bug_score);
+ if(s->divx_version==501 && s->divx_build==20020416)
+ s->padding_bug_score= 256*256*256*64;
+
+ if(s->divx_version>=500){
+ s->workaround_bugs|= FF_BUG_EDGE;
+ }
+
#if 0
if(s->divx_version==500)
- s->workaround_bugs|= FF_BUG_NO_PADDING;
+ s->padding_bug_score= 256*256*256*64;
/* very ugly XVID padding bug detection FIXME/XXX solve this differently
* lets hope this at least works
@@ -578,7 +597,6 @@ retry:
|| ABS(new_aspect - avctx->aspect_ratio) > 0.001) {
/* H.263 could change picture size any time */
MPV_common_end(s);
- s->context_initialized=0;
}
if (!s->context_initialized) {
avctx->width = s->width;
@@ -603,7 +621,7 @@ retry:
s->current_picture.key_frame= s->pict_type == I_TYPE;
/* skip b frames if we dont have reference frames */
- if(s->last_picture.data[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
+ if(s->last_picture_ptr==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
/* skip b frames if we are in a hurry */
if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
/* skip everything if we are in a hurry>=5 */
@@ -623,8 +641,7 @@ retry:
printf("qscale=%d\n", s->qscale);
#endif
- if(s->error_resilience)
- memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8));
+ ff_er_frame_start(s);
/* decode each macroblock */
s->block_wrap[0]=
@@ -637,7 +654,6 @@ retry:
s->mb_y=0;
decode_slice(s);
- s->error_status_table[0]|= VP_START;
while(s->mb_y<s->mb_height && s->gb.size_in_bits - get_bits_count(&s->gb)>16){
if(s->msmpeg4_version){
if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0)
@@ -651,8 +667,6 @@ retry:
ff_mpeg4_clean_buffers(s);
decode_slice(s);
-
- s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START;
}
if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE)
@@ -661,7 +675,7 @@ retry:
}
/* divx 5.01+ bistream reorder stuff */
- if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){
+ if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_packed){
int current_pos= get_bits_count(&s->gb)>>3;
if( buf_size - current_pos > 5
@@ -681,39 +695,11 @@ retry:
}
}
- if(s->error_resilience){
- int error=0, num_end_markers=0;
- for(i=0; i<s->mb_num; i++){
- int status= s->error_status_table[i];
-#if 0
- if(i%s->mb_width == 0) printf("\n");
- printf("%2X ", status);
-#endif
- if(status==0) continue;
-
- if(status&(DC_ERROR|AC_ERROR|MV_ERROR))
- error=1;
- if(status&VP_START){
- if(num_end_markers)
- error=1;
- num_end_markers=3;
- }
- if(status&AC_END)
- num_end_markers--;
- if(status&DC_END)
- num_end_markers--;
- if(status&MV_END)
- num_end_markers--;
- }
- if(num_end_markers || error){
- fprintf(stderr, "concealing errors\n");
- ff_error_resilience(s);
- }
- }
+ ff_er_frame_end(s);
MPV_frame_end(s);
- if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture.data[0]){
+ if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture_ptr){
const int shift= 1 + s->quarter_sample;
int mb_y;
uint8_t *ptr= s->last_picture.data[0];
@@ -771,7 +757,7 @@ retry:
avctx->frame_number = s->picture_number - 1;
/* dont output the last pic after seeking */
- if(s->last_picture.data[0] || s->low_delay)
+ if(s->last_picture_ptr || s->low_delay)
*data_size = sizeof(AVFrame);
#ifdef PRINT_FRAME_TIME
printf("%Ld\n", rdtsc()-time);
@@ -779,6 +765,12 @@ printf("%Ld\n", rdtsc()-time);
return get_consumed_bytes(s, buf_size);
}
+static const AVOption mpeg4_decoptions[] =
+{
+ AVOPTION_SUB(avoptions_workaround_bug),
+ AVOPTION_END()
+};
+
AVCodec mpeg4_decoder = {
"mpeg4",
CODEC_TYPE_VIDEO,
@@ -789,6 +781,7 @@ AVCodec mpeg4_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
+ .options = mpeg4_decoptions,
};
AVCodec h263_decoder = {
@@ -813,6 +806,7 @@ AVCodec msmpeg4v1_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ mpeg4_decoptions,
};
AVCodec msmpeg4v2_decoder = {
@@ -825,6 +819,7 @@ AVCodec msmpeg4v2_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ mpeg4_decoptions,
};
AVCodec msmpeg4v3_decoder = {
@@ -837,6 +832,7 @@ AVCodec msmpeg4v3_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .options = mpeg4_decoptions,
};
AVCodec wmv1_decoder = {
@@ -849,6 +845,7 @@ AVCodec wmv1_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ mpeg4_decoptions,
};
AVCodec h263i_decoder = {
@@ -861,5 +858,6 @@ AVCodec h263i_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ mpeg4_decoptions,
};
diff --git a/src/libffmpeg/libavcodec/huffyuv.c b/src/libffmpeg/libavcodec/huffyuv.c
index eccb57983..eb4dc8387 100644
--- a/src/libffmpeg/libavcodec/huffyuv.c
+++ b/src/libffmpeg/libavcodec/huffyuv.c
@@ -67,19 +67,19 @@ typedef struct HYuvContext{
DSPContext dsp;
}HYuvContext;
-static unsigned char classic_shift_luma[] = {
+static const unsigned char classic_shift_luma[] = {
34,36,35,69,135,232,9,16,10,24,11,23,12,16,13,10,14,8,15,8,
16,8,17,20,16,10,207,206,205,236,11,8,10,21,9,23,8,8,199,70,
69,68, 0
};
-static unsigned char classic_shift_chroma[] = {
+static const unsigned char classic_shift_chroma[] = {
66,36,37,38,39,40,41,75,76,77,110,239,144,81,82,83,84,85,118,183,
56,57,88,89,56,89,154,57,58,57,26,141,57,56,58,57,58,57,184,119,
214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0
};
-static unsigned char classic_add_luma[256] = {
+static const unsigned char classic_add_luma[256] = {
3, 9, 5, 12, 10, 35, 32, 29, 27, 50, 48, 45, 44, 41, 39, 37,
73, 70, 68, 65, 64, 61, 58, 56, 53, 50, 49, 46, 44, 41, 38, 36,
68, 65, 63, 61, 58, 55, 53, 51, 48, 46, 45, 43, 41, 39, 38, 36,
@@ -98,7 +98,7 @@ static unsigned char classic_add_luma[256] = {
46, 47, 49, 51, 26, 28, 30, 31, 33, 34, 18, 19, 11, 13, 7, 8,
};
-static unsigned char classic_add_chroma[256] = {
+static const unsigned char classic_add_chroma[256] = {
3, 1, 2, 2, 2, 2, 3, 3, 7, 5, 7, 5, 8, 6, 11, 9,
7, 13, 11, 10, 9, 8, 7, 5, 9, 7, 6, 4, 7, 5, 8, 7,
11, 8, 13, 11, 19, 15, 22, 23, 20, 33, 32, 28, 27, 29, 51, 77,
@@ -383,19 +383,16 @@ static int decode_init(AVCodecContext *avctx)
s->avctx= avctx;
s->flags= avctx->flags;
- dsputil_init(&s->dsp, avctx->dsp_mask);
+ dsputil_init(&s->dsp, avctx);
width= s->width= avctx->width;
height= s->height= avctx->height;
avctx->coded_frame= &s->picture;
- s->bgr32=1;
- XINE_ASSERT(width,"value 'width' is not defined");
- XINE_ASSERT(height, "value 'height' is not defined");
-
- //if(avctx->extradata)
- // printf("extradata:%X, extradata_size:%d\n", *(uint32_t*)avctx->extradata, avctx->extradata_size);
-
+s->bgr32=1;
+ assert(width && height);
+//if(avctx->extradata)
+// printf("extradata:%X, extradata_size:%d\n", *(uint32_t*)avctx->extradata, avctx->extradata_size);
if(avctx->extradata_size){
if((avctx->bits_per_sample&7) && avctx->bits_per_sample != 12)
s->version=1; // do such files exist at all?
@@ -467,7 +464,7 @@ static int decode_init(AVCodecContext *avctx)
}
break;
default:
- XINE_ASSERT(0,"We do not have a default action.");
+ assert(0);
}
// printf("pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_sample, s->interlaced);
@@ -507,13 +504,12 @@ static int encode_init(AVCodecContext *avctx)
s->avctx= avctx;
s->flags= avctx->flags;
- dsputil_init(&s->dsp, avctx->dsp_mask);
+ dsputil_init(&s->dsp, avctx);
width= s->width= avctx->width;
height= s->height= avctx->height;
- XINE_ASSERT(width, "value 'width' is not defined");
- XINE_ASSERT(height, "value 'height' is not defined");
+ assert(width && height);
avctx->extradata= av_mallocz(1024*10);
avctx->stats_out= av_mallocz(1024*10);
@@ -697,7 +693,7 @@ static void decode_bgr_bitstream(HYuvContext *s, int count){
static void draw_slice(HYuvContext *s, int y){
int h, cy;
- UINT8 *src_ptr[3];
+ uint8_t *src_ptr[3];
if(s->avctx->draw_horiz_band==NULL)
return;
@@ -952,7 +948,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
*data_size = sizeof(AVFrame);
- return (((get_bits_count(&s->gb)+7)>>3) + 3) & ~3;
+ return (get_bits_count(&s->gb)+31)/32*4;
}
static int decode_end(AVCodecContext *avctx)
@@ -1136,6 +1132,12 @@ static int encode_end(AVCodecContext *avctx)
return 0;
}
+static const AVOption huffyuv_options[] =
+{
+ AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0),
+ AVOPTION_END()
+};
+
AVCodec huffyuv_decoder = {
"huffyuv",
CODEC_TYPE_VIDEO,
@@ -1157,4 +1159,5 @@ AVCodec huffyuv_encoder = {
encode_init,
encode_frame,
encode_end,
+ .options = huffyuv_options,
};
diff --git a/src/libffmpeg/libavcodec/i386/dsputil_mmx.c b/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
index 857f1d398..d5a2d3734 100644
--- a/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
@@ -20,33 +20,9 @@
*/
#include "../dsputil.h"
+#include "../simple_idct.h"
int mm_flags; /* multimedia extension flags */
-/* FIXME use them in static form */
-int pix_abs16x16_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs16x16_x2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs16x16_y2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs16x16_xy2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-
-int pix_abs16x16_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs16x16_x2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs16x16_y2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs16x16_xy2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-
-int pix_abs8x8_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs8x8_x2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs8x8_y2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs8x8_xy2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
-
-int pix_abs8x8_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs8x8_x2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs8x8_y2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-int pix_abs8x8_xy2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
-
-int sad16x16_mmx(void *s, UINT8 *blk1, UINT8 *blk2, int lx);
-int sad8x8_mmx(void *s, UINT8 *blk1, UINT8 *blk2, int lx);
-int sad16x16_mmx2(void *s, UINT8 *blk1, UINT8 *blk2, int lx);
-int sad8x8_mmx2(void *s, UINT8 *blk1, UINT8 *blk2, int lx);
/* pixel operations */
static const uint64_t mm_bone __attribute__ ((aligned(8))) = 0x0101010101010101ULL;
@@ -195,7 +171,7 @@ static const uint64_t ff_pw_15 __attribute__ ((aligned(8))) = 0x000F000F000F000F
/***********************************/
/* standard MMX */
-static void get_pixels_mmx(DCTELEM *block, const UINT8 *pixels, int line_size)
+static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
{
asm volatile(
"movl $-128, %%eax \n\t"
@@ -223,7 +199,7 @@ static void get_pixels_mmx(DCTELEM *block, const UINT8 *pixels, int line_size)
);
}
-static inline void diff_pixels_mmx(DCTELEM *block, const UINT8 *s1, const UINT8 *s2, int stride)
+static inline void diff_pixels_mmx(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
@@ -252,10 +228,10 @@ static inline void diff_pixels_mmx(DCTELEM *block, const UINT8 *s1, const UINT8
);
}
-void put_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size)
+void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
const DCTELEM *p;
- UINT8 *pix;
+ uint8_t *pix;
/* read the pixels */
p = block;
@@ -307,10 +283,10 @@ void put_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size)
:"memory");
}
-void add_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size)
+void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
const DCTELEM *p;
- UINT8 *pix;
+ uint8_t *pix;
int i;
/* read the pixels */
@@ -348,7 +324,7 @@ void add_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size)
} while (--i);
}
-static void put_pixels8_mmx(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -374,7 +350,7 @@ static void put_pixels8_mmx(UINT8 *block, const UINT8 *pixels, int line_size, in
);
}
-static void put_pixels16_mmx(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -425,7 +401,7 @@ static void clear_blocks_mmx(DCTELEM *blocks)
);
}
-static int pix_sum16_mmx(UINT8 * pix, int line_size){
+static int pix_sum16_mmx(uint8_t * pix, int line_size){
const int h=16;
int sum;
int index= -line_size*h;
@@ -528,7 +504,7 @@ static int pix_norm1_mmx(uint8_t *pix, int line_size) {
return tmp;
}
-static int sse16_mmx(void *v, UINT8 * pix1, UINT8 * pix2, int line_size) {
+static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size) {
int tmp;
asm volatile (
"movl $16,%%ecx\n"
@@ -607,26 +583,21 @@ static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
for(; i<w; i++)
dst[i+0] = src1[i+0]-src2[i+0];
}
-#define LBUTTERFLY(a,b)\
- "paddw " #b ", " #a " \n\t"\
- "paddw " #b ", " #b " \n\t"\
- "psubw " #a ", " #b " \n\t"
+#define LBUTTERFLY2(a1,b1,a2,b2)\
+ "paddw " #b1 ", " #a1 " \n\t"\
+ "paddw " #b2 ", " #a2 " \n\t"\
+ "paddw " #b1 ", " #b1 " \n\t"\
+ "paddw " #b2 ", " #b2 " \n\t"\
+ "psubw " #a1 ", " #b1 " \n\t"\
+ "psubw " #a2 ", " #b1 " \n\t"
#define HADAMARD48\
- LBUTTERFLY(%%mm0, %%mm1)\
- LBUTTERFLY(%%mm2, %%mm3)\
- LBUTTERFLY(%%mm4, %%mm5)\
- LBUTTERFLY(%%mm6, %%mm7)\
- \
- LBUTTERFLY(%%mm0, %%mm2)\
- LBUTTERFLY(%%mm1, %%mm3)\
- LBUTTERFLY(%%mm4, %%mm6)\
- LBUTTERFLY(%%mm5, %%mm7)\
- \
- LBUTTERFLY(%%mm0, %%mm4)\
- LBUTTERFLY(%%mm1, %%mm5)\
- LBUTTERFLY(%%mm2, %%mm6)\
- LBUTTERFLY(%%mm3, %%mm7)
+ LBUTTERFLY2(%%mm0, %%mm1, %%mm2, %%mm3)\
+ LBUTTERFLY2(%%mm4, %%mm5, %%mm6, %%mm7)\
+ LBUTTERFLY2(%%mm0, %%mm2, %%mm1, %%mm3)\
+ LBUTTERFLY2(%%mm4, %%mm6, %%mm5, %%mm7)\
+ LBUTTERFLY2(%%mm0, %%mm4, %%mm1, %%mm5)\
+ LBUTTERFLY2(%%mm2, %%mm6, %%mm3, %%mm7)\
#define MMABS(a,z)\
"pxor " #z ", " #z " \n\t"\
@@ -641,12 +612,22 @@ static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
"psubw " #z ", " #a " \n\t"\
"paddusw " #a ", " #sum " \n\t"
-
+#define MMABS_MMX2(a,z)\
+ "pxor " #z ", " #z " \n\t"\
+ "psubw " #a ", " #z " \n\t"\
+ "pmaxsw " #z ", " #a " \n\t"
+
+#define MMABS_SUM_MMX2(a,z, sum)\
+ "pxor " #z ", " #z " \n\t"\
+ "psubw " #a ", " #z " \n\t"\
+ "pmaxsw " #z ", " #a " \n\t"\
+ "paddusw " #a ", " #sum " \n\t"
+
#define SBUTTERFLY(a,b,t,n)\
"movq " #a ", " #t " \n\t" /* abcd */\
"punpckl" #n " " #b ", " #a " \n\t" /* aebf */\
"punpckh" #n " " #b ", " #t " \n\t" /* cgdh */\
-
+
#define TRANSPOSE4(a,b,c,d,t)\
SBUTTERFLY(a,b,t,wd) /* a=aebf t=cgdh */\
SBUTTERFLY(c,d,b,wd) /* c=imjn b=kolp */\
@@ -750,7 +731,94 @@ static int hadamard8_diff_mmx(void *s, uint8_t *src1, uint8_t *src2, int stride)
return sum&0xFFFF;
}
+static int hadamard8_diff_mmx2(void *s, uint8_t *src1, uint8_t *src2, int stride){
+ uint64_t temp[16] __align8;
+ int sum=0;
+
+ diff_pixels_mmx((DCTELEM*)temp, src1, src2, stride);
+
+ asm volatile(
+ LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
+ LOAD4(64, %%mm4, %%mm5, %%mm6, %%mm7)
+
+ HADAMARD48
+
+ "movq %%mm7, 112(%1) \n\t"
+
+ TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
+ STORE4(0 , %%mm0, %%mm3, %%mm7, %%mm2)
+
+ "movq 112(%1), %%mm7 \n\t"
+ TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
+ STORE4(64, %%mm4, %%mm7, %%mm0, %%mm6)
+
+ LOAD4(8 , %%mm0, %%mm1, %%mm2, %%mm3)
+ LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
+
+ HADAMARD48
+
+ "movq %%mm7, 120(%1) \n\t"
+
+ TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
+ STORE4(8 , %%mm0, %%mm3, %%mm7, %%mm2)
+
+ "movq 120(%1), %%mm7 \n\t"
+ TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
+ "movq %%mm7, %%mm5 \n\t"//FIXME remove
+ "movq %%mm6, %%mm7 \n\t"
+ "movq %%mm0, %%mm6 \n\t"
+// STORE4(72, %%mm4, %%mm7, %%mm0, %%mm6) //FIXME remove
+
+ LOAD4(64, %%mm0, %%mm1, %%mm2, %%mm3)
+// LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
+
+ HADAMARD48
+ "movq %%mm7, 64(%1) \n\t"
+ MMABS_MMX2(%%mm0, %%mm7)
+ MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm2, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm3, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm4, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm5, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm6, %%mm7, %%mm0)
+ "movq 64(%1), %%mm1 \n\t"
+ MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
+ "movq %%mm0, 64(%1) \n\t"
+
+ LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
+ LOAD4(8 , %%mm4, %%mm5, %%mm6, %%mm7)
+
+ HADAMARD48
+ "movq %%mm7, (%1) \n\t"
+ MMABS_MMX2(%%mm0, %%mm7)
+ MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm2, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm3, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm4, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm5, %%mm7, %%mm0)
+ MMABS_SUM_MMX2(%%mm6, %%mm7, %%mm0)
+ "movq (%1), %%mm1 \n\t"
+ MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
+ "movq 64(%1), %%mm1 \n\t"
+ MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
+
+ "movq %%mm0, %%mm1 \n\t"
+ "psrlq $32, %%mm0 \n\t"
+ "paddusw %%mm1, %%mm0 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "psrlq $16, %%mm0 \n\t"
+ "paddusw %%mm1, %%mm0 \n\t"
+ "movd %%mm0, %0 \n\t"
+
+ : "=r" (sum)
+ : "r"(temp)
+ );
+ return sum&0xFFFF;
+}
+
+
WARPER88_1616(hadamard8_diff_mmx, hadamard8_diff16_mmx)
+WARPER88_1616(hadamard8_diff_mmx2, hadamard8_diff16_mmx2)
#define put_no_rnd_pixels8_mmx(a,b,c,d) put_pixels8_mmx(a,b,c,d)
#define put_no_rnd_pixels16_mmx(a,b,c,d) put_pixels16_mmx(a,b,c,d)
@@ -777,7 +845,7 @@ WARPER88_1616(hadamard8_diff_mmx, hadamard8_diff16_mmx)
OP(%%mm5, out, %%mm7, d)
#define QPEL_BASE(OPNAME, ROUNDER, RND, OP_MMX2, OP_3DNOW)\
-void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
+static void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
uint64_t temp;\
\
asm volatile(\
@@ -944,7 +1012,7 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, i
}\
}\
\
-void OPNAME ## mpeg4_qpel8_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
+static void OPNAME ## mpeg4_qpel8_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
uint64_t temp;\
\
asm volatile(\
@@ -1121,7 +1189,7 @@ static void OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src,
);\
}\
\
-void OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+static void OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
uint64_t temp[9*4];\
uint64_t *temp_ptr= temp;\
int count= 9;\
@@ -1181,46 +1249,46 @@ void OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dst
);\
}\
\
-static void OPNAME ## qpel8_mc00_ ## MMX (UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## pixels8_mmx(dst, src, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc10_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[8];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\
OPNAME ## pixels8_l2_mmx(dst, src, half, stride, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc20_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc30_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[8];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\
OPNAME ## pixels8_l2_mmx(dst, src+1, half, stride, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc01_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[8];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\
OPNAME ## pixels8_l2_mmx(dst, src, half, stride, stride, 8);\
}\
\
-static void OPNAME ## qpel8_mc02_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src, stride, stride);\
}\
\
-static void OPNAME ## qpel8_mc03_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[8];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\
OPNAME ## pixels8_l2_mmx(dst, src+stride, half, stride, stride, 8);\
}\
-static void OPNAME ## qpel8_mc11_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half) + 64;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1229,7 +1297,7 @@ static void OPNAME ## qpel8_mc11_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2_mmx(dst, halfH, halfHV, stride, 8, 8);\
}\
-static void OPNAME ## qpel8_mc31_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half) + 64;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1238,7 +1306,7 @@ static void OPNAME ## qpel8_mc31_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2_mmx(dst, halfH, halfHV, stride, 8, 8);\
}\
-static void OPNAME ## qpel8_mc13_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half) + 64;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1247,7 +1315,7 @@ static void OPNAME ## qpel8_mc13_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2_mmx(dst, halfH+8, halfHV, stride, 8, 8);\
}\
-static void OPNAME ## qpel8_mc33_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half) + 64;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1256,7 +1324,7 @@ static void OPNAME ## qpel8_mc33_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2_mmx(dst, halfH+8, halfHV, stride, 8, 8);\
}\
-static void OPNAME ## qpel8_mc21_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half) + 64;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1264,7 +1332,7 @@ static void OPNAME ## qpel8_mc21_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2_mmx(dst, halfH, halfHV, stride, 8, 8);\
}\
-static void OPNAME ## qpel8_mc23_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half) + 64;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1272,66 +1340,66 @@ static void OPNAME ## qpel8_mc23_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
OPNAME ## pixels8_l2_mmx(dst, halfH+8, halfHV, stride, 8, 8);\
}\
-static void OPNAME ## qpel8_mc12_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half);\
put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
put ## RND ## pixels8_l2_mmx(halfH, src, halfH, 8, stride, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
}\
-static void OPNAME ## qpel8_mc32_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[8 + 9];\
uint8_t * const halfH= ((uint8_t*)half);\
put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
put ## RND ## pixels8_l2_mmx(halfH, src+1, halfH, 8, stride, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
}\
-static void OPNAME ## qpel8_mc22_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[9];\
uint8_t * const halfH= ((uint8_t*)half);\
put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
}\
-static void OPNAME ## qpel16_mc00_ ## MMX (UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## pixels16_mmx(dst, src, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc10_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[32];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\
OPNAME ## pixels16_l2_mmx(dst, src, half, stride, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc20_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src, stride, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc30_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[32];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\
OPNAME ## pixels16_l2_mmx(dst, src+1, half, stride, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc01_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[32];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\
OPNAME ## pixels16_l2_mmx(dst, src, half, stride, stride, 16);\
}\
\
-static void OPNAME ## qpel16_mc02_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src, stride, stride);\
}\
\
-static void OPNAME ## qpel16_mc03_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t temp[32];\
uint8_t * const half= (uint8_t*)temp;\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\
OPNAME ## pixels16_l2_mmx(dst, src+stride, half, stride, stride, 16);\
}\
-static void OPNAME ## qpel16_mc11_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[16*2 + 17*2];\
uint8_t * const halfH= ((uint8_t*)half) + 256;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1340,7 +1408,7 @@ static void OPNAME ## qpel16_mc11_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2_mmx(dst, halfH, halfHV, stride, 16, 16);\
}\
-static void OPNAME ## qpel16_mc31_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[16*2 + 17*2];\
uint8_t * const halfH= ((uint8_t*)half) + 256;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1349,7 +1417,7 @@ static void OPNAME ## qpel16_mc31_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2_mmx(dst, halfH, halfHV, stride, 16, 16);\
}\
-static void OPNAME ## qpel16_mc13_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[16*2 + 17*2];\
uint8_t * const halfH= ((uint8_t*)half) + 256;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1358,7 +1426,7 @@ static void OPNAME ## qpel16_mc13_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2_mmx(dst, halfH+16, halfHV, stride, 16, 16);\
}\
-static void OPNAME ## qpel16_mc33_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[16*2 + 17*2];\
uint8_t * const halfH= ((uint8_t*)half) + 256;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1367,7 +1435,7 @@ static void OPNAME ## qpel16_mc33_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2_mmx(dst, halfH+16, halfHV, stride, 16, 16);\
}\
-static void OPNAME ## qpel16_mc21_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[16*2 + 17*2];\
uint8_t * const halfH= ((uint8_t*)half) + 256;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1375,7 +1443,7 @@ static void OPNAME ## qpel16_mc21_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2_mmx(dst, halfH, halfHV, stride, 16, 16);\
}\
-static void OPNAME ## qpel16_mc23_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[16*2 + 17*2];\
uint8_t * const halfH= ((uint8_t*)half) + 256;\
uint8_t * const halfHV= ((uint8_t*)half);\
@@ -1383,21 +1451,21 @@ static void OPNAME ## qpel16_mc23_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
OPNAME ## pixels16_l2_mmx(dst, halfH+16, halfHV, stride, 16, 16);\
}\
-static void OPNAME ## qpel16_mc12_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[17*2];\
uint8_t * const halfH= ((uint8_t*)half);\
put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
put ## RND ## pixels16_l2_mmx(halfH, src, halfH, 16, stride, 17);\
OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
}\
-static void OPNAME ## qpel16_mc32_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[17*2];\
uint8_t * const halfH= ((uint8_t*)half);\
put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
put ## RND ## pixels16_l2_mmx(halfH, src+1, halfH, 16, stride, 17);\
OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
}\
-static void OPNAME ## qpel16_mc22_ ## MMX(UINT8 *dst, UINT8 *src, int stride){\
+static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
uint64_t half[17*2];\
uint8_t * const halfH= ((uint8_t*)half);\
put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
@@ -1433,10 +1501,45 @@ static void just_return() { return; }
c->put_ ## postfix1 = put_ ## postfix2;\
c->put_no_rnd_ ## postfix1 = put_no_rnd_ ## postfix2;\
c->avg_ ## postfix1 = avg_ ## postfix2;
+
+/* external functions, from idct_mmx.c */
+void ff_mmx_idct(DCTELEM *block);
+void ff_mmxext_idct(DCTELEM *block);
+
+/* XXX: those functions should be suppressed ASAP when all IDCTs are
+ converted */
+static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_mmx_idct (block);
+ put_pixels_clamped_mmx(block, dest, line_size);
+}
+static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_mmx_idct (block);
+ add_pixels_clamped_mmx(block, dest, line_size);
+}
+static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_mmxext_idct (block);
+ put_pixels_clamped_mmx(block, dest, line_size);
+}
+static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_mmxext_idct (block);
+ add_pixels_clamped_mmx(block, dest, line_size);
+}
-void dsputil_init_mmx(DSPContext* c, unsigned mask)
+void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
mm_flags = mm_support();
+
+ if (avctx->dsp_mask) {
+ if (avctx->dsp_mask & FF_MM_FORCE)
+ mm_flags |= (avctx->dsp_mask & 0xffff);
+ else
+ mm_flags &= ~(avctx->dsp_mask & 0xffff);
+ }
+
#if 0
fprintf(stderr, "libavcodec: CPU flags:");
if (mm_flags & MM_MMX)
@@ -1453,6 +1556,27 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
#endif
if (mm_flags & MM_MMX) {
+ const int dct_algo = avctx->dct_algo;
+ const int idct_algo= avctx->idct_algo;
+
+ if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)
+ c->fdct = ff_fdct_mmx;
+
+ if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
+ c->idct_put= ff_simple_idct_put_mmx;
+ c->idct_add= ff_simple_idct_add_mmx;
+ c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
+ }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
+ if(mm_flags & MM_MMXEXT){
+ c->idct_put= ff_libmpeg2mmx2_idct_put;
+ c->idct_add= ff_libmpeg2mmx2_idct_add;
+ }else{
+ c->idct_put= ff_libmpeg2mmx_idct_put;
+ c->idct_add= ff_libmpeg2mmx_idct_add;
+ }
+ c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
+ }
+
c->get_pixels = get_pixels_mmx;
c->diff_pixels = diff_pixels_mmx;
c->put_pixels_clamped = put_pixels_clamped_mmx;
@@ -1460,15 +1584,6 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
c->clear_blocks = clear_blocks_mmx;
c->pix_sum = pix_sum16_mmx;
- c->pix_abs16x16 = pix_abs16x16_mmx;
- c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx;
- c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx;
- c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx;
- c->pix_abs8x8 = pix_abs8x8_mmx;
- c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx;
- c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx;
- c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx;
-
c->put_pixels_tab[0][0] = put_pixels16_mmx;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx;
c->put_pixels_tab[0][2] = put_pixels16_y2_mmx;
@@ -1515,45 +1630,35 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
c->hadamard8_diff[0]= hadamard8_diff16_mmx;
c->hadamard8_diff[1]= hadamard8_diff_mmx;
- c->sad[0]= sad16x16_mmx;
- c->sad[1]= sad8x8_mmx;
-
c->pix_norm1 = pix_norm1_mmx;
c->sse[0] = sse16_mmx;
if (mm_flags & MM_MMXEXT) {
- c->pix_abs16x16 = pix_abs16x16_mmx2;
- c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx2;
- c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx2;
- c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx2;
-
- c->pix_abs8x8 = pix_abs8x8_mmx2;
- c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx2;
- c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx2;
- c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx2;
-
- c->sad[0]= sad16x16_mmx2;
- c->sad[1]= sad8x8_mmx2;
-
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
- c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
- c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
c->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
- c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
- c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
- c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
c->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
- c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
+
+ c->hadamard8_diff[0]= hadamard8_diff16_mmx2;
+ c->hadamard8_diff[1]= hadamard8_diff_mmx2;
+
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
+ c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
+ c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
+ c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
+ c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
+ c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
+ }
#if 1
SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_mmx2)
@@ -1592,23 +1697,26 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
} else if (mm_flags & MM_3DNOW) {
c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
- c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
- c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
c->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
- c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
- c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
- c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
c->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
- c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
+
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
+ c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
+ c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
+ c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
+ c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
+ c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
+ }
SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_3dnow)
@@ -1644,7 +1752,8 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_3dnow)
}
}
-
+
+ dsputil_init_pix_mmx(c, avctx);
#if 0
// for speed testing
get_pixels = just_return;
@@ -1680,28 +1789,3 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
//ff_idct = just_return;
#endif
}
-
-/* remove any non bit exact operation (testing purpose). NOTE that
- this function should be kept as small as possible because it is
- always difficult to test automatically non bit exact cases. */
-void dsputil_set_bit_exact_mmx(DSPContext* c, unsigned mask)
-{
- if (mm_flags & MM_MMX) {
- /* MMX2 & 3DNOW */
- c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx;
- c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx;
- c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx;
- c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx;
- c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx;
- c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx;
-
- if (mm_flags & MM_MMXEXT) {
- c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx;
- c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx;
- c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx;
- c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx;
- c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx;
- c->pix_abs8x8_xy2= pix_abs8x8_xy2_mmx;
- }
- }
-}
diff --git a/src/libffmpeg/libavcodec/i386/dsputil_mmx_avg.h b/src/libffmpeg/libavcodec/i386/dsputil_mmx_avg.h
index 4a8841156..8418123ac 100644
--- a/src/libffmpeg/libavcodec/i386/dsputil_mmx_avg.h
+++ b/src/libffmpeg/libavcodec/i386/dsputil_mmx_avg.h
@@ -25,7 +25,7 @@
/* XXX: we use explicit registers to avoid a gcc 2.95.2 register asm
clobber bug - now it will work with 2.95.2 and also with -fPIC
*/
-static void DEF(put_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -85,7 +85,7 @@ static void DEF(put_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int
:"memory");
}
-static void DEF(put_pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -154,7 +154,7 @@ static void DEF(put_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int
}
/* GL: this function does incorrect rounding if overflow */
-static void DEF(put_no_rnd_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put_no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BONE(mm6);
__asm __volatile(
@@ -191,7 +191,7 @@ static void DEF(put_no_rnd_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int li
:"%eax", "memory");
}
-static void DEF(put_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -222,7 +222,7 @@ static void DEF(put_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size
}
/* GL: this function does incorrect rounding if overflow */
-static void DEF(put_no_rnd_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put_no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BONE(mm6);
__asm __volatile(
@@ -255,7 +255,7 @@ static void DEF(put_no_rnd_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int li
:"%eax", "memory");
}
-static void DEF(avg_pixels8)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -283,7 +283,7 @@ static void DEF(avg_pixels8)(UINT8 *block, const UINT8 *pixels, int line_size, i
:"%eax", "memory");
}
-static void DEF(avg_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -315,7 +315,7 @@ static void DEF(avg_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size
:"%eax", "memory");
}
-static void DEF(avg_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@@ -354,7 +354,7 @@ static void DEF(avg_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size
}
// Note this is not correctly rounded, but this function is only used for b frames so it doesnt matter
-static void DEF(avg_pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BONE(mm6);
__asm __volatile(
@@ -396,31 +396,31 @@ static void DEF(avg_pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_siz
}
//FIXME the following could be optimized too ...
-static void DEF(put_no_rnd_pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(put_no_rnd_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(put_no_rnd_pixels8_x2)(block , pixels , line_size, h);
DEF(put_no_rnd_pixels8_x2)(block+8, pixels+8, line_size, h);
}
-static void DEF(put_pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(put_pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(put_pixels8_y2)(block , pixels , line_size, h);
DEF(put_pixels8_y2)(block+8, pixels+8, line_size, h);
}
-static void DEF(put_no_rnd_pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(put_no_rnd_pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(put_no_rnd_pixels8_y2)(block , pixels , line_size, h);
DEF(put_no_rnd_pixels8_y2)(block+8, pixels+8, line_size, h);
}
-static void DEF(avg_pixels16)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(avg_pixels16)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(avg_pixels8)(block , pixels , line_size, h);
DEF(avg_pixels8)(block+8, pixels+8, line_size, h);
}
-static void DEF(avg_pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(avg_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(avg_pixels8_x2)(block , pixels , line_size, h);
DEF(avg_pixels8_x2)(block+8, pixels+8, line_size, h);
}
-static void DEF(avg_pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(avg_pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(avg_pixels8_y2)(block , pixels , line_size, h);
DEF(avg_pixels8_y2)(block+8, pixels+8, line_size, h);
}
-static void DEF(avg_pixels16_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(avg_pixels16_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(avg_pixels8_xy2)(block , pixels , line_size, h);
DEF(avg_pixels8_xy2)(block+8, pixels+8, line_size, h);
}
diff --git a/src/libffmpeg/libavcodec/i386/dsputil_mmx_rnd.h b/src/libffmpeg/libavcodec/i386/dsputil_mmx_rnd.h
index 956edf798..bbd5aec97 100644
--- a/src/libffmpeg/libavcodec/i386/dsputil_mmx_rnd.h
+++ b/src/libffmpeg/libavcodec/i386/dsputil_mmx_rnd.h
@@ -22,7 +22,7 @@
*/
// put_pixels
-static void DEF(put, pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@@ -104,7 +104,7 @@ static void DEF(put, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int
:"memory");
}
-static void DEF(put, pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@@ -199,7 +199,7 @@ static void DEF(put, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, in
:"memory");
}
-static void DEF(put, pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@@ -228,7 +228,7 @@ static void DEF(put, pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_siz
:"eax", "memory");
}
-static void DEF(put, pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
@@ -296,7 +296,7 @@ static void DEF(put, pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_si
// avg_pixels
// in case more speed is needed - unroling would certainly help
-static void DEF(avg, pixels8)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg, pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
@@ -315,7 +315,7 @@ static void DEF(avg, pixels8)(UINT8 *block, const UINT8 *pixels, int line_size,
while (--h);
}
-static void DEF(avg, pixels16)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg, pixels16)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
@@ -338,7 +338,7 @@ static void DEF(avg, pixels16)(UINT8 *block, const UINT8 *pixels, int line_size,
while (--h);
}
-static void DEF(avg, pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
@@ -379,7 +379,7 @@ static void DEF(avg, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int
} while (--h);
}
-static void DEF(avg, pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
@@ -432,7 +432,7 @@ static void DEF(avg, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, in
} while (--h);
}
-static void DEF(avg, pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@@ -472,7 +472,7 @@ static void DEF(avg, pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_siz
}
// this routine is 'slightly' suboptimal but mostly unused
-static void DEF(avg, pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
+static void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
@@ -547,22 +547,22 @@ static void DEF(avg, pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_si
}
//FIXME optimize
-static void DEF(put, pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(put, pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(put, pixels8_y2)(block , pixels , line_size, h);
DEF(put, pixels8_y2)(block+8, pixels+8, line_size, h);
}
-static void DEF(put, pixels16_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(put, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(put, pixels8_xy2)(block , pixels , line_size, h);
DEF(put, pixels8_xy2)(block+8, pixels+8, line_size, h);
}
-static void DEF(avg, pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(avg, pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(avg, pixels8_y2)(block , pixels , line_size, h);
DEF(avg, pixels8_y2)(block+8, pixels+8, line_size, h);
}
-static void DEF(avg, pixels16_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
+static void DEF(avg, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
DEF(avg, pixels8_xy2)(block , pixels , line_size, h);
DEF(avg, pixels8_xy2)(block+8, pixels+8, line_size, h);
}
diff --git a/src/libffmpeg/libavcodec/i386/motion_est_mmx.c b/src/libffmpeg/libavcodec/i386/motion_est_mmx.c
index fa85db67b..5c4b32dcd 100644
--- a/src/libffmpeg/libavcodec/i386/motion_est_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/motion_est_mmx.c
@@ -20,7 +20,7 @@
*/
#include "../dsputil.h"
-static const __attribute__ ((aligned(8))) UINT64 round_tab[3]={
+static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={
0x0000000000000000,
0x0001000100010001,
0x0002000200020002,
@@ -28,7 +28,7 @@ static const __attribute__ ((aligned(8))) UINT64 round_tab[3]={
static __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
-static inline void sad8_mmx(UINT8 *blk1, UINT8 *blk2, int stride, int h)
+static inline void sad8_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
int len= -(stride<<h);
asm volatile(
@@ -64,7 +64,7 @@ static inline void sad8_mmx(UINT8 *blk1, UINT8 *blk2, int stride, int h)
);
}
-static inline void sad8_mmx2(UINT8 *blk1, UINT8 *blk2, int stride, int h)
+static inline void sad8_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
int len= -(stride<<h);
asm volatile(
@@ -86,7 +86,7 @@ static inline void sad8_mmx2(UINT8 *blk1, UINT8 *blk2, int stride, int h)
);
}
-static inline void sad8_2_mmx2(UINT8 *blk1a, UINT8 *blk1b, UINT8 *blk2, int stride, int h)
+static inline void sad8_2_mmx2(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
{
int len= -(stride<<h);
asm volatile(
@@ -112,13 +112,13 @@ static inline void sad8_2_mmx2(UINT8 *blk1a, UINT8 *blk1b, UINT8 *blk2, int stri
);
}
-static inline void sad8_4_mmx2(UINT8 *blk1, UINT8 *blk2, int stride, int h)
+static inline void sad8_4_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{ //FIXME reuse src
int len= -(stride<<h);
asm volatile(
".balign 16 \n\t"
"movq "MANGLE(bone)", %%mm5 \n\t"
- "1: \n\t"
+ "1: \n\t"
"movq (%1, %%eax), %%mm0 \n\t"
"movq (%2, %%eax), %%mm2 \n\t"
"movq 1(%1, %%eax), %%mm1 \n\t"
@@ -149,7 +149,7 @@ static inline void sad8_4_mmx2(UINT8 *blk1, UINT8 *blk2, int stride, int h)
);
}
-static inline void sad8_2_mmx(UINT8 *blk1a, UINT8 *blk1b, UINT8 *blk2, int stride, int h)
+static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
{
int len= -(stride<<h);
asm volatile(
@@ -165,7 +165,7 @@ static inline void sad8_2_mmx(UINT8 *blk1a, UINT8 *blk1b, UINT8 *blk2, int strid
"punpckhbw %%mm7, %%mm3 \n\t"
"paddw %%mm0, %%mm1 \n\t"
"paddw %%mm2, %%mm3 \n\t"
- "movq (%3, %%eax), %%mm4 \n\t"
+ "movq (%3, %%eax), %%mm4 \n\t"
"movq (%3, %%eax), %%mm2 \n\t"
"paddw %%mm5, %%mm1 \n\t"
"paddw %%mm5, %%mm3 \n\t"
@@ -187,7 +187,7 @@ static inline void sad8_2_mmx(UINT8 *blk1a, UINT8 *blk1b, UINT8 *blk2, int strid
);
}
-static inline void sad8_4_mmx(UINT8 *blk1, UINT8 *blk2, int stride, int h)
+static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
int len= -(stride<<h);
asm volatile(
@@ -215,8 +215,8 @@ static inline void sad8_4_mmx(UINT8 *blk1, UINT8 *blk2, int stride, int h)
"punpckhbw %%mm7, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm1 \n\t"
- "movq (%3, %%eax), %%mm3 \n\t"
- "movq (%3, %%eax), %%mm4 \n\t"
+ "movq (%3, %%eax), %%mm3 \n\t"
+ "movq (%3, %%eax), %%mm4 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"paddw %%mm5, %%mm1 \n\t"
"psrlw $2, %%mm2 \n\t"
@@ -237,7 +237,7 @@ static inline void sad8_4_mmx(UINT8 *blk1, UINT8 *blk2, int stride, int h)
);
}
-static inline int sum_mmx()
+static inline int sum_mmx(void)
{
int ret;
asm volatile(
@@ -253,7 +253,7 @@ static inline int sum_mmx()
return ret&0xFFFF;
}
-static inline int sum_mmx2()
+static inline int sum_mmx2(void)
{
int ret;
asm volatile(
@@ -265,7 +265,7 @@ static inline int sum_mmx2()
#define PIX_SAD(suf)\
-int pix_abs8x8_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs8x8_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t":);\
@@ -274,7 +274,7 @@ int pix_abs8x8_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
\
return sum_ ## suf();\
}\
-int sad8x8_ ## suf(void *s, UINT8 *blk2, UINT8 *blk1, int stride)\
+static int sad8x8_ ## suf(void *s, uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t":);\
@@ -284,7 +284,7 @@ int sad8x8_ ## suf(void *s, UINT8 *blk2, UINT8 *blk1, int stride)\
return sum_ ## suf();\
}\
\
-int pix_abs8x8_x2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs8x8_x2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
@@ -297,7 +297,7 @@ int pix_abs8x8_x2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
return sum_ ## suf();\
}\
\
-int pix_abs8x8_y2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs8x8_y2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
@@ -310,7 +310,7 @@ int pix_abs8x8_y2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
return sum_ ## suf();\
}\
\
-int pix_abs8x8_xy2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs8x8_xy2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
@@ -323,7 +323,7 @@ int pix_abs8x8_xy2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
return sum_ ## suf();\
}\
\
-int pix_abs16x16_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs16x16_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t":);\
@@ -333,7 +333,7 @@ int pix_abs16x16_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
\
return sum_ ## suf();\
}\
-int sad16x16_ ## suf(void *s, UINT8 *blk2, UINT8 *blk1, int stride)\
+static int sad16x16_ ## suf(void *s, uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t":);\
@@ -343,7 +343,7 @@ int sad16x16_ ## suf(void *s, UINT8 *blk2, UINT8 *blk1, int stride)\
\
return sum_ ## suf();\
}\
-int pix_abs16x16_x2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs16x16_x2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
@@ -356,7 +356,7 @@ int pix_abs16x16_x2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
\
return sum_ ## suf();\
}\
-int pix_abs16x16_y2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs16x16_y2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
@@ -369,7 +369,7 @@ int pix_abs16x16_y2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
\
return sum_ ## suf();\
}\
-int pix_abs16x16_xy2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
+static int pix_abs16x16_xy2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\
{\
asm volatile("pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
@@ -385,3 +385,36 @@ int pix_abs16x16_xy2_ ## suf(UINT8 *blk2, UINT8 *blk1, int stride)\
PIX_SAD(mmx)
PIX_SAD(mmx2)
+
+void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
+{
+ if (mm_flags & MM_MMX) {
+ c->pix_abs16x16 = pix_abs16x16_mmx;
+ c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx;
+ c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx;
+ c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx;
+ c->pix_abs8x8 = pix_abs8x8_mmx;
+ c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx;
+ c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx;
+ c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx;
+
+ c->sad[0]= sad16x16_mmx;
+ c->sad[1]= sad8x8_mmx;
+ }
+ if (mm_flags & MM_MMXEXT) {
+ c->pix_abs16x16 = pix_abs16x16_mmx2;
+ c->pix_abs8x8 = pix_abs8x8_mmx2;
+
+ c->sad[0]= sad16x16_mmx2;
+ c->sad[1]= sad8x8_mmx2;
+
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx2;
+ c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx2;
+ c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx2;
+ c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx2;
+ c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx2;
+ c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx2;
+ }
+ }
+}
diff --git a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c
index be8015dd3..8e452b499 100644
--- a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c
@@ -23,12 +23,10 @@
#include "../dsputil.h"
#include "../mpegvideo.h"
#include "../avcodec.h"
-#include "../simple_idct.h"
-#include "xineutils.h"
-extern UINT8 zigzag_direct_noperm[64];
-extern UINT16 inv_zigzag_direct16[64];
-extern UINT32 inverse[256];
+extern uint8_t zigzag_direct_noperm[64];
+extern uint16_t inv_zigzag_direct16[64];
+extern uint32_t inverse[256];
static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL;
static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
@@ -42,9 +40,7 @@ static void dct_unquantize_h263_mmx(MpegEncContext *s,
qmul = qscale << 1;
qadd = (qscale - 1) | 1;
- XINE_ASSERT(s->block_last_index[n]>=0,
- "value 's->block_last_index[%d] is < 0: %d",
- n, s->block_last_index[n]);
+ assert(s->block_last_index[n]>=0);
if (s->mb_intra) {
if (!s->h263_aic) {
@@ -147,11 +143,9 @@ static void dct_unquantize_mpeg1_mmx(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int nCoeffs;
- const UINT16 *quant_matrix;
+ const uint16_t *quant_matrix;
- XINE_ASSERT(s->block_last_index[n]>=0,
- "value 's->block_last_index[%d] is < 0: %d",
- n, s->block_last_index[n]);
+ assert(s->block_last_index[n]>=0);
nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
@@ -277,11 +271,9 @@ static void dct_unquantize_mpeg2_mmx(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int nCoeffs;
- const UINT16 *quant_matrix;
+ const uint16_t *quant_matrix;
- XINE_ASSERT(s->block_last_index[n]>=0,
- "value 's->block_last_index[%d] is < 0: %d",
- n, s->block_last_index[n]);
+ assert(s->block_last_index[n]>=0);
if(s->alternate_scan) nCoeffs= 63; //FIXME
else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
@@ -411,9 +403,9 @@ asm volatile(
/* draw the edges of width 'w' of an image of size width, height
this mmx version can only handle w==8 || w==16 */
-static void draw_edges_mmx(UINT8 *buf, int wrap, int width, int height, int w)
+static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w)
{
- UINT8 *ptr, *last_line;
+ uint8_t *ptr, *last_line;
int i;
last_line = buf + (height - 1) * wrap;
@@ -506,38 +498,10 @@ static void draw_edges_mmx(UINT8 *buf, int wrap, int width, int height, int w)
#define RENAME(a) a ## _MMX2
#include "mpegvideo_mmx_template.c"
-/* external functions, from idct_mmx.c */
-void ff_mmx_idct(DCTELEM *block);
-void ff_mmxext_idct(DCTELEM *block);
-
-/* XXX: those functions should be suppressed ASAP when all IDCTs are
- converted */
-static void ff_libmpeg2mmx_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
-{
- ff_mmx_idct (block);
- put_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_libmpeg2mmx_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
-{
- ff_mmx_idct (block);
- add_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_libmpeg2mmx2_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
-{
- ff_mmxext_idct (block);
- put_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_libmpeg2mmx2_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
-{
- ff_mmxext_idct (block);
- add_pixels_clamped_mmx(block, dest, line_size);
-}
-
void MPV_common_init_mmx(MpegEncContext *s)
{
if (mm_flags & MM_MMX) {
const int dct_algo = s->avctx->dct_algo;
- const int idct_algo= s->avctx->idct_algo;
s->dct_unquantize_h263 = dct_unquantize_h263_mmx;
s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_mmx;
@@ -546,28 +510,11 @@ void MPV_common_init_mmx(MpegEncContext *s)
draw_edges = draw_edges_mmx;
if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
- s->fdct = ff_fdct_mmx;
-
if(mm_flags & MM_MMXEXT){
s->dct_quantize= dct_quantize_MMX2;
} else {
s->dct_quantize= dct_quantize_MMX;
}
}
-
- if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
- s->idct_put= ff_simple_idct_put_mmx;
- s->idct_add= ff_simple_idct_add_mmx;
- s->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
- }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
- if(mm_flags & MM_MMXEXT){
- s->idct_put= ff_libmpeg2mmx2_idct_put;
- s->idct_add= ff_libmpeg2mmx2_idct_add;
- }else{
- s->idct_put= ff_libmpeg2mmx_idct_put;
- s->idct_add= ff_libmpeg2mmx_idct_add;
- }
- s->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
- }
}
}
diff --git a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c
index ead30ed31..8cd91024b 100644
--- a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c
+++ b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c
@@ -37,8 +37,8 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
int qscale, int *overflow)
{
int level=0, last_non_zero_p1, q; //=0 is cuz gcc says uninitalized ...
- const UINT16 *qmat, *bias;
- static __align8 INT16 temp_block[64];
+ const uint16_t *qmat, *bias;
+ static __align8 int16_t temp_block[64];
//s->fdct (block);
ff_fdct_mmx (block); //cant be anything else ...
@@ -207,7 +207,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
if(s->mb_intra) block[0]= level;
else block[0]= temp_block[0];
- if(s->idct_permutation[1]==8){
+ if(s->dsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM){
if(last_non_zero_p1 <= 1) goto end;
block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];
block[0x20] = temp_block[0x10];
@@ -251,7 +251,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36];
block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37];
block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
- }else if(s->idct_permutation[1]==4){
+ }else if(s->dsp.idct_permutation_type == FF_LIBMPEG2_IDCT_PERM){
if(last_non_zero_p1 <= 1) goto end;
block[0x04] = temp_block[0x01];
block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10];
diff --git a/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c b/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c
index 9dfd5f149..836403ca5 100644
--- a/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c
@@ -1298,12 +1298,12 @@ void ff_simple_idct_mmx(int16_t *block)
//FIXME merge add/put into the idct
-void ff_simple_idct_put_mmx(UINT8 *dest, int line_size, DCTELEM *block)
+void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block)
{
idct(block);
put_pixels_clamped_mmx(block, dest, line_size);
}
-void ff_simple_idct_add_mmx(UINT8 *dest, int line_size, DCTELEM *block)
+void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block)
{
idct(block);
add_pixels_clamped_mmx(block, dest, line_size);
diff --git a/src/libffmpeg/libavcodec/imgconvert.c b/src/libffmpeg/libavcodec/imgconvert.c
index cace55a94..cfb21a477 100644
--- a/src/libffmpeg/libavcodec/imgconvert.c
+++ b/src/libffmpeg/libavcodec/imgconvert.c
@@ -1,4 +1,3 @@
-
/*
* Misc image convertion routines
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
@@ -17,6 +16,13 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file imgconvert.c
+ * Misc image convertion routines.
+ */
+
+
#include "avcodec.h"
#include "dsputil.h"
@@ -30,59 +36,90 @@
typedef struct PixFmtInfo {
const char *name;
- UINT8 nb_components; /* number of components in AVPicture array */
- UINT8 is_yuv : 1; /* true if YUV instead of RGB color space */
- UINT8 is_packed : 1; /* true if multiple components in same word */
- UINT8 is_paletted : 1; /* true if paletted */
- UINT8 is_alpha : 1; /* true if alpha can be specified */
- UINT8 is_gray : 1; /* true if gray or monochrome format */
- UINT8 x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */
- UINT8 y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */
+ uint8_t nb_components; /* number of components in AVPicture array */
+ uint8_t is_yuv : 1; /* true if YUV instead of RGB color space */
+ uint8_t is_packed : 1; /* true if multiple components in same word */
+ uint8_t is_paletted : 1; /* true if paletted */
+ uint8_t is_alpha : 1; /* true if alpha can be specified */
+ uint8_t is_gray : 1; /* true if gray or monochrome format */
+ uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */
+ uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */
} PixFmtInfo;
/* this table gives more information about formats */
static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
- { /*PIX_FMT_YUV420P*/
- "yuv420p", 3, 1, 0, 0, 0, 0, 1, 1,
+ /* YUV formats */
+ [PIX_FMT_YUV420P] = {
+ .name = "yuv420p",
+ .nb_components = 3, .is_yuv = 1,
+ .x_chroma_shift = 1, .y_chroma_shift = 1,
},
- { /*PIX_FMT_YUV422*/
- "yuv422", 1, 1, 1, 0, 0, 0, 1, 0,
+ [PIX_FMT_YUV422P] = {
+ .name = "yuv422p",
+ .nb_components = 3, .is_yuv = 1,
+ .x_chroma_shift = 1, .y_chroma_shift = 0,
},
- { /*PIX_FMT_RGB24*/
- "rgb24", 1, 0, 1, 0, 0, 0, 0, 0,
+ [PIX_FMT_YUV444P] = {
+ .name = "yuv444p",
+ .nb_components = 3, .is_yuv = 1,
+ .x_chroma_shift = 0, .y_chroma_shift = 0,
},
- { /*PIX_FMT_BGR24*/
- "bgr24", 1, 0, 1, 0, 0, 0, 0, 0,
+ [PIX_FMT_YUV422] = {
+ .name = "yuv422",
+ .nb_components = 1, .is_yuv = 1, .is_packed = 1,
+ .x_chroma_shift = 1, .y_chroma_shift = 0,
},
- { /*PIX_FMT_YUV422P*/
- "yuv422p", 3, 1, 0, 0, 0, 0, 1, 0,
+ [PIX_FMT_YUV410P] = {
+ .name = "yuv410p",
+ .nb_components = 3, .is_yuv = 1,
+ .x_chroma_shift = 2, .y_chroma_shift = 2,
},
- { /*PIX_FMT_YUV444P*/
- "yuv444p", 3, 1, 0, 0, 0, 0, 0, 0,
+ [PIX_FMT_YUV411P] = {
+ .name = "yuv411p",
+ .nb_components = 3, .is_yuv = 1,
+ .x_chroma_shift = 2, .y_chroma_shift = 0,
},
- { /*PIX_FMT_RGBA32*/
- "rgba32", 1, 0, 1, 0, 1, 0, 0, 0,
+
+ /* RGB formats */
+ [PIX_FMT_RGB24] = {
+ .name = "rgb24",
+ .nb_components = 1, .is_packed = 1,
},
- { /*PIX_FMT_YUV410P*/
- "yuv410p", 3, 1, 0, 0, 0, 0, 2, 2,
+ [PIX_FMT_BGR24] = {
+ .name = "bgr24",
+ .nb_components = 1, .is_packed = 1,
},
- { /*PIX_FMT_YUV411P*/
- "yuv411p", 3, 1, 0, 0, 0, 0, 2, 0,
+ [PIX_FMT_RGBA32] = {
+ .name = "rgba32",
+ .nb_components = 1, .is_packed = 1, .is_alpha = 1,
},
- { /*PIX_FMT_RGB565*/
- "rgb565", 1, 0, 1, 0, 0, 0, 0, 0,
+ [PIX_FMT_RGB565] = {
+ .name = "rgb565",
+ .nb_components = 1, .is_packed = 1,
},
- { /*PIX_FMT_RGB555*/
- "rgb555", 1, 0, 1, 0, 1, 0, 0, 0,
+ [PIX_FMT_RGB555] = {
+ .name = "rgb555",
+ .nb_components = 1, .is_packed = 1, .is_alpha = 1,
},
- { /*PIX_FMT_GRAY8*/
- "gray", 1, 0, 0, 0, 0, 1, 0, 0,
+
+ /* gray / mono formats */
+ [PIX_FMT_GRAY8] = {
+ .name = "gray",
+ .nb_components = 1, .is_gray = 1,
},
- { /*PIX_FMT_MONOWHITE*/
- "monow", 1, 0, 1, 0, 0, 1, 0, 0,
+ [PIX_FMT_MONOWHITE] = {
+ .name = "monow",
+ .nb_components = 1, .is_packed = 1, .is_gray = 1,
},
- { /*PIX_FMT_MONOBLACK*/
- "monob", 1, 0, 1, 0, 0, 1, 0, 0,
+ [PIX_FMT_MONOBLACK] = {
+ .name = "monob",
+ .nb_components = 1, .is_packed = 1, .is_gray = 1,
+ },
+
+ /* paletted formats */
+ [PIX_FMT_PAL8] = {
+ .name = "pal8",
+ .nb_components = 1, .is_packed = 1, .is_paletted = 1,
},
};
@@ -106,21 +143,30 @@ const char *avcodec_get_pix_fmt_name(int pix_fmt)
}
/* Picture field are filled with 'ptr' addresses. Also return size */
-int avpicture_fill(AVPicture *picture, UINT8 *ptr,
+int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height)
{
- int size;
-
+ int size, w2, h2, size2;
+ PixFmtInfo *pinfo;
+
+ pinfo = &pix_fmt_info[pix_fmt];
size = width * height;
switch(pix_fmt) {
case PIX_FMT_YUV420P:
+ case PIX_FMT_YUV422P:
+ case PIX_FMT_YUV444P:
+ case PIX_FMT_YUV410P:
+ case PIX_FMT_YUV411P:
+ w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
+ h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
+ size2 = w2 * h2;
picture->data[0] = ptr;
picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size / 4;
+ picture->data[2] = picture->data[1] + size2;
picture->linesize[0] = width;
- picture->linesize[1] = width / 2;
- picture->linesize[2] = width / 2;
- return (size * 3) / 2;
+ picture->linesize[1] = w2;
+ picture->linesize[2] = w2;
+ return size + 2 * size2;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
picture->data[0] = ptr;
@@ -128,44 +174,12 @@ int avpicture_fill(AVPicture *picture, UINT8 *ptr,
picture->data[2] = NULL;
picture->linesize[0] = width * 3;
return size * 3;
- case PIX_FMT_YUV422P:
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size / 2;
- picture->linesize[0] = width;
- picture->linesize[1] = width / 2;
- picture->linesize[2] = width / 2;
- return (size * 2);
- case PIX_FMT_YUV444P:
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size;
- picture->linesize[0] = width;
- picture->linesize[1] = width;
- picture->linesize[2] = width;
- return size * 3;
case PIX_FMT_RGBA32:
picture->data[0] = ptr;
picture->data[1] = NULL;
picture->data[2] = NULL;
picture->linesize[0] = width * 4;
return size * 4;
- case PIX_FMT_YUV410P:
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size / 16;
- picture->linesize[0] = width;
- picture->linesize[1] = width / 4;
- picture->linesize[2] = width / 4;
- return size + (size / 8);
- case PIX_FMT_YUV411P:
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size / 4;
- picture->linesize[0] = width;
- picture->linesize[1] = width / 4;
- picture->linesize[2] = width / 4;
- return size + (size / 2);
case PIX_FMT_RGB555:
case PIX_FMT_RGB565:
case PIX_FMT_YUV422:
@@ -187,10 +201,19 @@ int avpicture_fill(AVPicture *picture, UINT8 *ptr,
picture->data[2] = NULL;
picture->linesize[0] = (width + 7) >> 3;
return picture->linesize[0] * height;
+ case PIX_FMT_PAL8:
+ size2 = (size + 3) & ~3;
+ picture->data[0] = ptr;
+ picture->data[1] = ptr + size2; /* palette is stored here as 256 32 bit words */
+ picture->data[2] = NULL;
+ picture->linesize[0] = width;
+ picture->linesize[1] = 4;
+ return size2 + 256 * 4;
default:
picture->data[0] = NULL;
picture->data[1] = NULL;
picture->data[2] = NULL;
+ picture->data[3] = NULL;
return -1;
}
}
@@ -207,9 +230,9 @@ int avpicture_get_size(int pix_fmt, int width, int height)
static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
int width, int height)
{
- UINT8 *lum, *cb, *cr;
+ uint8_t *lum, *cb, *cr;
int x, y;
- const UINT8 *p;
+ const uint8_t *p;
lum = dst->data[0];
cb = dst->data[1];
@@ -242,12 +265,12 @@ static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
/* XXX: use generic filter ? */
/* 1x2 -> 1x1 */
-static void shrink2(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+static void shrink2(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height)
{
int w;
- UINT8 *s1, *s2, *d;
+ uint8_t *s1, *s2, *d;
for(;height > 0; height--) {
s1 = src;
@@ -274,12 +297,12 @@ static void shrink2(UINT8 *dst, int dst_wrap,
}
/* 2x2 -> 1x1 */
-static void shrink22(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+static void shrink22(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height)
{
int w;
- UINT8 *s1, *s2, *d;
+ uint8_t *s1, *s2, *d;
for(;height > 0; height--) {
s1 = src;
@@ -306,12 +329,12 @@ static void shrink22(UINT8 *dst, int dst_wrap,
}
/* 1x1 -> 2x2 */
-static void grow22(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+static void grow22(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height)
{
int w;
- UINT8 *s1, *d;
+ uint8_t *s1, *d;
for(;height > 0; height--) {
s1 = src;
@@ -334,12 +357,12 @@ static void grow22(UINT8 *dst, int dst_wrap,
}
/* 1x2 -> 2x1 */
-static void conv411(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+static void conv411(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height)
{
int w, c;
- UINT8 *s1, *s2, *d;
+ uint8_t *s1, *s2, *d;
for(;height > 0; height--) {
s1 = src;
@@ -358,8 +381,8 @@ static void conv411(UINT8 *dst, int dst_wrap,
}
}
-static void img_copy(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+static void img_copy(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height)
{
for(;height > 0; height--) {
@@ -391,21 +414,21 @@ static void img_copy(UINT8 *dst, int dst_wrap,
static void yuv420p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
int width, int height) \
{ \
- UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; \
+ uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; \
int w, y, cb, cr, r_add, g_add, b_add, width2; \
- UINT8 *cm = cropTbl + MAX_NEG_CROP; \
+ uint8_t *cm = cropTbl + MAX_NEG_CROP; \
unsigned int r, g, b; \
\
d = dst->data[0]; \
y1_ptr = src->data[0]; \
cb_ptr = src->data[1]; \
cr_ptr = src->data[2]; \
- width2 = width >> 1; \
- for(;height > 0; height -= 2) { \
+ width2 = (width + 1) >> 1; \
+ for(;height >= 2; height -= 2) { \
d1 = d; \
d2 = d + dst->linesize[0]; \
y2_ptr = y1_ptr + src->linesize[0]; \
- for(w = width2; w > 0; w --) { \
+ for(w = width; w >= 2; w -= 2) { \
cb = cb_ptr[0] - 128; \
cr = cr_ptr[0] - 128; \
r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
@@ -433,30 +456,91 @@ static void yuv420p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
cb_ptr++; \
cr_ptr++; \
} \
+ /* handle odd width */ \
+ if (w) { \
+ cb = cb_ptr[0] - 128; \
+ cr = cr_ptr[0] - 128; \
+ r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
+ g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
+ b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
+ \
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
+ RGB_OUT(d1, r, g, b); \
+ \
+ YUV_TO_RGB2(r, g, b, y2_ptr[0]); \
+ RGB_OUT(d2, r, g, b); \
+ d1 += BPP; \
+ d2 += BPP; \
+ y1_ptr++; \
+ y2_ptr++; \
+ cb_ptr++; \
+ cr_ptr++; \
+ } \
d += 2 * dst->linesize[0]; \
y1_ptr += 2 * src->linesize[0] - width; \
cb_ptr += src->linesize[1] - width2; \
cr_ptr += src->linesize[2] - width2; \
} \
+ /* handle odd height */ \
+ if (height) { \
+ d1 = d; \
+ for(w = width; w >= 2; w -= 2) { \
+ cb = cb_ptr[0] - 128; \
+ cr = cr_ptr[0] - 128; \
+ r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
+ g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
+ b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
+ \
+ /* output 2 pixels */ \
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
+ RGB_OUT(d1, r, g, b); \
+ \
+ YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
+ RGB_OUT(d1 + BPP, r, g, b); \
+ \
+ d1 += 2 * BPP; \
+ \
+ y1_ptr += 2; \
+ cb_ptr++; \
+ cr_ptr++; \
+ } \
+ /* handle width */ \
+ if (w) { \
+ cb = cb_ptr[0] - 128; \
+ cr = cr_ptr[0] - 128; \
+ r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
+ g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
+ b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
+ \
+ /* output 2 pixels */ \
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
+ RGB_OUT(d1, r, g, b); \
+ d1 += BPP; \
+ \
+ y1_ptr++; \
+ cb_ptr++; \
+ cr_ptr++; \
+ } \
+ } \
} \
\
/* XXX: no chroma interpolating is done */ \
static void yuv422p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
int width, int height) \
{ \
- UINT8 *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; \
+ uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; \
int w, y, cb, cr, r_add, g_add, b_add, width2; \
- UINT8 *cm = cropTbl + MAX_NEG_CROP; \
+ uint8_t *cm = cropTbl + MAX_NEG_CROP; \
unsigned int r, g, b; \
\
d = dst->data[0]; \
y1_ptr = src->data[0]; \
cb_ptr = src->data[1]; \
cr_ptr = src->data[2]; \
- width2 = width >> 1; \
+ width2 = (width + 1) >> 1; \
for(;height > 0; height --) { \
d1 = d; \
- for(w = width2; w > 0; w --) { \
+ for(w = width; w >= 2; w -= 2) { \
cb = cb_ptr[0] - 128; \
cr = cr_ptr[0] - 128; \
r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
@@ -465,17 +549,34 @@ static void yuv422p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
\
/* output 2 pixels */ \
YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d, r, g, b); \
+ RGB_OUT(d1, r, g, b); \
\
YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
- RGB_OUT(d + BPP, r, g, b); \
+ RGB_OUT(d1 + BPP, r, g, b); \
\
- d += 2 * BPP; \
+ d1 += 2 * BPP; \
\
y1_ptr += 2; \
cb_ptr++; \
cr_ptr++; \
} \
+ /* handle width */ \
+ if (w) { \
+ cb = cb_ptr[0] - 128; \
+ cr = cr_ptr[0] - 128; \
+ r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
+ g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
+ b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
+ \
+ /* output 2 pixels */ \
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
+ RGB_OUT(d1, r, g, b); \
+ d1 += BPP; \
+ \
+ y1_ptr++; \
+ cb_ptr++; \
+ cr_ptr++; \
+ } \
d += dst->linesize[0]; \
y1_ptr += src->linesize[0] - width; \
cb_ptr += src->linesize[1] - width2; \
@@ -488,15 +589,15 @@ static void rgb_name ## _to_yuv420p(AVPicture *dst, AVPicture *src, \
{ \
int wrap, wrap3, x, y; \
int r, g, b, r1, g1, b1; \
- UINT8 *lum, *cb, *cr; \
- const UINT8 *p; \
+ uint8_t *lum, *cb, *cr; \
+ const uint8_t *p; \
\
lum = dst->data[0]; \
cb = dst->data[1]; \
cr = dst->data[2]; \
\
- wrap = width; \
- wrap3 = width * BPP; \
+ wrap = dst->linesize[0]; \
+ wrap3 = src->linesize[0]; \
p = src->data[0]; \
for(y=0;y<height;y+=2) { \
for(x=0;x<width;x+=2) { \
@@ -541,8 +642,10 @@ static void rgb_name ## _to_yuv420p(AVPicture *dst, AVPicture *src, \
p += -wrap3 + 2 * BPP; \
lum += -wrap + 2; \
} \
- p += wrap3; \
- lum += wrap; \
+ p += wrap3 + (wrap3 - width * BPP); \
+ lum += wrap + (wrap - width); \
+ cb += dst->linesize[1] - width / 2; \
+ cr += dst->linesize[2] - width / 2; \
} \
} \
\
@@ -597,6 +700,38 @@ static void gray_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
p += src_wrap; \
q += dst_wrap; \
} \
+} \
+ \
+static void pal8_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
+ int width, int height) \
+{ \
+ const unsigned char *p; \
+ unsigned char *q; \
+ int r, g, b, dst_wrap, src_wrap; \
+ int x, y; \
+ uint32_t v;\
+ const uint32_t *palette;\
+\
+ p = src->data[0]; \
+ src_wrap = src->linesize[0] - width; \
+ palette = (uint32_t *)src->data[1];\
+ \
+ q = dst->data[0]; \
+ dst_wrap = dst->linesize[0] - BPP * width; \
+ \
+ for(y=0;y<height;y++) { \
+ for(x=0;x<width;x++) { \
+ v = palette[p[0]];\
+ r = (v >> 16) & 0xff;\
+ g = (v >> 8) & 0xff;\
+ b = (v) & 0xff;\
+ RGB_OUT(q, r, g, b); \
+ q += BPP; \
+ p ++; \
+ } \
+ p += src_wrap; \
+ q += dst_wrap; \
+ } \
}
/* copy bit n to bits 0 ... n - 1 */
@@ -611,7 +746,7 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
#define RGB_IN(r, g, b, s)\
{\
- unsigned int v = ((UINT16 *)(s))[0];\
+ unsigned int v = ((const uint16_t *)(s))[0];\
r = bitcopy_n(v >> (10 - 3), 3);\
g = bitcopy_n(v >> (5 - 3), 3);\
b = bitcopy_n(v << 3, 3);\
@@ -619,7 +754,7 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
#define RGB_OUT(d, r, g, b)\
{\
- ((UINT16 *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;\
+ ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;\
}
#define BPP 2
@@ -634,7 +769,7 @@ RGB_FUNCTIONS(rgb555)
#define RGB_IN(r, g, b, s)\
{\
- unsigned int v = ((UINT16 *)(s))[0];\
+ unsigned int v = ((const uint16_t *)(s))[0];\
r = bitcopy_n(v >> (11 - 3), 3);\
g = bitcopy_n(v >> (5 - 2), 2);\
b = bitcopy_n(v << 3, 3);\
@@ -642,7 +777,7 @@ RGB_FUNCTIONS(rgb555)
#define RGB_OUT(d, r, g, b)\
{\
- ((UINT16 *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\
+ ((uint16_t *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\
}
#define BPP 2
@@ -705,7 +840,7 @@ RGB_FUNCTIONS(rgb24)
#define RGB_IN(r, g, b, s)\
{\
- unsigned int v = ((UINT32 *)(s))[0];\
+ unsigned int v = ((const uint32_t *)(s))[0];\
r = (v >> 16) & 0xff;\
g = (v >> 8) & 0xff;\
b = v & 0xff;\
@@ -713,7 +848,7 @@ RGB_FUNCTIONS(rgb24)
#define RGB_OUT(d, r, g, b)\
{\
- ((UINT32 *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;\
+ ((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;\
}
#define BPP 4
@@ -843,8 +978,8 @@ static void gray_to_mono(AVPicture *dst, AVPicture *src,
int width, int height, int xor_mask)
{
int n;
- const UINT8 *s;
- UINT8 *d;
+ const uint8_t *s;
+ uint8_t *d;
int j, b, v, n1, src_wrap, dst_wrap, y;
s = src->data[0];
@@ -896,6 +1031,58 @@ static void gray_to_monoblack(AVPicture *dst, AVPicture *src,
gray_to_mono(dst, src, width, height, 0x00);
}
+/* this is maybe slow, but allows for extensions */
+static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
+{
+ return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6));
+}
+
+/* XXX: put jpeg quantize code instead */
+static void rgb24_to_pal8(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, g, b, dst_wrap, src_wrap;
+ int x, y, i;
+ static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
+ uint32_t *pal;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - 3 * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ r = p[0];
+ g = p[1];
+ b = p[2];
+
+ q[0] = gif_clut_index(r, g, b);
+ q++;
+ p += 3;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+
+ /* build palette */
+ pal = (uint32_t *)dst->data[1];
+ i = 0;
+ for(r = 0; r < 6; r++) {
+ for(g = 0; g < 6; g++) {
+ for(b = 0; b < 6; b++) {
+ pal[i++] = (0xff << 24) | (pal_value[r] << 16) |
+ (pal_value[g] << 8) | pal_value[b];
+ }
+ }
+ }
+ while (i < 256)
+ pal[i++] = 0;
+}
+
typedef struct ConvertEntry {
void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
} ConvertEntry;
@@ -905,614 +1092,143 @@ typedef struct ConvertEntry {
- all non YUV modes must convert at least to and from PIX_FMT_RGB24
*/
static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
- { /*PIX_FMT_YUV420P*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- yuv420p_to_rgb24
- },
- { /*PIX_FMT_BGR24*/
- yuv420p_to_bgr24
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
+ [PIX_FMT_YUV420P] = {
+ [PIX_FMT_RGB555] = {
+ .convert = yuv420p_to_rgb555
},
- { /*PIX_FMT_RGBA32]*/
- yuv420p_to_rgba32
+ [PIX_FMT_RGB565] = {
+ .convert = yuv420p_to_rgb565
},
- { /*PIX_FMT_YUV410P*/
- NULL
+ [PIX_FMT_BGR24] = {
+ .convert = yuv420p_to_bgr24
},
- { /*PIX_FMT_YUV411P*/
- NULL
+ [PIX_FMT_RGB24] = {
+ .convert = yuv420p_to_rgb24
},
- { /*PIX_FMT_RGB565*/
- yuv420p_to_rgb565
- },
- { /*PIX_FMT_RGB555*/
- yuv420p_to_rgb555
- },
- { /*PIX_FMT_GRAY8*/
- NULL
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_RGBA32] = {
+ .convert = yuv420p_to_rgba32
},
},
- { /*PIX_FMT_YUV422*/
- { /*PIX_FMT_YUV420P*/
- yuv422_to_yuv420p
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
+ [PIX_FMT_YUV422P] = {
+ [PIX_FMT_RGB555] = {
+ .convert = yuv422p_to_rgb555
},
- { /*PIX_FMT_YUV410P*/
- NULL
+ [PIX_FMT_RGB565] = {
+ .convert = yuv422p_to_rgb565
},
- { /*PIX_FMT_YUV411P*/
- NULL
+ [PIX_FMT_BGR24] = {
+ .convert = yuv422p_to_bgr24
},
- { /*PIX_FMT_RGB565*/
- NULL
+ [PIX_FMT_RGB24] = {
+ .convert = yuv422p_to_rgb24
},
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- NULL
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_RGBA32] = {
+ .convert = yuv422p_to_rgba32
},
},
- { /*PIX_FMT_RGB24*/
- { /*PIX_FMT_YUV420P*/
- rgb24_to_yuv420p
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- rgb24_to_rgb565
- },
- { /*PIX_FMT_RGB555*/
- rgb24_to_rgb555
- },
- { /*PIX_FMT_GRAY8*/
- rgb24_to_gray
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_YUV422] = {
+ [PIX_FMT_YUV420P] = {
+ .convert = yuv422_to_yuv420p,
},
},
- { /*PIX_FMT_BGR24*/
- { /*PIX_FMT_YUV420P*/
- bgr24_to_yuv420p
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
- },
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- bgr24_to_gray
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
- },
- },
- { /*PIX_FMT_YUV422P*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- yuv422p_to_bgr24
- },
- { /*PIX_FMT_RGB24*/
- yuv422p_to_rgb24
- },
- { /*PIX_FMT_RGBA32*/
- yuv422p_to_rgba32
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB555*/
- yuv422p_to_rgb555
- },
- { /*PIX_FMT_RGB565*/
- yuv422p_to_rgb565
- },
- { /*PIX_FMT_GRAY8*/
- NULL
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
- },
- },
- { /*PIX_FMT_YUV444P*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
+
+ [PIX_FMT_RGB24] = {
+ [PIX_FMT_YUV420P] = {
+ .convert = rgb24_to_yuv420p
},
- { /*PIX_FMT_RGB555*/
- NULL
+ [PIX_FMT_RGB565] = {
+ .convert = rgb24_to_rgb565
},
- { /*PIX_FMT_GRAY8*/
- NULL
+ [PIX_FMT_RGB555] = {
+ .convert = rgb24_to_rgb555
},
- { /*PIX_FMT_MONOWHITE*/
- NULL
+ [PIX_FMT_GRAY8] = {
+ .convert = rgb24_to_gray
},
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_PAL8] = {
+ .convert = rgb24_to_pal8
},
},
- { /*PIX_FMT_RGBA32*/
- { /*PIX_FMT_YUV420P*/
- rgba32_to_yuv420p
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
+ [PIX_FMT_RGBA32] = {
+ [PIX_FMT_YUV420P] = {
+ .convert = rgba32_to_yuv420p
},
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
- },
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- rgba32_to_gray
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_GRAY8] = {
+ .convert = rgba32_to_gray
},
},
- { /*PIX_FMT_YUV410P*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
+ [PIX_FMT_BGR24] = {
+ [PIX_FMT_YUV420P] = {
+ .convert = bgr24_to_yuv420p
},
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
- },
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- NULL
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_GRAY8] = {
+ .convert = bgr24_to_gray
},
},
- { /*PIX_FMT_YUV411P*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
+ [PIX_FMT_RGB555] = {
+ [PIX_FMT_YUV420P] = {
+ .convert = rgb555_to_yuv420p
},
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- NULL
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_GRAY8] = {
+ .convert = rgb555_to_gray
},
},
- { /*PIX_FMT_RGB565*/
- { /*PIX_FMT_YUV420P*/
- rgb565_to_yuv420p
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
+ [PIX_FMT_RGB565] = {
+ [PIX_FMT_YUV420P] = {
+ .convert = rgb565_to_yuv420p
},
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
- },
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- rgb565_to_gray
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_GRAY8] = {
+ .convert = rgb565_to_gray
},
},
- { /*PIX_FMT_RGB555*/
- { /*PIX_FMT_YUV420P*/
- rgb555_to_yuv420p
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
+ [PIX_FMT_GRAY8] = {
+ [PIX_FMT_RGB555] = {
+ .convert = gray_to_rgb555
},
- { /*PIX_FMT_YUV444P*/
- NULL
+ [PIX_FMT_RGB565] = {
+ .convert = gray_to_rgb565
},
- { /*PIX_FMT_RGBA32*/
- NULL
+ [PIX_FMT_RGB24] = {
+ .convert = gray_to_rgb24
},
- { /*PIX_FMT_YUV410P*/
- NULL
+ [PIX_FMT_BGR24] = {
+ .convert = gray_to_bgr24
},
- { /*PIX_FMT_YUV411P*/
- NULL
+ [PIX_FMT_RGBA32] = {
+ .convert = gray_to_rgba32
},
- { /*PIX_FMT_RGB565*/
- NULL
+ [PIX_FMT_MONOWHITE] = {
+ .convert = gray_to_monowhite
},
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- rgb555_to_gray
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_MONOBLACK] = {
+ .convert = gray_to_monoblack
},
},
- { /*PIX_FMT_GRAY8*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- gray_to_rgb24
- },
- { /*PIX_FMT_BGR24*/
- gray_to_bgr24
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- gray_to_rgba32
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- gray_to_rgb565
- },
- { /*PIX_FMT_RGB555*/
- gray_to_rgb555
- },
- { /*PIX_FMT_GRAY8*/
- NULL
- },
- { /*PIX_FMT_MONOWHITE*/
- gray_to_monowhite
- },
- { /*PIX_FMT_MONOBLACK*/
- gray_to_monoblack
+ [PIX_FMT_MONOWHITE] = {
+ [PIX_FMT_GRAY8] = {
+ .convert = monowhite_to_gray
},
},
- { /*PIX_FMT_MONOWHITE*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
- },
- { /*PIX_FMT_RGB555*/
- NULL
- },
- { /*PIX_FMT_GRAY8*/
- monowhite_to_gray
- },
- { /*PIX_FMT_MONOWHITE*/
- NULL
- },
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_MONOBLACK] = {
+ [PIX_FMT_GRAY8] = {
+ .convert = monoblack_to_gray
},
},
- { /*PIX_FMT_MONOBLACK*/
- { /*PIX_FMT_YUV420P*/
- NULL
- },
- { /*PIX_FMT_YUV422*/
- NULL
- },
- { /*PIX_FMT_RGB24*/
- NULL
- },
- { /*PIX_FMT_BGR24*/
- NULL
- },
- { /*PIX_FMT_YUV422P*/
- NULL
- },
- { /*PIX_FMT_YUV444P*/
- NULL
- },
- { /*PIX_FMT_RGBA32*/
- NULL
- },
- { /*PIX_FMT_YUV410P*/
- NULL
- },
- { /*PIX_FMT_YUV411P*/
- NULL
- },
- { /*PIX_FMT_RGB565*/
- NULL
+ [PIX_FMT_PAL8] = {
+ [PIX_FMT_RGB555] = {
+ .convert = pal8_to_rgb555
},
- { /*PIX_FMT_RGB555*/
- NULL
+ [PIX_FMT_RGB565] = {
+ .convert = pal8_to_rgb565
},
- { /*PIX_FMT_GRAY8*/
- monoblack_to_gray
+ [PIX_FMT_BGR24] = {
+ .convert = pal8_to_bgr24
},
- { /*PIX_FMT_MONOWHITE*/
- NULL
+ [PIX_FMT_RGB24] = {
+ .convert = pal8_to_rgb24
},
- { /*PIX_FMT_MONOBLACK*/
- NULL
+ [PIX_FMT_RGBA32] = {
+ .convert = pal8_to_rgba32
},
},
};
@@ -1520,7 +1236,7 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
static int avpicture_alloc(AVPicture *picture,
int pix_fmt, int width, int height)
{
- int size;
+ unsigned int size;
void *ptr;
size = avpicture_get_size(pix_fmt, width, height);
@@ -1621,8 +1337,8 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
/* YUV to YUV */
if (dst_pix->is_yuv && src_pix->is_yuv) {
int x_shift, y_shift, w, h;
- void (*resize_func)(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+ void (*resize_func)(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height);
/* compute chroma size of the smallest dimensions */
@@ -1661,7 +1377,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
for(i = 1;i <= 2; i++)
resize_func(dst->data[i], dst->linesize[i],
src->data[i], src->linesize[i],
- w, h);
+ dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift);
return 0;
}
@@ -1738,11 +1454,11 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
#endif
/* filter parameters: [-1 4 2 4 -1] // 8 */
-static void deinterlace_line(UINT8 *dst, UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2, UINT8 *lum_m1, UINT8 *lum,
+static void deinterlace_line(uint8_t *dst, uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
int size)
{
#ifndef HAVE_MMX
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
int sum;
for(;size > 0;size--) {
@@ -1781,11 +1497,11 @@ static void deinterlace_line(UINT8 *dst, UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lu
}
#endif
}
-static void deinterlace_line_inplace(UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2, UINT8 *lum_m1, UINT8 *lum,
+static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
int size)
{
#ifndef HAVE_MMX
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
int sum;
for(;size > 0;size--) {
@@ -1827,11 +1543,11 @@ static void deinterlace_line_inplace(UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2
/* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The
top field is copied as is, but the bottom field is deinterlaced
against the top field. */
-static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap,
- UINT8 *src1, int src_wrap,
+static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
+ uint8_t *src1, int src_wrap,
int width, int height)
{
- UINT8 *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
+ uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
int y;
src_m2 = src1;
@@ -1856,13 +1572,13 @@ static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap,
deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width);
}
-static void deinterlace_bottom_field_inplace(UINT8 *src1, int src_wrap,
+static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
int width, int height)
{
- UINT8 *src_m1, *src_0, *src_p1, *src_p2;
+ uint8_t *src_m1, *src_0, *src_p1, *src_p2;
int y;
- UINT8 *buf;
- buf = (UINT8*)av_malloc(width);
+ uint8_t *buf;
+ buf = (uint8_t*)av_malloc(width);
src_m1 = src1;
memcpy(buf,src_m1,width);
diff --git a/src/libffmpeg/libavcodec/imgresample.c b/src/libffmpeg/libavcodec/imgresample.c
index 28147fc72..140894d36 100644
--- a/src/libffmpeg/libavcodec/imgresample.c
+++ b/src/libffmpeg/libavcodec/imgresample.c
@@ -16,13 +16,18 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file imgresample.c
+ * High quality image resampling with polyphase filters .
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#ifdef USE_FASTMEMCPY
#include "fastmemcpy.h"
#endif
-extern int mm_flags;
#define NB_COMPONENTS 3
@@ -42,9 +47,9 @@ extern int mm_flags;
struct ImgReSampleContext {
int iwidth, iheight, owidth, oheight, topBand, bottomBand, leftBand, rightBand;
int h_incr, v_incr;
- INT16 h_filters[NB_PHASES][NB_TAPS] __align8; /* horizontal filters */
- INT16 v_filters[NB_PHASES][NB_TAPS] __align8; /* vertical filters */
- UINT8 *line_buf;
+ int16_t h_filters[NB_PHASES][NB_TAPS] __align8; /* horizontal filters */
+ int16_t v_filters[NB_PHASES][NB_TAPS] __align8; /* vertical filters */
+ uint8_t *line_buf;
};
static inline int get_phase(int pos)
@@ -53,12 +58,12 @@ static inline int get_phase(int pos)
}
/* This function must be optimized */
-static void h_resample_fast(UINT8 *dst, int dst_width, UINT8 *src, int src_width,
- int src_start, int src_incr, INT16 *filters)
+static void h_resample_fast(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
+ int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase, sum, i;
- UINT8 *s;
- INT16 *filter;
+ uint8_t *s;
+ int16_t *filter;
src_pos = src_start;
for(i=0;i<dst_width;i++) {
@@ -96,11 +101,11 @@ static void h_resample_fast(UINT8 *dst, int dst_width, UINT8 *src, int src_width
}
/* This function must be optimized */
-static void v_resample(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
- INT16 *filter)
+static void v_resample(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
+ int16_t *filter)
{
int sum, i;
- UINT8 *s;
+ uint8_t *s;
s = src;
for(i=0;i<dst_width;i++) {
@@ -112,7 +117,7 @@ static void v_resample(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
#else
{
int j;
- UINT8 *s1 = s;
+ uint8_t *s1 = s;
sum = 0;
for(j=0;j<NB_TAPS;j++) {
@@ -155,12 +160,12 @@ static void v_resample(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
#define DUMP(reg) movq_r2m(reg, tmp); printf(#reg "=%016Lx\n", tmp.uq);
/* XXX: do four pixels at a time */
-static void h_resample_fast4_mmx(UINT8 *dst, int dst_width, UINT8 *src, int src_width,
- int src_start, int src_incr, INT16 *filters)
+static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
+ int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase;
- UINT8 *s;
- INT16 *filter;
+ uint8_t *s;
+ int16_t *filter;
mmx_t tmp;
src_pos = src_start;
@@ -199,11 +204,11 @@ static void h_resample_fast4_mmx(UINT8 *dst, int dst_width, UINT8 *src, int src_
emms();
}
-static void v_resample4_mmx(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
- INT16 *filter)
+static void v_resample4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
+ int16_t *filter)
{
int sum, i, v;
- UINT8 *s;
+ uint8_t *s;
mmx_t tmp;
mmx_t coefs[4];
@@ -240,7 +245,7 @@ static void v_resample4_mmx(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
packuswb_r2r(mm7, mm0);
movq_r2m(mm0, tmp);
- *(UINT32 *)dst = tmp.ud[0];
+ *(uint32_t *)dst = tmp.ud[0];
dst += 4;
s += 4;
dst_width -= 4;
@@ -275,8 +280,8 @@ typedef union {
signed short s[8];
} vec_ss_t;
-void v_resample16_altivec(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
- INT16 *filter)
+void v_resample16_altivec(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
+ int16_t *filter)
{
int sum, i;
uint8_t *s;
@@ -392,12 +397,12 @@ void v_resample16_altivec(UINT8 *dst, int dst_width, UINT8 *src, int wrap,
#endif
/* slow version to handle limit cases. Does not need optimisation */
-static void h_resample_slow(UINT8 *dst, int dst_width, UINT8 *src, int src_width,
- int src_start, int src_incr, INT16 *filters)
+static void h_resample_slow(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
+ int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase, sum, j, v, i;
- UINT8 *s, *src_end;
- INT16 *filter;
+ uint8_t *s, *src_end;
+ int16_t *filter;
src_end = src + src_width;
src_pos = src_start;
@@ -427,8 +432,8 @@ static void h_resample_slow(UINT8 *dst, int dst_width, UINT8 *src, int src_width
}
}
-static void h_resample(UINT8 *dst, int dst_width, UINT8 *src, int src_width,
- int src_start, int src_incr, INT16 *filters)
+static void h_resample(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
+ int src_start, int src_incr, int16_t *filters)
{
int n, src_end;
@@ -464,11 +469,11 @@ static void h_resample(UINT8 *dst, int dst_width, UINT8 *src, int src_width,
}
static void component_resample(ImgReSampleContext *s,
- UINT8 *output, int owrap, int owidth, int oheight,
- UINT8 *input, int iwrap, int iwidth, int iheight)
+ uint8_t *output, int owrap, int owidth, int oheight,
+ uint8_t *input, int iwrap, int iwidth, int iheight)
{
int src_y, src_y1, last_src_y, ring_y, phase_y, y1, y;
- UINT8 *new_line, *src_line;
+ uint8_t *new_line, *src_line;
last_src_y = - FCENTER - 1;
/* position of the bottom of the filter in the source image */
@@ -529,7 +534,7 @@ static void component_resample(ImgReSampleContext *s,
/* XXX: the following filter is quite naive, but it seems to suffice
for 4 taps */
-static void build_filter(INT16 *filter, float factor)
+static void build_filter(int16_t *filter, float factor)
{
int ph, i, v;
float x, y, tab[NB_TAPS], norm, mult;
@@ -642,15 +647,15 @@ void av_free(void *ptr)
/* input */
#define XSIZE 256
#define YSIZE 256
-UINT8 img[XSIZE * YSIZE];
+uint8_t img[XSIZE * YSIZE];
/* output */
#define XSIZE1 512
#define YSIZE1 512
-UINT8 img1[XSIZE1 * YSIZE1];
-UINT8 img2[XSIZE1 * YSIZE1];
+uint8_t img1[XSIZE1 * YSIZE1];
+uint8_t img2[XSIZE1 * YSIZE1];
-void save_pgm(const char *filename, UINT8 *img, int xsize, int ysize)
+void save_pgm(const char *filename, uint8_t *img, int xsize, int ysize)
{
FILE *f;
f=fopen(filename,"w");
@@ -659,7 +664,7 @@ void save_pgm(const char *filename, UINT8 *img, int xsize, int ysize)
fclose(f);
}
-static void dump_filter(INT16 *filter)
+static void dump_filter(int16_t *filter)
{
int i, ph;
diff --git a/src/libffmpeg/libavcodec/jfdctfst.c b/src/libffmpeg/libavcodec/jfdctfst.c
index 4e3b55bb5..899768d36 100644
--- a/src/libffmpeg/libavcodec/jfdctfst.c
+++ b/src/libffmpeg/libavcodec/jfdctfst.c
@@ -30,6 +30,11 @@
* quality-setting files than with low-quality ones.
*/
+/**
+ * @file jfdctfst.c
+ * Independent JPEG Group's fast AAN dct.
+ */
+
#include <stdlib.h>
#include <stdio.h>
#include "common.h"
@@ -78,10 +83,10 @@
*/
#if CONST_BITS == 8
-#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */
-#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */
-#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */
-#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */
+#define FIX_0_382683433 ((int32_t) 98) /* FIX(0.382683433) */
+#define FIX_0_541196100 ((int32_t) 139) /* FIX(0.541196100) */
+#define FIX_0_707106781 ((int32_t) 181) /* FIX(0.707106781) */
+#define FIX_1_306562965 ((int32_t) 334) /* FIX(1.306562965) */
#else
#define FIX_0_382683433 FIX(0.382683433)
#define FIX_0_541196100 FIX(0.541196100)
@@ -101,7 +106,7 @@
#endif
-/* Multiply a DCTELEM variable by an INT32 constant, and immediately
+/* Multiply a DCTELEM variable by an int32_t constant, and immediately
* descale to yield a DCTELEM result.
*/
diff --git a/src/libffmpeg/libavcodec/jfdctint.c b/src/libffmpeg/libavcodec/jfdctint.c
index 6b0d4cadb..702d0a947 100644
--- a/src/libffmpeg/libavcodec/jfdctint.c
+++ b/src/libffmpeg/libavcodec/jfdctint.c
@@ -23,6 +23,11 @@
* scaled fixed-point arithmetic, with a minimal number of shifts.
*/
+/**
+ * @file jfdctint.c
+ * Independent JPEG Group's slow & accurate dct.
+ */
+
#include <stdlib.h>
#include <stdio.h>
#include "common.h"
@@ -78,7 +83,7 @@
* they are represented to better-than-integral precision. These outputs
* require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
* with the recommended scaling. (For 12-bit sample data, the intermediate
- * array is INT32 anyway.)
+ * array is int32_t anyway.)
*
* To avoid overflow of the 32-bit intermediate results in pass 2, we must
* have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
@@ -101,18 +106,18 @@
*/
#if CONST_BITS == 13
-#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
-#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
-#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */
-#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */
-#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */
-#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */
-#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */
-#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */
-#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */
-#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */
-#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */
-#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */
+#define FIX_0_298631336 ((int32_t) 2446) /* FIX(0.298631336) */
+#define FIX_0_390180644 ((int32_t) 3196) /* FIX(0.390180644) */
+#define FIX_0_541196100 ((int32_t) 4433) /* FIX(0.541196100) */
+#define FIX_0_765366865 ((int32_t) 6270) /* FIX(0.765366865) */
+#define FIX_0_899976223 ((int32_t) 7373) /* FIX(0.899976223) */
+#define FIX_1_175875602 ((int32_t) 9633) /* FIX(1.175875602) */
+#define FIX_1_501321110 ((int32_t) 12299) /* FIX(1.501321110) */
+#define FIX_1_847759065 ((int32_t) 15137) /* FIX(1.847759065) */
+#define FIX_1_961570560 ((int32_t) 16069) /* FIX(1.961570560) */
+#define FIX_2_053119869 ((int32_t) 16819) /* FIX(2.053119869) */
+#define FIX_2_562915447 ((int32_t) 20995) /* FIX(2.562915447) */
+#define FIX_3_072711026 ((int32_t) 25172) /* FIX(3.072711026) */
#else
#define FIX_0_298631336 FIX(0.298631336)
#define FIX_0_390180644 FIX(0.390180644)
@@ -129,7 +134,7 @@
#endif
-/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
+/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
* 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
@@ -150,9 +155,9 @@
GLOBAL(void)
ff_jpeg_fdct_islow (DCTELEM * data)
{
- INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- INT32 tmp10, tmp11, tmp12, tmp13;
- INT32 z1, z2, z3, z4, z5;
+ int32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int32_t tmp10, tmp11, tmp12, tmp13;
+ int32_t z1, z2, z3, z4, z5;
DCTELEM *dataptr;
int ctr;
SHIFT_TEMPS
diff --git a/src/libffmpeg/libavcodec/jrevdct.c b/src/libffmpeg/libavcodec/jrevdct.c
index 3ba91543d..3bd78c192 100644
--- a/src/libffmpeg/libavcodec/jrevdct.c
+++ b/src/libffmpeg/libavcodec/jrevdct.c
@@ -25,6 +25,12 @@
* A better way to do this would be to pass in the DCT block as a sparse
* matrix, perhaps with the difference cases encoded.
*/
+
+/**
+ * @file jrevdct.c
+ * Independent JPEG Group's LLM idct.
+ */
+
#include "common.h"
#include "dsputil.h"
@@ -92,7 +98,7 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
-#define ONE ((INT32) 1)
+#define ONE ((int32_t) 1)
#define CONST_SCALE (ONE << CONST_BITS)
@@ -103,16 +109,16 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
*/
/* Actually FIX is no longer used, we precomputed them all */
-#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
+#define FIX(x) ((int32_t) ((x) * CONST_SCALE + 0.5))
-/* Descale and correctly round an INT32 value that's scaled by N bits.
+/* Descale and correctly round an int32_t value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
-/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
+/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
* 16x16->32 bit multiply can be used instead of a full 32x32 multiply;
@@ -125,10 +131,10 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
#ifdef EIGHT_BIT_SAMPLES
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
-#define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const)))
+#define MULTIPLY(var,const) (((int16_t) (var)) * ((int16_t) (const)))
#endif
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
-#define MULTIPLY(var,const) (((INT16) (var)) * ((INT32) (const)))
+#define MULTIPLY(var,const) (((int16_t) (var)) * ((int32_t) (const)))
#endif
#endif
@@ -172,10 +178,10 @@ ones here or successive P-frames will drift too much with Reference frame coding
void j_rev_dct(DCTBLOCK data)
{
- INT32 tmp0, tmp1, tmp2, tmp3;
- INT32 tmp10, tmp11, tmp12, tmp13;
- INT32 z1, z2, z3, z4, z5;
- INT32 d0, d1, d2, d3, d4, d5, d6, d7;
+ int32_t tmp0, tmp1, tmp2, tmp3;
+ int32_t tmp10, tmp11, tmp12, tmp13;
+ int32_t z1, z2, z3, z4, z5;
+ int32_t d0, d1, d2, d3, d4, d5, d6, d7;
register DCTELEM *dataptr;
int rowctr;
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.c b/src/libffmpeg/libavcodec/libpostproc/postprocess.c
index 130bb36c6..8668b530f 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess.c
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.c
@@ -16,6 +16,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * @file postprocess.c
+ * postprocessing.
+ */
+
/*
C MMX MMX2 3DNow
isVertDC Ec Ec
@@ -62,10 +67,8 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
//Changelog: use the CVS log
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
-
+#include <inttypes.h>
#include <stdio.h>
#include "xineutils.h"
@@ -152,7 +155,6 @@ static inline void unusedVariableWarningFixer()
}
#endif
-
// The horizontal Functions exist only in C cuz the MMX code is faster with vertical filters and transposing
/**
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.h b/src/libffmpeg/libavcodec/libpostproc/postprocess.h
index 8c3c7b143..fd8a42c13 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess.h
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.h
@@ -36,7 +36,7 @@ extern "C" {
typedef void pp_context_t;
typedef void pp_mode_t;
-extern char *pp_help; /* a simple help text */
+extern char *pp_help; ///< a simple help text
void pp_postprocess(uint8_t * src[3], int srcStride[3],
uint8_t * dst[3], int dstStride[3],
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h b/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h
index f45a0cf85..1956180b7 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h
@@ -16,10 +16,15 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * @file postprocess_internal.h
+ * internal api header.
+ */
+
#define V_DEBLOCK 0x01
#define H_DEBLOCK 0x02
#define DERING 0x04
-#define LEVEL_FIX 0x08 /* Brightness & Contrast */
+#define LEVEL_FIX 0x08 ///< Brightness & Contrast
#define LUM_V_DEBLOCK V_DEBLOCK // 1
#define LUM_H_DEBLOCK H_DEBLOCK // 2
@@ -36,7 +41,7 @@
// Experimental horizontal filters
#define H_X1_FILTER 0x2000 // 8192
-// select between full y range (255-0) or standart one (234-16)
+/// select between full y range (255-0) or standart one (234-16)
#define FULL_Y_RANGE 0x8000 // 32768
//Deinterlacing Filters
@@ -56,47 +61,59 @@
//filters on
//#define COMPILE_TIME_MODE 0x77
+/**
+ * Postprocessng filter.
+ */
struct PPFilter{
char *shortName;
char *longName;
- int chromDefault; // is chrominance filtering on by default if this filter is manually activated
- int minLumQuality; // minimum quality to turn luminance filtering on
- int minChromQuality; // minimum quality to turn chrominance filtering on
- int mask; // Bitmask to turn this filter on
+ int chromDefault; ///< is chrominance filtering on by default if this filter is manually activated
+ int minLumQuality; ///< minimum quality to turn luminance filtering on
+ int minChromQuality; ///< minimum quality to turn chrominance filtering on
+ int mask; ///< Bitmask to turn this filter on
};
+/**
+ * Postprocessng mode.
+ */
typedef struct PPMode{
- int lumMode; // acivates filters for luminance
- int chromMode; // acivates filters for chrominance
- int error; // non zero on error
+ int lumMode; ///< acivates filters for luminance
+ int chromMode; ///< acivates filters for chrominance
+ int error; ///< non zero on error
- int minAllowedY; // for brigtness correction
- int maxAllowedY; // for brihtness correction
- float maxClippedThreshold; // amount of "black" u r willing to loose to get a brightness corrected picture
+ int minAllowedY; ///< for brigtness correction
+ int maxAllowedY; ///< for brihtness correction
+ float maxClippedThreshold; ///< amount of "black" u r willing to loose to get a brightness corrected picture
- int maxTmpNoise[3]; // for Temporal Noise Reducing filter (Maximal sum of abs differences)
+ int maxTmpNoise[3]; ///< for Temporal Noise Reducing filter (Maximal sum of abs differences)
int baseDcDiff;
int flatnessThreshold;
- int forcedQuant; // quantizer if FORCE_QUANT is used
+ int forcedQuant; ///< quantizer if FORCE_QUANT is used
} PPMode;
+/**
+ * postprocess context.
+ */
typedef struct PPContext{
- uint8_t *tempBlocks; //used for the horizontal code
+ uint8_t *tempBlocks; ///<used for the horizontal code
- /* we need 64bit here otherwise we´ll going to have a problem
- after watching a black picture for 5 hours*/
+ /**
+ * luma histogram.
+ * we need 64bit here otherwise we'll going to have a problem
+ * after watching a black picture for 5 hours
+ */
uint64_t *yHistogram;
uint64_t __attribute__((aligned(8))) packedYOffset;
uint64_t __attribute__((aligned(8))) packedYScale;
- /* Temporal noise reducing buffers */
+ /** Temporal noise reducing buffers */
uint8_t *tempBlured[3];
int32_t *tempBluredPast[3];
- /* Temporary buffers for handling the last row(s) */
+ /** Temporary buffers for handling the last row(s) */
uint8_t *tempDst;
uint8_t *tempSrc;
@@ -118,7 +135,7 @@ typedef struct PPContext{
int cpuCaps;
- int stride; //size of some buffers (needed to realloc them if needed)
+ int stride; ///<size of some buffers (needed to realloc them if needed)
int hChromaSubSample;
int vChromaSubSample;
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c b/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
index af48cdcba..fc8cde56c 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
@@ -16,6 +16,12 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * @file postprocess_template.c
+ * mmx/mmx2/3dnow postprocess code.
+ */
+
+
#undef PAVGB
#undef PMINUB
#undef PMAXUB
@@ -1523,7 +1529,7 @@ DERING_CORE((%0, %1, 8),(%%edx, %1, 4) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm
}
/**
- * Deinterlaces the given block
+ * Deinterlaces the given block by linearly interpolating every second line.
* will be called for every 8x8 block and can read & write from line 4-15
* lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
* lines 4-12 will be read into the deblocking filter and should be deinterlaced
@@ -1570,7 +1576,7 @@ static inline void RENAME(deInterlaceInterpolateLinear)(uint8_t src[], int strid
}
/**
- * Deinterlaces the given block
+ * Deinterlaces the given block by cubic interpolating every second line.
* will be called for every 8x8 block and can read & write from line 4-15
* lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
* lines 4-12 will be read into the deblocking filter and should be deinterlaced
@@ -1635,7 +1641,7 @@ DEINT_CUBIC((%%edx, %1), (%0, %1, 8), (%%edx, %1, 4), (%%ecx), (%%ecx, %1, 2))
}
/**
- * Deinterlaces the given block
+ * Deinterlaces the given block by filtering every second line with a (-1 4 2 4 -1) filter.
* will be called for every 8x8 block and can read & write from line 4-15
* lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
* lines 4-12 will be read into the deblocking filter and should be deinterlaced
@@ -1714,7 +1720,7 @@ DEINT_FF((%%edx, %1), (%%edx, %1, 2), (%0, %1, 8), (%%edx, %1, 4))
}
/**
- * Deinterlaces the given block
+ * Deinterlaces the given block by filtering all lines with a (1 2 1) filter.
* will be called for every 8x8 block and can read & write from line 4-15
* lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
* lines 4-12 will be read into the deblocking filter and should be deinterlaced
@@ -1789,7 +1795,7 @@ static inline void RENAME(deInterlaceBlendLinear)(uint8_t src[], int stride)
}
/**
- * Deinterlaces the given block
+ * Deinterlaces the given block by applying a median filter to every second line.
* will be called for every 8x8 block and can read & write from line 4-15,
* lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
* lines 4-12 will be read into the deblocking filter and should be deinterlaced
diff --git a/src/libffmpeg/libavcodec/mace.c b/src/libffmpeg/libavcodec/mace.c
index 18aaacaf1..91a37452b 100644
--- a/src/libffmpeg/libavcodec/mace.c
+++ b/src/libffmpeg/libavcodec/mace.c
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file mace.c
+ * MACE decoder.
+ */
+
#include "avcodec.h"
/*
@@ -24,11 +30,11 @@
* libavcodec api, context stuff, interlaced stereo out).
*/
-static const UINT16 MACEtab1[] = { 0xfff3, 0x0008, 0x004c, 0x00de, 0x00de, 0x004c, 0x0008, 0xfff3 };
+static const uint16_t MACEtab1[] = { 0xfff3, 0x0008, 0x004c, 0x00de, 0x00de, 0x004c, 0x0008, 0xfff3 };
-static const UINT16 MACEtab3[] = { 0xffee, 0x008c, 0x008c, 0xffee };
+static const uint16_t MACEtab3[] = { 0xffee, 0x008c, 0x008c, 0xffee };
-static const UINT16 MACEtab2[][8] = {
+static const uint16_t MACEtab2[][8] = {
{ 0x0025, 0x0074, 0x00CE, 0x014A, 0xFEB5, 0xFF31, 0xFF8B, 0xFFDA },
{ 0x0027, 0x0079, 0x00D8, 0x015A, 0xFEA5, 0xFF27, 0xFF86, 0xFFD8 },
{ 0x0029, 0x007F, 0x00E1, 0x0169, 0xFE96, 0xFF1E, 0xFF80, 0xFFD6 },
@@ -159,7 +165,7 @@ static const UINT16 MACEtab2[][8] = {
{ 0x25A7, 0x741F, 0x7FFF, 0x7FFF, 0x8000, 0x8000, 0x8BE0, 0xDA58 },
};
-static const UINT16 MACEtab4[][8] = {
+static const uint16_t MACEtab4[][8] = {
{ 0x0040, 0x00D8, 0xFF27, 0xFFBF, 0, 0, 0, 0 }, { 0x0043, 0x00E2, 0xFF1D, 0xFFBC, 0, 0, 0, 0 },
{ 0x0046, 0x00EC, 0xFF13, 0xFFB9, 0, 0, 0, 0 }, { 0x004A, 0x00F6, 0xFF09, 0xFFB5, 0, 0, 0, 0 },
{ 0x004D, 0x0101, 0xFEFE, 0xFFB2, 0, 0, 0, 0 }, { 0x0050, 0x010C, 0xFEF3, 0xFFAF, 0, 0, 0, 0 },
@@ -234,9 +240,9 @@ typedef struct MACEContext {
/* /// "chomp3()" */
static void chomp3(MACEContext *ctx,
- UINT8 val,
- const UINT16 tab1[],
- const UINT16 tab2[][8])
+ uint8_t val,
+ const uint16_t tab1[],
+ const uint16_t tab2[][8])
{
short current;
@@ -253,13 +259,13 @@ static void chomp3(MACEContext *ctx,
/* /// "Exp1to3()" */
static void Exp1to3(MACEContext *ctx,
- UINT8 *inBuffer,
+ uint8_t *inBuffer,
void *outBuffer,
- UINT32 cnt,
- UINT32 numChannels,
- UINT32 whichChannel)
+ uint32_t cnt,
+ uint32_t numChannels,
+ uint32_t whichChannel)
{
- UINT8 pkt;
+ uint8_t pkt;
/*
if (inState) {
@@ -298,9 +304,9 @@ static void Exp1to3(MACEContext *ctx,
/* /// "chomp6()" */
static void chomp6(MACEContext *ctx,
- UINT8 val,
- const UINT16 tab1[],
- const UINT16 tab2[][8])
+ uint8_t val,
+ const uint16_t tab1[],
+ const uint16_t tab2[][8])
{
short current;
@@ -335,13 +341,13 @@ static void chomp6(MACEContext *ctx,
/* /// "Exp1to6()" */
static void Exp1to6(MACEContext *ctx,
- UINT8 *inBuffer,
+ uint8_t *inBuffer,
void *outBuffer,
- UINT32 cnt,
- UINT32 numChannels,
- UINT32 whichChannel)
+ uint32_t cnt,
+ uint32_t numChannels,
+ uint32_t whichChannel)
{
- UINT8 pkt;
+ uint8_t pkt;
/*
if (inState) {
@@ -389,7 +395,7 @@ static int mace_decode_init(AVCodecContext * avctx)
static int mace_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
short *samples;
MACEContext *c = avctx->priv_data;
diff --git a/src/libffmpeg/libavcodec/mdct.c b/src/libffmpeg/libavcodec/mdct.c
index 91a927cb0..a0f567177 100644
--- a/src/libffmpeg/libavcodec/mdct.c
+++ b/src/libffmpeg/libavcodec/mdct.c
@@ -18,8 +18,13 @@
*/
#include "dsputil.h"
-/*
- * init MDCT or IMDCT computation
+/**
+ * @file mdct.c
+ * MDCT/IMDCT transforms.
+ */
+
+/**
+ * init MDCT or IMDCT computation.
*/
int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
{
diff --git a/src/libffmpeg/libavcodec/mem.c b/src/libffmpeg/libavcodec/mem.c
index a36952fd7..c5ca166d3 100644
--- a/src/libffmpeg/libavcodec/mem.c
+++ b/src/libffmpeg/libavcodec/mem.c
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file mem.c
+ * default memory allocator for libavcodec.
+ */
+
#include "avcodec.h"
/* here we can use OS dependant allocation functions */
diff --git a/src/libffmpeg/libavcodec/mjpeg.c b/src/libffmpeg/libavcodec/mjpeg.c
index 8df477afa..135066796 100644
--- a/src/libffmpeg/libavcodec/mjpeg.c
+++ b/src/libffmpeg/libavcodec/mjpeg.c
@@ -20,26 +20,31 @@
* aspecting, new decode_frame mechanism and apple mjpeg-b support
* by Alex Beregszaszi <alex@naxine.org>
*/
+
+/**
+ * @file mjpeg.c
+ * MJPEG encoder and decoder.
+ */
+
//#define DEBUG
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "xineutils.h"
/* use two quantizer tables (one for luminance and one for chrominance) */
/* not yet working */
#undef TWOMATRIXES
typedef struct MJpegContext {
- UINT8 huff_size_dc_luminance[12];
- UINT16 huff_code_dc_luminance[12];
- UINT8 huff_size_dc_chrominance[12];
- UINT16 huff_code_dc_chrominance[12];
-
- UINT8 huff_size_ac_luminance[256];
- UINT16 huff_code_ac_luminance[256];
- UINT8 huff_size_ac_chrominance[256];
- UINT16 huff_code_ac_chrominance[256];
+ uint8_t huff_size_dc_luminance[12];
+ uint16_t huff_code_dc_luminance[12];
+ uint8_t huff_size_dc_chrominance[12];
+ uint16_t huff_code_dc_chrominance[12];
+
+ uint8_t huff_size_ac_luminance[256];
+ uint16_t huff_code_ac_luminance[256];
+ uint8_t huff_size_ac_chrominance[256];
+ uint16_t huff_code_ac_chrominance[256];
} MJpegContext;
/* JPEG marker codes */
@@ -153,19 +158,19 @@ static const unsigned char std_chrominance_quant_tbl[64] = {
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
/* IMPORTANT: these are only valid for 8-bit data precision! */
-static const UINT8 bits_dc_luminance[17] =
+static const uint8_t bits_dc_luminance[17] =
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
-static const UINT8 val_dc_luminance[] =
+static const uint8_t val_dc_luminance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-static const UINT8 bits_dc_chrominance[17] =
+static const uint8_t bits_dc_chrominance[17] =
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
-static const UINT8 val_dc_chrominance[] =
+static const uint8_t val_dc_chrominance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-static const UINT8 bits_ac_luminance[17] =
+static const uint8_t bits_ac_luminance[17] =
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
-static const UINT8 val_ac_luminance[] =
+static const uint8_t val_ac_luminance[] =
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
@@ -189,10 +194,10 @@ static const UINT8 val_ac_luminance[] =
0xf9, 0xfa
};
-static const UINT8 bits_ac_chrominance[17] =
+static const uint8_t bits_ac_chrominance[17] =
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
-static const UINT8 val_ac_chrominance[] =
+static const uint8_t val_ac_chrominance[] =
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
@@ -217,8 +222,8 @@ static const UINT8 val_ac_chrominance[] =
};
/* isn't this function nicer than the one in the libjpeg ? */
-static void build_huffman_codes(UINT8 *huff_size, UINT16 *huff_code,
- const UINT8 *bits_table, const UINT8 *val_table)
+static void build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
+ const uint8_t *bits_table, const uint8_t *val_table)
{
int i, j, k,nb, code, sym;
@@ -246,7 +251,6 @@ int mjpeg_init(MpegEncContext *s)
s->min_qcoeff=-1023;
s->max_qcoeff= 1023;
- s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
/* build all the huffman tables */
build_huffman_codes(m->huff_size_dc_luminance,
@@ -283,7 +287,7 @@ static inline void put_marker(PutBitContext *p, int code)
/* table_class: 0 = DC coef, 1 = AC coefs */
static int put_huffman_table(MpegEncContext *s, int table_class, int table_id,
- const UINT8 *bits_table, const UINT8 *value_table)
+ const uint8_t *bits_table, const uint8_t *value_table)
{
PutBitContext *p = &s->pb;
int n, i;
@@ -307,7 +311,7 @@ static void jpeg_table_header(MpegEncContext *s)
{
PutBitContext *p = &s->pb;
int i, j, size;
- UINT8 *ptr;
+ uint8_t *ptr;
/* quant matrixes */
put_marker(p, DQT);
@@ -350,7 +354,7 @@ static void jpeg_put_comments(MpegEncContext *s)
{
PutBitContext *p = &s->pb;
int size;
- UINT8 *ptr;
+ uint8_t *ptr;
if (s->aspect_ratio_info)
{
@@ -387,15 +391,13 @@ static void jpeg_put_comments(MpegEncContext *s)
}
/* comment */
- if(!ff_bit_exact){
+ if(!(s->flags & CODEC_FLAG_BITEXACT)){
put_marker(p, COM);
flush_put_bits(p);
ptr = pbBufPtr(p);
put_bits(p, 16, 0); /* patched later */
-#define MJPEG_VERSION "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
- put_string(p, MJPEG_VERSION);
- size = strlen(MJPEG_VERSION)+3;
-#undef MJPEG_VERSION
+ put_string(p, LIBAVCODEC_IDENT);
+ size = strlen(LIBAVCODEC_IDENT)+3;
ptr[0] = size >> 8;
ptr[1] = size;
}
@@ -478,7 +480,7 @@ static void escape_FF(MpegEncContext *s, int start)
uint8_t *buf= s->pb.buf + start;
int align= (-(int)(buf))&3;
- XINE_ASSERT((size&7) == 0,"?");
+ assert((size&7) == 0);
size >>= 3;
ff_count=0;
@@ -534,7 +536,7 @@ void mjpeg_picture_trailer(MpegEncContext *s)
put_bits(&s->pb, pad,0xFF>>(8-pad));
flush_put_bits(&s->pb);
- XINE_ASSERT((s->header_bits&7)==0, "?");
+ assert((s->header_bits&7)==0);
escape_FF(s, s->header_bits>>3);
@@ -542,7 +544,7 @@ void mjpeg_picture_trailer(MpegEncContext *s)
}
static inline void mjpeg_encode_dc(MpegEncContext *s, int val,
- UINT8 *huff_size, UINT16 *huff_code)
+ uint8_t *huff_size, uint16_t *huff_code)
{
int mant, nbits;
@@ -573,8 +575,8 @@ static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
int mant, nbits, code, i, j;
int component, dc, run, last_index, val;
MJpegContext *m = s->mjpeg_ctx;
- UINT8 *huff_size_ac;
- UINT16 *huff_code_ac;
+ uint8_t *huff_size_ac;
+ uint16_t *huff_code_ac;
/* DC coef */
component = (n <= 3 ? 0 : n - 4 + 1);
@@ -652,9 +654,9 @@ typedef struct MJpegDecodeContext {
int start_code; /* current start code */
int buffer_size;
- UINT8 *buffer;
+ uint8_t *buffer;
- INT16 quant_matrixes[4][64];
+ int16_t quant_matrixes[4][64];
VLC vlcs[2][4];
int org_width, org_height; /* size given at codec init */
@@ -670,11 +672,11 @@ typedef struct MJpegDecodeContext {
int h_max, v_max; /* maximum h and v counts */
int quant_index[4]; /* quant table index for each component */
int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
- UINT8 *current_picture[MAX_COMPONENTS]; /* picture structure */
+ uint8_t *current_picture[MAX_COMPONENTS]; /* picture structure */
int linesize[MAX_COMPONENTS];
DCTELEM block[64] __align8;
ScanTable scantable;
- void (*idct_put)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
+ void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
int restart_interval;
int restart_count;
@@ -685,11 +687,11 @@ typedef struct MJpegDecodeContext {
static int mjpeg_decode_dht(MJpegDecodeContext *s);
-static void build_vlc(VLC *vlc, const UINT8 *bits_table, const UINT8 *val_table,
+static void build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table,
int nb_codes)
{
- UINT8 huff_size[256];
- UINT16 huff_code[256];
+ uint8_t huff_size[256];
+ uint16_t huff_code[256];
memset(huff_size, 0, sizeof(huff_size));
build_huffman_codes(huff_size, huff_code, bits_table, val_table);
@@ -704,7 +706,7 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
- /* ugly way to get the idct & scantable */
+ /* ugly way to get the idct & scantable FIXME */
memset(&s2, 0, sizeof(MpegEncContext));
s2.flags= avctx->flags;
s2.avctx= avctx;
@@ -714,7 +716,7 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
if (MPV_common_init(&s2) < 0)
return -1;
s->scantable= s2.intra_scantable;
- s->idct_put= s2.idct_put;
+ s->idct_put= s2.dsp.idct_put;
MPV_common_end(&s2);
s->mpeg_enc_ctx_allocated = 0;
@@ -777,8 +779,8 @@ static int mjpeg_decode_dqt(MJpegDecodeContext *s)
static int mjpeg_decode_dht(MJpegDecodeContext *s)
{
int len, index, i, class, n, v, code_max;
- UINT8 bits_table[17];
- UINT8 val_table[256];
+ uint8_t bits_table[17];
+ uint8_t val_table[256];
len = get_bits(&s->gb, 16) - 2;
@@ -929,7 +931,7 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
int nbits, code, i, j, level;
int run, val;
VLC *ac_vlc;
- INT16 *quant_matrix;
+ int16_t *quant_matrix;
/* DC coef */
val = mjpeg_decode_dc(s, dc_index);
@@ -1072,7 +1074,7 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s)
for(mb_y = 0; mb_y < mb_height; mb_y++) {
for(mb_x = 0; mb_x < mb_width; mb_x++) {
for(i=0;i<nb_components;i++) {
- UINT8 *ptr;
+ uint8_t *ptr;
int x, y, c;
n = nb_blocks[i];
c = comp_index[i];
@@ -1263,31 +1265,33 @@ out:
static int mjpeg_decode_com(MJpegDecodeContext *s)
{
- int len, i;
- UINT8 *cbuf;
-
/* XXX: verify len field validity */
- len = get_bits(&s->gb, 16)-2;
- cbuf = av_malloc(len+1);
-
- for (i = 0; i < len; i++)
- cbuf[i] = get_bits(&s->gb, 8);
- if (cbuf[i-1] == '\n')
- cbuf[i-1] = 0;
- else
- cbuf[i] = 0;
-
- printf("mjpeg comment: '%s'\n", cbuf);
+ unsigned int len = get_bits(&s->gb, 16);
+ if (len >= 2 && len < 32768) {
+ /* XXX: any better upper bound */
+ uint8_t *cbuf = av_malloc(len - 1);
+ if (cbuf) {
+ int i;
+ for (i = 0; i < len - 2; i++)
+ cbuf[i] = get_bits(&s->gb, 8);
+ if (i > 0 && cbuf[i-1] == '\n')
+ cbuf[i-1] = 0;
+ else
+ cbuf[i] = 0;
+
+ printf("mjpeg comment: '%s'\n", cbuf);
+
+ /* buggy avid, it puts EOI only at every 10th frame */
+ if (!strcmp(cbuf, "AVID"))
+ {
+ s->buggy_avid = 1;
+ // if (s->first_picture)
+ // printf("mjpeg: workarounding buggy AVID\n");
+ }
- /* buggy avid, it puts EOI only at every 10th frame */
- if (!strcmp(cbuf, "AVID"))
- {
- s->buggy_avid = 1;
-// if (s->first_picture)
-// printf("mjpeg: workarounding buggy AVID\n");
+ av_free(cbuf);
+ }
}
-
- av_free(cbuf);
return 0;
}
@@ -1317,9 +1321,9 @@ static int valid_marker_list[] =
/* return the 8 bit start code value and update the search
state. Return -1 if no start code found */
-static int find_marker(UINT8 **pbuf_ptr, UINT8 *buf_end)
+static int find_marker(uint8_t **pbuf_ptr, uint8_t *buf_end)
{
- UINT8 *buf_ptr;
+ uint8_t *buf_ptr;
unsigned int v, v2;
int val;
#ifdef DEBUG
@@ -1349,10 +1353,10 @@ found:
static int mjpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
MJpegDecodeContext *s = avctx->priv_data;
- UINT8 *buf_end, *buf_ptr;
+ uint8_t *buf_end, *buf_ptr;
int i, start_code;
AVPicture *picture = data;
@@ -1386,12 +1390,12 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
/* unescape buffer of SOS */
if (start_code == SOS)
{
- UINT8 *src = buf_ptr;
- UINT8 *dst = s->buffer;
+ uint8_t *src = buf_ptr;
+ uint8_t *dst = s->buffer;
while (src<buf_end)
{
- UINT8 x = *(src++);
+ uint8_t x = *(src++);
*(dst++) = x;
if (x == 0xff)
@@ -1526,10 +1530,10 @@ the_end:
static int mjpegb_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
MJpegDecodeContext *s = avctx->priv_data;
- UINT8 *buf_end, *buf_ptr;
+ uint8_t *buf_end, *buf_ptr;
int i;
AVPicture *picture = data;
GetBitContext hgb; /* for the header */
diff --git a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
index 14e001316..7a0f9d564 100644
--- a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
+++ b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
@@ -19,7 +19,6 @@
#include "../dsputil.h"
#include "../mpegvideo.h"
-#include "xineutils.h"
#include <mlib_types.h>
#include <mlib_status.h>
@@ -32,7 +31,7 @@
static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoCopyRef_U8_U8_16x16(dest, (uint8_t *)ref, stride);
else
@@ -42,7 +41,7 @@ static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -52,7 +51,7 @@ static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -62,7 +61,7 @@ static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -75,7 +74,7 @@ static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
else
@@ -85,7 +84,7 @@ static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -95,7 +94,7 @@ static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -105,7 +104,7 @@ static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -118,7 +117,7 @@ static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoCopyRefAve_U8_U8_16x16(dest, (uint8_t *)ref, stride);
else
@@ -128,7 +127,7 @@ static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpAveX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -138,7 +137,7 @@ static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpAveY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -148,7 +147,7 @@ static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels16_xy2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpAveXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -161,7 +160,7 @@ static void avg_pixels16_xy2_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
else
@@ -171,7 +170,7 @@ static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -181,7 +180,7 @@ static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -191,7 +190,7 @@ static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
static void avg_pixels8_xy2_mlib (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
- XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height);
+ assert(height == 16 || height == 8);
if (height == 16)
mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
else
@@ -199,10 +198,10 @@ static void avg_pixels8_xy2_mlib (uint8_t * dest, const uint8_t * ref,
}
-static void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
+static void (*put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
-static void add_pixels_clamped_mlib(const DCTELEM *block, UINT8 *pixels, int line_size)
+static void add_pixels_clamped_mlib(const DCTELEM *block, uint8_t *pixels, int line_size)
{
mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
}
@@ -210,13 +209,13 @@ static void add_pixels_clamped_mlib(const DCTELEM *block, UINT8 *pixels, int lin
/* XXX: those functions should be suppressed ASAP when all IDCTs are
converted */
-static void ff_idct_put_mlib(UINT8 *dest, int line_size, DCTELEM *data)
+static void ff_idct_put_mlib(uint8_t *dest, int line_size, DCTELEM *data)
{
mlib_VideoIDCT8x8_S16_S16 (data, data);
put_pixels_clamped(data, dest, line_size);
}
-static void ff_idct_add_mlib(UINT8 *dest, int line_size, DCTELEM *data)
+static void ff_idct_add_mlib(uint8_t *dest, int line_size, DCTELEM *data)
{
mlib_VideoIDCT8x8_S16_S16 (data, data);
mlib_VideoAddBlock_U8_S16(dest, (mlib_s16 *)data, line_size);
diff --git a/src/libffmpeg/libavcodec/motion_est.c b/src/libffmpeg/libavcodec/motion_est.c
index 8d004a7c0..5bc37fa03 100644
--- a/src/libffmpeg/libavcodec/motion_est.c
+++ b/src/libffmpeg/libavcodec/motion_est.c
@@ -20,12 +20,21 @@
*
* new Motion Estimation (X1/EPZS) by Michael Niedermayer <michaelni@gmx.at>
*/
+
+/**
+ * @file motion_est.c
+ * Motion estimation.
+ */
+
#include <stdlib.h>
#include <stdio.h>
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
+//#undef NDEBUG
+//#include <assert.h>
+
#define SQ(a) ((a)*(a))
#define P_LEFT P[1]
@@ -58,8 +67,8 @@ typedef struct Minima{
}Minima;
static int minima_cmp(const void *a, const void *b){
- Minima *da = (Minima *) a;
- Minima *db = (Minima *) b;
+ const Minima *da = (const Minima *) a;
+ const Minima *db = (const Minima *) b;
return da->height - db->height;
}
@@ -173,10 +182,19 @@ if((x) >= xmin && 2*(x) + (dx) <= 2*xmax && (y) >= ymin && 2*(y) + (dy) <= 2*yma
}else{\
int fx = s->me.direct_basis_mv[0][0] + hx;\
int fy = s->me.direct_basis_mv[0][1] + hy;\
- int bx = hx ? fx - s->me.co_located_mv[0][0] : s->me.co_located_mv[0][0]*(time_pb - time_pp)/time_pp;\
- int by = hy ? fy - s->me.co_located_mv[0][1] : s->me.co_located_mv[0][1]*(time_pb - time_pp)/time_pp;\
+ int bx = hx ? fx - s->me.co_located_mv[0][0] : (s->me.co_located_mv[0][0]*(time_pb - time_pp)/time_pp);\
+ int by = hy ? fy - s->me.co_located_mv[0][1] : (s->me.co_located_mv[0][1]*(time_pb - time_pp)/time_pp);\
int fxy= (fx&1) + 2*(fy&1);\
int bxy= (bx&1) + 2*(by&1);\
+ \
+ assert((fx>>1) + 16*s->mb_x >= -16);\
+ assert((fy>>1) + 16*s->mb_y >= -16);\
+ assert((fx>>1) + 16*s->mb_x <= s->width);\
+ assert((fy>>1) + 16*s->mb_y <= s->height);\
+ assert((bx>>1) + 16*s->mb_x >= -16);\
+ assert((by>>1) + 16*s->mb_y >= -16);\
+ assert((bx>>1) + 16*s->mb_x <= s->width);\
+ assert((by>>1) + 16*s->mb_y <= s->height);\
\
hpel_put[0][fxy](s->me.scratchpad, (ref_y ) + (fx>>1) + (fy>>1)*(stride), stride, 16);\
hpel_avg[0][bxy](s->me.scratchpad, (ref2_y) + (bx>>1) + (by>>1)*(stride), stride, 16);\
@@ -229,8 +247,14 @@ if((x) >= xmin && 4*(x) + (dx) <= 4*xmax && (y) >= ymin && 4*(y) + (dy) <= 4*yma
int fxy= (fx&3) + 4*(fy&3);\
int bxy= (bx&3) + 4*(by&3);\
\
- qpel_put[0][fxy](s->me.scratchpad, (ref_y ) + (fx>>2) + (fy>>2)*(stride), stride);\
- qpel_avg[0][bxy](s->me.scratchpad, (ref2_y) + (bx>>2) + (by>>2)*(stride), stride);\
+ qpel_put[1][fxy](s->me.scratchpad , (ref_y ) + (fx>>2) + (fy>>2)*(stride) , stride);\
+ qpel_put[1][fxy](s->me.scratchpad + 8 , (ref_y ) + (fx>>2) + (fy>>2)*(stride) + 8 , stride);\
+ qpel_put[1][fxy](s->me.scratchpad + 8*stride, (ref_y ) + (fx>>2) + (fy>>2)*(stride) + 8*stride, stride);\
+ qpel_put[1][fxy](s->me.scratchpad + 8 + 8*stride, (ref_y ) + (fx>>2) + (fy>>2)*(stride) + 8 + 8*stride, stride);\
+ qpel_avg[1][bxy](s->me.scratchpad , (ref2_y) + (bx>>2) + (by>>2)*(stride) , stride);\
+ qpel_avg[1][bxy](s->me.scratchpad + 8 , (ref2_y) + (bx>>2) + (by>>2)*(stride) + 8 , stride);\
+ qpel_avg[1][bxy](s->me.scratchpad + 8*stride, (ref2_y) + (bx>>2) + (by>>2)*(stride) + 8*stride, stride);\
+ qpel_avg[1][bxy](s->me.scratchpad + 8 + 8*stride, (ref2_y) + (bx>>2) + (by>>2)*(stride) + 8 + 8*stride, stride);\
}\
d = cmp_func(s, s->me.scratchpad, src_y, stride);\
}else\
@@ -369,7 +393,7 @@ void ff_init_me(MpegEncContext *s){
}
}
-static int pix_dev(UINT8 * pix, int line_size, int mean)
+static int pix_dev(uint8_t * pix, int line_size, int mean)
{
int s, i, j;
@@ -404,7 +428,7 @@ static int full_motion_search(MpegEncContext * s,
{
int x1, y1, x2, y2, xx, yy, x, y;
int mx, my, dmin, d;
- UINT8 *pix;
+ uint8_t *pix;
xx = 16 * s->mb_x;
yy = 16 * s->mb_y;
@@ -458,7 +482,7 @@ static int log_motion_search(MpegEncContext * s,
{
int x1, y1, x2, y2, xx, yy, x, y;
int mx, my, dmin, d;
- UINT8 *pix;
+ uint8_t *pix;
xx = s->mb_x << 4;
yy = s->mb_y << 4;
@@ -534,7 +558,7 @@ static int phods_motion_search(MpegEncContext * s,
{
int x1, y1, x2, y2, xx, yy, x, y, lastx, d;
int mx, my, dminx, dminy;
- UINT8 *pix;
+ uint8_t *pix;
xx = s->mb_x << 4;
yy = s->mb_y << 4;
@@ -639,7 +663,7 @@ static inline int sad_hpel_motion_search(MpegEncContext * s,
uint32_t *score_map= s->me.score_map;
const int penalty_factor= s->me.sub_penalty_factor;
int mx, my, xx, yy, dminh;
- UINT8 *pix, *ptr;
+ uint8_t *pix, *ptr;
op_pixels_abs_func pix_abs_x2;
op_pixels_abs_func pix_abs_y2;
op_pixels_abs_func pix_abs_xy2;
@@ -773,18 +797,18 @@ static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4)
}
}
-static inline void get_limits(MpegEncContext *s, int *range, int *xmin, int *ymin, int *xmax, int *ymax, int f_code)
+/**
+ * get fullpel ME search limits.
+ * @param range the approximate search range for the old ME code, unused for EPZS and newer
+ */
+static inline void get_limits(MpegEncContext *s, int *range, int *xmin, int *ymin, int *xmax, int *ymax)
{
- *range = 8 * (1 << (f_code - 1));
- /* XXX: temporary kludge to avoid overflow for msmpeg4 */
- if (s->out_format == FMT_H263 && !s->h263_msmpeg4)
- *range *= 2;
+ if(s->avctx->me_range) *range= s->avctx->me_range >> 1;
+ else *range= 16;
if (s->unrestricted_mv) {
*xmin = -16;
*ymin = -16;
- if (s->h263_plus)
- *range *= 2;
if(s->avctx->codec->id!=CODEC_ID_MPEG4){
*xmax = s->mb_width*16;
*ymax = s->mb_height*16;
@@ -798,6 +822,8 @@ static inline void get_limits(MpegEncContext *s, int *range, int *xmin, int *ymi
*xmax = s->mb_width*16 - 16;
*ymax = s->mb_height*16 - 16;
}
+
+ //FIXME try to limit x/y min/max if me_range is set
}
static inline int h263_mv4_search(MpegEncContext *s, int xmin, int ymin, int xmax, int ymax, int mx, int my, int shift)
@@ -946,7 +972,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int xmin, int ymin, int xma
void ff_estimate_p_frame_motion(MpegEncContext * s,
int mb_x, int mb_y)
{
- UINT8 *pix, *ppix;
+ uint8_t *pix, *ppix;
int sum, varc, vard, mx, my, range, dmin, xx, yy;
int xmin, ymin, xmax, ymax;
int rel_xmin, rel_ymin, rel_xmax, rel_ymax;
@@ -958,13 +984,13 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
Picture * const pic= &s->current_picture;
uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
- XINE_ASSERT(s->quarter_sample==0 || s->quarter_sample==1, "value out of range: %d", s->quarter_sample);
+ assert(s->quarter_sample==0 || s->quarter_sample==1);
s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp);
s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp);
s->me.mb_penalty_factor = get_penalty_factor(s, s->avctx->mb_cmp);
- get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, s->f_code);
+ get_limits(s, &range, &xmin, &ymin, &xmax, &ymax);
rel_xmin= xmin - mb_x*16;
rel_xmax= xmax - mb_x*16;
rel_ymin= ymin - mb_y*16;
@@ -1129,12 +1155,11 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
const int mv_stride= s->mb_width + 2;
const int xy= mb_x + 1 + (mb_y + 1)*mv_stride;
- XINE_ASSERT((s->quarter_sample==0 || s->quarter_sample==1),
- "value out of range: %d", s->quarter_sample);
+ assert(s->quarter_sample==0 || s->quarter_sample==1);
s->me.pre_penalty_factor = get_penalty_factor(s, s->avctx->me_pre_cmp);
- get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, s->f_code);
+ get_limits(s, &range, &xmin, &ymin, &xmax, &ymax);
rel_xmin= xmin - mb_x*16;
rel_xmax= xmax - mb_x*16;
rel_ymin= ymin - mb_y*16;
@@ -1176,7 +1201,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
return dmin;
}
-int ff_estimate_motion_b(MpegEncContext * s,
+static int ff_estimate_motion_b(MpegEncContext * s,
int mb_x, int mb_y, int16_t (*mv_table)[2], Picture *picture, int f_code)
{
int mx, my, range, dmin;
@@ -1195,7 +1220,7 @@ int ff_estimate_motion_b(MpegEncContext * s,
s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp);
s->me.mb_penalty_factor = get_penalty_factor(s, s->avctx->mb_cmp);
- get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, f_code);
+ get_limits(s, &range, &xmin, &ymin, &xmax, &ymax);
rel_xmin= xmin - mb_x*16;
rel_xmax= xmax - mb_x*16;
rel_ymin= ymin - mb_y*16;
@@ -1285,7 +1310,7 @@ static inline int check_bidir_mv(MpegEncContext * s,
//FIXME optimize?
//FIXME move into template?
//FIXME better f_code prediction (max mv & distance)
- UINT16 *mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
+ uint16_t *mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
uint8_t *dest_y = s->me.scratchpad;
uint8_t *ptr;
int dxy;
@@ -1296,8 +1321,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
src_x = mb_x * 16 + (motion_fx >> 2);
src_y = mb_y * 16 + (motion_fy >> 2);
- XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width);
- XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height);
+ assert(src_x >=-16 && src_x<=s->width);
+ assert(src_y >=-16 && src_y<=s->height);
ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.put_qpel_pixels_tab[0][dxy](dest_y , ptr , s->linesize);
@@ -1305,8 +1330,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
src_x = mb_x * 16 + (motion_bx >> 2);
src_y = mb_y * 16 + (motion_by >> 2);
- XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width);
- XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height);
+ assert(src_x >=-16 && src_x<=s->width);
+ assert(src_y >=-16 && src_y<=s->height);
ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.avg_qpel_pixels_tab[0][dxy](dest_y , ptr , s->linesize);
@@ -1314,8 +1339,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
src_x = mb_x * 16 + (motion_fx >> 1);
src_y = mb_y * 16 + (motion_fy >> 1);
- XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width);
- XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height);
+ assert(src_x >=-16 && src_x<=s->width);
+ assert(src_y >=-16 && src_y<=s->height);
ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
@@ -1323,8 +1348,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
src_x = mb_x * 16 + (motion_bx >> 1);
src_y = mb_y * 16 + (motion_by >> 1);
- XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width);
- XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height);
+ assert(src_x >=-16 && src_x<=s->width);
+ assert(src_y >=-16 && src_y<=s->height);
ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
@@ -1404,24 +1429,22 @@ static inline int direct_search(MpegEncContext * s,
max= FFMAX(s->me.direct_basis_mv[i][0], s->me.direct_basis_mv[i][0] - s->me.co_located_mv[i][0])>>shift;
min= FFMIN(s->me.direct_basis_mv[i][0], s->me.direct_basis_mv[i][0] - s->me.co_located_mv[i][0])>>shift;
- max+= (2*mb_x + (i& 1))*8 - 1; // +-1 is for the simpler rounding
- min+= (2*mb_x + (i& 1))*8 + 1;
+ max+= (2*mb_x + (i& 1))*8 + 1; // +-1 is for the simpler rounding
+ min+= (2*mb_x + (i& 1))*8 - 1;
xmax= FFMIN(xmax, s->width - max);
xmin= FFMAX(xmin, - 16 - min);
max= FFMAX(s->me.direct_basis_mv[i][1], s->me.direct_basis_mv[i][1] - s->me.co_located_mv[i][1])>>shift;
min= FFMIN(s->me.direct_basis_mv[i][1], s->me.direct_basis_mv[i][1] - s->me.co_located_mv[i][1])>>shift;
- max+= (2*mb_y + (i>>1))*8 - 1; // +-1 is for the simpler rounding
- min+= (2*mb_y + (i>>1))*8 + 1;
+ max+= (2*mb_y + (i>>1))*8 + 1; // +-1 is for the simpler rounding
+ min+= (2*mb_y + (i>>1))*8 - 1;
ymax= FFMIN(ymax, s->height - max);
ymin= FFMAX(ymin, - 16 - min);
if(s->mv_type == MV_TYPE_16X16) break;
}
- XINE_ASSERT(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16,
- "xmax (%d) > 15\nymax (%d) >15\nxmin (%d) < -16\nymin (%d) < -16",
- xmax, ymax, xmin, ymin);
+ assert(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);
if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){
s->b_direct_mv_table[mot_xy][0]= 0;
@@ -1484,12 +1507,13 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor;
//printf("%d %d %d %d\n", dmin, fmin, bmin, fbmin);
{
- int score= dmin;
- type=MB_TYPE_DIRECT;
+ int score= fmin;
+ type = MB_TYPE_FORWARD;
- if(fmin<score){
- score=fmin;
- type= MB_TYPE_FORWARD;
+ // RAL: No MB_TYPE_DIRECT in MPEG-1 video (only MPEG-4)
+ if (s->codec_id != CODEC_ID_MPEG1VIDEO && dmin <= score){
+ score = dmin;
+ type = MB_TYPE_DIRECT;
}
if(bmin<score){
score=bmin;
@@ -1519,7 +1543,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
if(s->me_method>=ME_EPZS){
int score[8];
int i, y;
- UINT8 * fcode_tab= s->fcode_tab;
+ uint8_t * fcode_tab= s->fcode_tab;
int best_fcode=-1;
int best_score=-10000000;
@@ -1567,10 +1591,14 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
void ff_fix_long_p_mvs(MpegEncContext * s)
{
const int f_code= s->f_code;
- int y;
- UINT8 * fcode_tab= s->fcode_tab;
-//int clip=0;
-//int noclip=0;
+ int y, range;
+
+ range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code);
+
+ if(s->msmpeg4_version) range= 16;
+
+ if(s->avctx->me_range && range > s->avctx->me_range) range= s->avctx->me_range;
+
/* clip / convert to intra 16x16 type MVs */
for(y=0; y<s->mb_height; y++){
int x;
@@ -1578,10 +1606,8 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
int i= y*s->mb_width;
for(x=0; x<s->mb_width; x++){
if(s->mb_type[i]&MB_TYPE_INTER){
- if( fcode_tab[s->p_mv_table[xy][0] + MAX_MV] > f_code
- || fcode_tab[s->p_mv_table[xy][0] + MAX_MV] == 0
- || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] > f_code
- || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] == 0 ){
+ if( s->p_mv_table[xy][0] >=range || s->p_mv_table[xy][0] <-range
+ || s->p_mv_table[xy][1] >=range || s->p_mv_table[xy][1] <-range){
s->mb_type[i] &= ~MB_TYPE_INTER;
s->mb_type[i] |= MB_TYPE_INTRA;
s->p_mv_table[xy][0] = 0;
@@ -1613,10 +1639,8 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
int mx= s->motion_val[ xy + off ][0];
int my= s->motion_val[ xy + off ][1];
- if( fcode_tab[mx + MAX_MV] > f_code
- || fcode_tab[mx + MAX_MV] == 0
- || fcode_tab[my + MAX_MV] > f_code
- || fcode_tab[my + MAX_MV] == 0 ){
+ if( mx >=range || mx <-range
+ || my >=range || my <-range){
s->mb_type[i] &= ~MB_TYPE_INTER4V;
s->mb_type[i] |= MB_TYPE_INTRA;
}
@@ -1632,7 +1656,11 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, int type)
{
int y;
- UINT8 * fcode_tab= s->fcode_tab;
+
+ // RAL: 8 in MPEG-1, 16 in MPEG-4
+ int range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code);
+
+ if(s->avctx->me_range && range > s->avctx->me_range) range= s->avctx->me_range;
/* clip / convert to intra 16x16 type MVs */
for(y=0; y<s->mb_height; y++){
@@ -1640,15 +1668,18 @@ void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, i
int xy= (y+1)* (s->mb_width+2)+1;
int i= y*s->mb_width;
for(x=0; x<s->mb_width; x++){
- if( fcode_tab[mv_table[xy][0] + MAX_MV] > f_code
- || fcode_tab[mv_table[xy][0] + MAX_MV] == 0){
- if(mv_table[xy][0]>0) mv_table[xy][0]= (16<<f_code)-1;
- else mv_table[xy][0]= -(16<<f_code);
- }
- if( fcode_tab[mv_table[xy][1] + MAX_MV] > f_code
- || fcode_tab[mv_table[xy][1] + MAX_MV] == 0){
- if(mv_table[xy][1]>0) mv_table[xy][1]= (16<<f_code)-1;
- else mv_table[xy][1]= -(16<<f_code);
+ if (s->mb_type[i] & type){ // RAL: "type" test added...
+ if( mv_table[xy][0] >=range || mv_table[xy][0] <-range
+ || mv_table[xy][1] >=range || mv_table[xy][1] <-range){
+
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO && 0){
+ }else{
+ if (mv_table[xy][0] > range-1) mv_table[xy][0]= range-1;
+ else if(mv_table[xy][0] < -range ) mv_table[xy][0]= -range;
+ if (mv_table[xy][1] > range-1) mv_table[xy][1]= range-1;
+ else if(mv_table[xy][1] < -range ) mv_table[xy][1]= -range;
+ }
+ }
}
xy++;
i++;
diff --git a/src/libffmpeg/libavcodec/motion_est_template.c b/src/libffmpeg/libavcodec/motion_est_template.c
index f1ce615ae..f393fd88a 100644
--- a/src/libffmpeg/libavcodec/motion_est_template.c
+++ b/src/libffmpeg/libavcodec/motion_est_template.c
@@ -17,8 +17,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-
-#include "xineutils.h"
+
+/**
+ * @file motion_est_template.c
+ * Motion estimation template.
+ */
//lets hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...)
//Note, the last line is there to kill these ugly unused var warnings
@@ -121,9 +124,7 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s,
CHECK_HALF_MV(0, 1, mx , my )
CHECK_HALF_MV(1, 1, mx , my )
- XINE_ASSERT((bx >= xmin*2 || bx <= xmax*2 || by >= ymin*2 || by <= ymax*2),
- "bx (%d) is not wihtin range %d to %d.\nby (%d) is not within range %d to %d",
- bx, xmin*2, xmax*2, by, ymin*2, ymax*2);
+ assert(bx >= xmin*2 || bx <= xmax*2 || by >= ymin*2 || by <= ymax*2);
*mx_ptr = bx;
*my_ptr = by;
@@ -187,14 +188,13 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s,
int map_generation= s->me.map_generation;
uint32_t *map= s->me.map;
key= ((my-1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
-
- XINE_ASSERT(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key,"map[%d] != %d",(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1), key );
+ assert(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key);
key= ((my+1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
- XINE_ASSERT(map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key,"map[%d] != %d",(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1), key);
+ assert(map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key);
key= ((my)<<ME_MAP_MV_BITS) + (mx+1) + map_generation;
- XINE_ASSERT(map[(index+1)&(ME_MAP_SIZE-1)] == key, "map[%d] != %d",(index+1)&(ME_MAP_SIZE-1), key);
+ assert(map[(index+1)&(ME_MAP_SIZE-1)] == key);
key= ((my)<<ME_MAP_MV_BITS) + (mx-1) + map_generation;
- XINE_ASSERT(map[(index-1)&(ME_MAP_SIZE-1)] == key, "map[%d] != %d",(index-1)&(ME_MAP_SIZE-1), key);
+ assert(map[(index-1)&(ME_MAP_SIZE-1)] == key);
#endif
if(t<=b){
CHECK_HALF_MV(0, 1, mx ,my-1)
@@ -235,9 +235,7 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s,
}
CHECK_HALF_MV(0, 1, mx , my)
}
- XINE_ASSERT((bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2),
- "bx (%d) is not wihtin range %d to %d.\nby (%d) is not within range %d to %d",
- bx, xmin*2, xmax*2, by, ymin*2, ymax*2);
+ assert(bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2);
}
*mx_ptr = bx;
@@ -267,9 +265,8 @@ static int RENAME(hpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pre
cmp_sub= s->dsp.mb_cmp[size];
chroma_cmp_sub= s->dsp.mb_cmp[size+1];
- XINE_ASSERT(!s->me.skip,"s->me.skip is not NULL");
- XINE_ASSERT((s->avctx->me_sub_cmp != s->avctx->mb_cmp), "s->avctx->me_sub_cmp (%d) != s->avctx->mb_cmp (%d)",
- s->avctx->me_sub_cmp, s->avctx->mb_cmp );
+ assert(!s->me.skip);
+ assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp);
CMP_HPEL(d, mx&1, my&1, mx>>1, my>>1, size);
//FIXME check cbp before adding penalty for (0,0) vector
@@ -397,12 +394,11 @@ static int RENAME(qpel_motion_search)(MpegEncContext * s,
cxy= 2*tl + (cx + cy)/4 - (cx2 + cy2) - 2*c;
- XINE_ASSERT(16*cx2 + 4*cx + 32*c == 32*r, "%d != %d",16*cx2 + 4*cx + 32*c, 32*r);
- XINE_ASSERT(16*cx2 - 4*cx + 32*c == 32*l, "%d != %d",16*cx2 - 4*cx + 32*c, 32*l);
- XINE_ASSERT(16*cy2 + 4*cy + 32*c == 32*b, "%d != %d",16*cy2 + 4*cy + 32*c, 32*b);
- XINE_ASSERT(16*cy2 - 4*cy + 32*c == 32*t, "%d != %d",16*cy2 - 4*cy + 32*c, 32*t);
- XINE_ASSERT(16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c == 32*tl, "%d != %d",
- 16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c, 32*tl);
+ assert(16*cx2 + 4*cx + 32*c == 32*r);
+ assert(16*cx2 - 4*cx + 32*c == 32*l);
+ assert(16*cy2 + 4*cy + 32*c == 32*b);
+ assert(16*cy2 - 4*cy + 32*c == 32*t);
+ assert(16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c == 32*tl);
for(ny= -3; ny <= 3; ny++){
for(nx= -3; nx <= 3; nx++){
@@ -504,9 +500,7 @@ static int RENAME(qpel_motion_search)(MpegEncContext * s,
CHECK_QUARTER_MV(1, 1, mx-1, my )
CHECK_QUARTER_MV(1, 0, mx-1, my )
#endif
- XINE_ASSERT(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4,
- "bx (%d) is not wihtin range %d to %d.\nby (%d) is not within range %d to %d",
- bx, xmin*4, xmax*4, by, ymin*4, ymax*4);
+ assert(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4);
*mx_ptr = bx;
*my_ptr = by;
@@ -537,8 +531,8 @@ static int RENAME(qpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pre
cmp_sub= s->dsp.mb_cmp[size];
chroma_cmp_sub= s->dsp.mb_cmp[size+1];
- XINE_ASSERT(!s->me.skip, "value 's->me.skip' is not NULL");
- XINE_ASSERT(s->avctx->me_sub_cmp != s->avctx->mb_cmp, "%d != %d", s->avctx->me_sub_cmp, s->avctx->mb_cmp );
+ assert(!s->me.skip);
+ assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp);
CMP_QPEL(d, mx&3, my&3, mx>>2, my>>2, size);
//FIXME check cbp before adding penalty for (0,0) vector
@@ -756,7 +750,7 @@ static inline int RENAME(sab_diamond_search)(MpegEncContext * s, int *best, int
if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;
- XINE_ASSERT(j<MAX_SAB_SIZE, "%d >= %d", j, MAX_SAB_SIZE); //max j = number of predictors
+ assert(j<MAX_SAB_SIZE); //max j = number of predictors
minima[j].height= score_map[i];
minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;
diff --git a/src/libffmpeg/libavcodec/mpeg12.c b/src/libffmpeg/libavcodec/mpeg12.c
index 907b141e9..729b2f04f 100644
--- a/src/libffmpeg/libavcodec/mpeg12.c
+++ b/src/libffmpeg/libavcodec/mpeg12.c
@@ -1,5 +1,5 @@
/*
- * MPEG1 encoder / MPEG2 decoder
+ * MPEG1 codec / MPEG2 decoder
* Copyright (c) 2000,2001 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file mpeg12.c
+ * MPEG1 codec / MPEG2 decoder.
+ */
+
//#define DEBUG
#include "avcodec.h"
#include "dsputil.h"
@@ -50,7 +56,7 @@
static void mpeg1_encode_block(MpegEncContext *s,
DCTELEM *block,
int component);
-static void mpeg1_encode_motion(MpegEncContext *s, int val);
+static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code); // RAL: f_code parameter added
static void mpeg1_skip_picture(MpegEncContext *s, int pict_num);
static inline int mpeg1_decode_block_inter(MpegEncContext *s,
DCTELEM *block,
@@ -67,8 +73,8 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
#ifdef CONFIG_ENCODERS
-static UINT16 mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
-static UINT8 fcode_tab[MAX_MV*2+1];
+static uint16_t mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
+static uint8_t fcode_tab[MAX_MV*2+1];
static uint32_t uni_mpeg1_ac_vlc_bits[64*64*2];
static uint8_t uni_mpeg1_ac_vlc_len [64*64*2];
@@ -182,7 +188,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
unsigned int vbv_buffer_size;
unsigned int fps, v;
int n, i;
- UINT64 time_code;
+ uint64_t time_code;
float best_aspect_error= 1E10;
float aspect_ratio= s->avctx->aspect_ratio;
@@ -197,8 +203,10 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
int i, dmin, d;
s->frame_rate_index = 0;
dmin = 0x7fffffff;
- for(i=1;i<9;i++) {
- d = abs(s->frame_rate - frame_rate_tab[i]);
+ for(i=1;i<14;i++) {
+ if(s->avctx->strict_std_compliance >= 0 && i>=9) break;
+
+ d = abs(MPEG1_FRAME_RATE_BASE*(int64_t)s->avctx->frame_rate/s->avctx->frame_rate_base - frame_rate_tab[i]);
if (d < dmin) {
dmin = d;
s->frame_rate_index = i;
@@ -221,7 +229,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 4, s->aspect_ratio_info);
put_bits(&s->pb, 4, s->frame_rate_index);
- v = s->bit_rate / 400;
+ v = (s->bit_rate + 399) / 400;
if (v > 0x3ffff)
v = 0x3ffff;
put_bits(&s->pb, 18, v);
@@ -242,22 +250,22 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
/* time code : we must convert from the real frame rate to a
fake mpeg frame rate in case of low frame rate */
fps = frame_rate_tab[s->frame_rate_index];
- time_code = (INT64)s->fake_picture_number * FRAME_RATE_BASE;
+ time_code = (int64_t)s->fake_picture_number * MPEG1_FRAME_RATE_BASE;
s->gop_picture_number = s->fake_picture_number;
- put_bits(&s->pb, 5, (UINT32)((time_code / (fps * 3600)) % 24));
- put_bits(&s->pb, 6, (UINT32)((time_code / (fps * 60)) % 60));
+ put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
+ put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
put_bits(&s->pb, 1, 1);
- put_bits(&s->pb, 6, (UINT32)((time_code / fps) % 60));
- put_bits(&s->pb, 6, (UINT32)((time_code % fps) / FRAME_RATE_BASE));
+ put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
+ put_bits(&s->pb, 6, (uint32_t)((time_code % fps) / MPEG1_FRAME_RATE_BASE));
put_bits(&s->pb, 1, 1); /* closed gop */
put_bits(&s->pb, 1, 0); /* broken link */
}
- if (s->frame_rate < (24 * FRAME_RATE_BASE) && s->picture_number > 0) {
+ if (s->avctx->frame_rate < (24 * s->avctx->frame_rate_base) && s->picture_number > 0) {
/* insert empty P pictures to slow down to the desired
frame rate. Each fake pictures takes about 20 bytes */
fps = frame_rate_tab[s->frame_rate_index];
- n = (((INT64)s->picture_number * fps) / s->frame_rate) - 1;
+ n = av_rescale((int64_t)s->picture_number * s->avctx->frame_rate_base, fps, s->avctx->frame_rate) / MPEG1_FRAME_RATE_BASE - 1;
while (s->fake_picture_number < n) {
mpeg1_skip_picture(s, s->fake_picture_number -
s->gop_picture_number);
@@ -325,6 +333,7 @@ static void common_init(MpegEncContext *s)
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
+#ifdef CONFIG_ENCODERS
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
{
mpeg1_encode_sequence_header(s);
@@ -332,18 +341,27 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
/* mpeg1 picture header */
put_header(s, PICTURE_START_CODE);
/* temporal reference */
- put_bits(&s->pb, 10, (s->fake_picture_number -
+
+ // RAL: s->picture_number instead of s->fake_picture_number
+ put_bits(&s->pb, 10, (s->picture_number -
s->gop_picture_number) & 0x3ff);
s->fake_picture_number++;
put_bits(&s->pb, 3, s->pict_type);
put_bits(&s->pb, 16, 0xffff); /* non constant bit rate */
- if (s->pict_type == P_TYPE) {
+ // RAL: Forward f_code also needed for B frames
+ if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0); /* half pel coordinates */
put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
}
+ // RAL: Backward f_code necessary for B frames
+ if (s->pict_type == B_TYPE) {
+ put_bits(&s->pb, 1, 0); /* half pel coordinates */
+ put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
+ }
+
put_bits(&s->pb, 1, 0); /* extra bit picture */
/* only one slice */
@@ -368,10 +386,11 @@ void mpeg1_encode_mb(MpegEncContext *s,
cbp |= 1 << (5 - i);
}
- /* skip macroblock, except if first or last macroblock of a slice */
- if ((cbp | motion_x | motion_y) == 0 &&
- (!((mb_x | mb_y) == 0 ||
- (mb_x == s->mb_width - 1 && mb_y == s->mb_height - 1)))) {
+ // RAL: Skipped macroblocks for B frames...
+ if (cbp == 0 && (!((mb_x | mb_y) == 0 || (mb_x == s->mb_width - 1 && mb_y == s->mb_height - 1))) &&
+ ((s->pict_type == P_TYPE && (motion_x | motion_y) == 0) ||
+ (s->pict_type == B_TYPE && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) |
+ ((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) {
s->mb_incr++;
s->qscale -= s->dquant;
s->skip_count++;
@@ -398,18 +417,19 @@ void mpeg1_encode_mb(MpegEncContext *s,
}
s->misc_bits+= get_bits_diff(s);
s->i_count++;
- } else {
- if (s->mb_intra) {
- if(s->dquant && cbp){
- put_bits(&s->pb, 6, 0x01);
- put_bits(&s->pb, 5, s->qscale);
- }else{
- put_bits(&s->pb, 5, 0x03);
- s->qscale -= s->dquant;
- }
- s->misc_bits+= get_bits_diff(s);
- s->i_count++;
- } else {
+ } else if (s->mb_intra) {
+ if(s->dquant && cbp){
+ put_bits(&s->pb, 6, 0x01);
+ put_bits(&s->pb, 5, s->qscale);
+ }else{
+ put_bits(&s->pb, 5, 0x03);
+ s->qscale -= s->dquant;
+ }
+ s->misc_bits+= get_bits_diff(s);
+ s->i_count++;
+ s->last_mv[0][0][0] =
+ s->last_mv[0][0][1] = 0;
+ } else if (s->pict_type == P_TYPE) {
if (cbp != 0) {
if (motion_x == 0 && motion_y == 0) {
if(s->dquant){
@@ -428,21 +448,106 @@ void mpeg1_encode_mb(MpegEncContext *s,
put_bits(&s->pb, 1, 1); /* motion + cbp */
}
s->misc_bits+= get_bits_diff(s);
- mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0]);
- mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1]);
+ mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); // RAL: f_code parameter added
+ mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); // RAL: f_code parameter added
s->mv_bits+= get_bits_diff(s);
put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
}
} else {
put_bits(&s->pb, 3, 1); /* motion only */
- mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0]);
- mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1]);
+ mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); // RAL: f_code parameter added
+ mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); // RAL: f_code parameter added
s->qscale -= s->dquant;
s->mv_bits+= get_bits_diff(s);
}
s->f_count++;
+ } else
+ { // RAL: All the following bloc added for B frames:
+ if (cbp != 0)
+ { // With coded bloc pattern
+ if (s->mv_dir == (MV_DIR_FORWARD | MV_DIR_BACKWARD))
+ { // Bi-directional motion
+ if (s->dquant)
+ { // With QScale
+ put_bits(&s->pb, 5, 2);
+ put_bits(&s->pb, 5, s->qscale);
+ }
+ else // Without QScale
+ put_bits(&s->pb, 2, 3);
+ s->misc_bits += get_bits_diff(s);
+ mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
+ mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ s->f_count++;
+ s->mv_bits += get_bits_diff(s);
+ put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
+ }
+ else if (s->mv_dir == MV_DIR_BACKWARD)
+ { // Backward motion
+ if (s->dquant)
+ { // With QScale
+ put_bits(&s->pb, 6, 2);
+ put_bits(&s->pb, 5, s->qscale);
+ }
+ else // Without QScale
+ put_bits(&s->pb, 3, 3);
+ s->misc_bits += get_bits_diff(s);
+ mpeg1_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ s->mv_bits += get_bits_diff(s);
+ put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
+ }
+ else if (s->mv_dir == MV_DIR_FORWARD)
+ { // Forward motion
+ if (s->dquant)
+ { // With QScale
+ put_bits(&s->pb, 6, 3);
+ put_bits(&s->pb, 5, s->qscale);
+ }
+ else // Without QScale
+ put_bits(&s->pb, 4, 3);
+ s->misc_bits += get_bits_diff(s);
+ mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);
+ s->f_count++;
+ s->mv_bits += get_bits_diff(s);
+ put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
+ }
+ }
+ else
+ { // No coded bloc pattern
+ if (s->mv_dir == (MV_DIR_FORWARD | MV_DIR_BACKWARD))
+ { // Bi-directional motion
+ put_bits(&s->pb, 2, 2); /* backward & forward motion */
+ mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
+ mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ s->f_count++;
+ }
+ else if (s->mv_dir == MV_DIR_BACKWARD)
+ { // Backward motion
+ put_bits(&s->pb, 3, 2); /* backward motion only */
+ mpeg1_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ }
+ else if (s->mv_dir == MV_DIR_FORWARD)
+ { // Forward motion
+ put_bits(&s->pb, 4, 2); /* forward motion only */
+ mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);
+ s->f_count++;
+ }
+ s->qscale -= s->dquant;
+ s->mv_bits += get_bits_diff(s);
+ }
+ // End of bloc from RAL
}
- }
for(i=0;i<6;i++) {
if (cbp & (1 << (5 - i))) {
mpeg1_encode_block(s, block[i], i);
@@ -454,11 +559,22 @@ void mpeg1_encode_mb(MpegEncContext *s,
else
s->p_tex_bits+= get_bits_diff(s);
}
- s->last_mv[0][0][0] = motion_x;
- s->last_mv[0][0][1] = motion_y;
+
+ // RAL: By this:
+ if (s->mv_dir & MV_DIR_FORWARD)
+ {
+ s->last_mv[0][0][0]= s->mv[0][0][0];
+ s->last_mv[0][0][1]= s->mv[0][0][1];
+ }
+ if (s->mv_dir & MV_DIR_BACKWARD)
+ {
+ s->last_mv[1][0][0]= s->mv[1][0][0];
+ s->last_mv[1][0][1]= s->mv[1][0][1];
+ }
}
-static void mpeg1_encode_motion(MpegEncContext *s, int val)
+// RAL: Parameter added: f_or_b_code
+static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code)
{
int code, bit_size, l, m, bits, range, sign;
@@ -469,7 +585,7 @@ static void mpeg1_encode_motion(MpegEncContext *s, int val)
mbMotionVectorTable[0][1],
mbMotionVectorTable[0][0]);
} else {
- bit_size = s->f_code - 1;
+ bit_size = f_or_b_code - 1;
range = 1 << bit_size;
/* modulo encoding */
l = 16 * range;
@@ -492,9 +608,13 @@ static void mpeg1_encode_motion(MpegEncContext *s, int val)
bits = val & (range - 1);
sign = 1;
}
+
+ assert(code > 0 && code <= 16);
+
put_bits(&s->pb,
mbMotionVectorTable[code][1],
mbMotionVectorTable[code][0]);
+
put_bits(&s->pb, 1, sign);
if (bit_size > 0) {
put_bits(&s->pb, bit_size, bits);
@@ -504,7 +624,6 @@ static void mpeg1_encode_motion(MpegEncContext *s, int val)
void ff_mpeg1_encode_init(MpegEncContext *s)
{
-#if 0
static int done=0;
common_init(s);
@@ -583,11 +702,8 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
s->fcode_tab= fcode_tab;
s->min_qcoeff=-255;
s->max_qcoeff= 255;
- s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
- s->inter_quant_bias= 0;
s->intra_ac_vlc_length=
s->inter_ac_vlc_length= uni_mpeg1_ac_vlc_len;
-#endif
}
static inline void encode_dc(MpegEncContext *s, int diff, int component)
@@ -628,7 +744,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
it is handled slightly differently */
level = block[0];
if (abs(level) == 1) {
- code = ((UINT32)level >> 31); /* the sign bit */
+ code = ((uint32_t)level >> 31); /* the sign bit */
put_bits(&s->pb, 2, code | 0x02);
i = 1;
} else {
@@ -683,6 +799,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
/* end of block */
put_bits(&s->pb, 2, 0x2);
}
+#endif //CONFIG_ENCODERS
/******************************************/
/* decoding */
@@ -769,7 +886,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
- XINE_ASSERT(s->mb_skiped==0, "s->mp_skiped is not 0: %d", s->mb_skiped);
+ assert(s->mb_skiped==0);
if (--s->mb_incr != 0) {
/* skip mb */
@@ -912,8 +1029,8 @@ static int mpeg_decode_mb(MpegEncContext *s,
}
break;
case MT_FIELD:
+ s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
- s->mv_type = MV_TYPE_FIELD;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
@@ -928,7 +1045,6 @@ static int mpeg_decode_mb(MpegEncContext *s,
dprintf("fmy=%d\n", val);
}
} else {
- s->mv_type = MV_TYPE_16X16;
s->field_select[i][0] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
@@ -1099,8 +1215,8 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
int level, dc, diff, i, j, run;
int component;
RLTable *rl = &rl_mpeg1;
- UINT8 * const scantable= s->intra_scantable.permutated;
- const UINT16 *quant_matrix= s->intra_matrix;
+ uint8_t * const scantable= s->intra_scantable.permutated;
+ const uint16_t *quant_matrix= s->intra_matrix;
const int qscale= s->qscale;
/* DC coef */
@@ -1171,8 +1287,8 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
{
int level, i, j, run;
RLTable *rl = &rl_mpeg1;
- UINT8 * const scantable= s->intra_scantable.permutated;
- const UINT16 *quant_matrix= s->inter_matrix;
+ uint8_t * const scantable= s->intra_scantable.permutated;
+ const uint16_t *quant_matrix= s->inter_matrix;
const int qscale= s->qscale;
{
@@ -1249,8 +1365,8 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
{
int level, i, j, run;
RLTable *rl = &rl_mpeg1;
- UINT8 * const scantable= s->intra_scantable.permutated;
- const UINT16 *quant_matrix;
+ uint8_t * const scantable= s->intra_scantable.permutated;
+ const uint16_t *quant_matrix;
const int qscale= s->qscale;
int mismatch;
@@ -1329,8 +1445,8 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
int level, dc, diff, i, j, run;
int component;
RLTable *rl;
- UINT8 * const scantable= s->intra_scantable.permutated;
- const UINT16 *quant_matrix;
+ uint8_t * const scantable= s->intra_scantable.permutated;
+ const uint16_t *quant_matrix;
const int qscale= s->qscale;
int mismatch;
@@ -1407,10 +1523,10 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
- UINT32 header_state;
+ uint32_t header_state;
int start_code; /* current start code */
- UINT8 buffer[PICTURE_BUFFER_SIZE];
- UINT8 *buf_ptr;
+ uint8_t buffer[PICTURE_BUFFER_SIZE];
+ uint8_t *buf_ptr;
int buffer_size;
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
@@ -1437,10 +1553,10 @@ static int mpeg_decode_init(AVCodecContext *avctx)
/* return the 8 bit start code value and update the search
state. Return -1 if no start code found */
-static int find_start_code(UINT8 **pbuf_ptr, UINT8 *buf_end,
- UINT32 *header_state)
+static int find_start_code(uint8_t **pbuf_ptr, uint8_t *buf_end,
+ uint32_t *header_state)
{
- UINT8 *buf_ptr;
+ uint8_t *buf_ptr;
unsigned int state, v;
int val;
@@ -1463,7 +1579,7 @@ static int find_start_code(UINT8 **pbuf_ptr, UINT8 *buf_end,
}
static int mpeg1_decode_picture(AVCodecContext *avctx,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
@@ -1522,8 +1638,13 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s)
s->low_delay = get_bits1(&s->gb);
frame_rate_ext_n = get_bits(&s->gb, 2);
frame_rate_ext_d = get_bits(&s->gb, 5);
- if (frame_rate_ext_d >= 1)
- s->frame_rate = (s->frame_rate * frame_rate_ext_n) / frame_rate_ext_d;
+ av_reduce(
+ &s->avctx->frame_rate,
+ &s->avctx->frame_rate_base,
+ frame_rate_tab[s->frame_rate_index] * (frame_rate_ext_n+1),
+ MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d+1),
+ 1<<30);
+
dprintf("sequence extension\n");
s->mpeg2 = 1;
s->avctx->sub_id = 2; /* indicates mpeg2 found */
@@ -1542,7 +1663,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
v = get_bits(&s->gb, 8);
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
}
@@ -1550,7 +1671,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
v = get_bits(&s->gb, 8);
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
@@ -1558,14 +1679,14 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
v = get_bits(&s->gb, 8);
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->chroma_intra_matrix[j] = v;
}
}
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
v = get_bits(&s->gb, 8);
- j= s->idct_permutation[ ff_zigzag_direct[i] ];
+ j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->chroma_inter_matrix[j] = v;
}
}
@@ -1590,6 +1711,13 @@ static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
s->chroma_420_type = get_bits1(&s->gb);
s->progressive_frame = get_bits1(&s->gb);
+ if(s->picture_structure == PICT_FRAME)
+ s->first_field=0;
+ else{
+ s->first_field ^= 1;
+ memset(s->mbskip_table, 0, s->mb_width*s->mb_height);
+ }
+
if(s->alternate_scan){
ff_init_scantable(s, &s->inter_scantable , ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_scantable , ff_alternate_vertical_scan);
@@ -1615,7 +1743,7 @@ static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
}
static void mpeg_decode_extension(AVCodecContext *avctx,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
@@ -1655,11 +1783,12 @@ static void mpeg_decode_extension(AVCodecContext *avctx,
static int mpeg_decode_slice(AVCodecContext *avctx,
AVFrame *pict,
int start_code,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ret;
+ const int field_pic= s->picture_structure != PICT_FRAME;
start_code = (start_code - 1) & 0xff;
if (start_code >= s->mb_height){
@@ -1670,12 +1799,27 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s->last_dc[1] = s->last_dc[0];
s->last_dc[2] = s->last_dc[0];
memset(s->last_mv, 0, sizeof(s->last_mv));
+
/* start frame decoding */
if (s->first_slice) {
- s->first_slice = 0;
+ if(s->first_field || s->picture_structure==PICT_FRAME){
if(MPV_frame_start(s, avctx) < 0)
return DECODE_SLICE_FATAL_ERROR;
-
+ /* first check if we must repeat the frame */
+ s->current_picture.repeat_pict = 0;
+
+ if (s->repeat_first_field) {
+ if (s->progressive_sequence) {
+ if (s->top_field_first)
+ s->current_picture.repeat_pict = 4;
+ else
+ s->current_picture.repeat_pict = 2;
+ } else if (s->progressive_frame) {
+ s->current_picture.repeat_pict = 1;
+ }
+ }
+// printf("%d \n", s->current_picture.repeat_pict);
+
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],
@@ -1684,7 +1828,17 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,
s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :"");
}
+ }else{ //second field
+ int i;
+ for(i=0; i<4; i++){
+ s->current_picture.data[i] = s->current_picture_ptr->data[i];
+ if(s->picture_structure == PICT_BOTTOM_FIELD){
+ s->current_picture.data[i] += s->current_picture_ptr->linesize[i];
+ }
+ }
+ }
}
+ s->first_slice = 0;
init_get_bits(&s->gb, buf, buf_size*8);
@@ -1719,11 +1873,17 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
dprintf("ret=%d\n", ret);
if (ret < 0)
return -1;
-
+
MPV_decode_mb(s, s->block);
if (++s->mb_x >= s->mb_width) {
- ff_draw_horiz_band(s);
+ if(s->picture_structure==PICT_FRAME){
+ ff_draw_horiz_band(s, 16*s->mb_y, 16);
+ }else{
+ if(!s->first_field){
+ ff_draw_horiz_band(s, 32*s->mb_y, 32);
+ }
+ }
s->mb_x = 0;
s->mb_y++;
@@ -1750,7 +1910,7 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
}
}
}
- if(s->mb_y >= s->mb_height){
+ if(s->mb_y<<field_pic >= s->mb_height){
fprintf(stderr, "slice too long\n");
return DECODE_SLICE_ERROR;
}
@@ -1758,10 +1918,9 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
eos: //end of slice
emms_c();
-
+//intf("%d %d %d %d\n", s->mb_y, s->mb_height, s->pict_type, s->picture_number);
/* end of slice reached */
- if (/*s->mb_x == 0 &&*/
- s->mb_y == s->mb_height) {
+ if (s->mb_y<<field_pic == s->mb_height && !s->first_field) {
/* end of image */
if(s->mpeg2)
@@ -1775,7 +1934,7 @@ eos: //end of slice
s->picture_number++;
/* latency of 1 frame for I and P frames */
/* XXX: use another variable than picture_number */
- if (s->last_picture.data[0] == NULL) {
+ if (s->last_picture_ptr == NULL) {
return DECODE_SLICE_OK;
} else {
*pict= *(AVFrame*)&s->last_picture;
@@ -1788,7 +1947,7 @@ eos: //end of slice
}
static int mpeg1_decode_sequence(AVCodecContext *avctx,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
@@ -1827,13 +1986,13 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->avctx = avctx;
avctx->width = width;
avctx->height = height;
- if (s->frame_rate_index >= 9) {
- /* at least give a valid frame rate (some old mpeg1 have this) */
- avctx->frame_rate = 25 * FRAME_RATE_BASE;
- } else {
- avctx->frame_rate = frame_rate_tab[s->frame_rate_index];
- }
- s->frame_rate = avctx->frame_rate;
+ av_reduce(
+ &avctx->frame_rate,
+ &avctx->frame_rate_base,
+ frame_rate_tab[s->frame_rate_index],
+ MPEG1_FRAME_RATE_BASE, //FIXME store in allready reduced form
+ 1<<30
+ );
avctx->bit_rate = s->bit_rate;
if (MPV_common_init(s) < 0)
@@ -1860,7 +2019,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
#endif
} else {
for(i=0;i<64;i++) {
- int j= s->idct_permutation[i];
+ int j= s->dsp.idct_permutation[i];
v = ff_mpeg1_default_intra_matrix[i];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
@@ -1881,7 +2040,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
#endif
} else {
for(i=0;i<64;i++) {
- int j= s->idct_permutation[i];
+ int j= s->dsp.idct_permutation[i];
v = ff_mpeg1_default_non_intra_matrix[i];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
@@ -1898,13 +2057,42 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
return 0;
}
+static void mpeg_decode_user_data(AVCodecContext *avctx,
+ const uint8_t *buf, int buf_size)
+{
+ const uint8_t *p;
+ int len, flags;
+ p = buf;
+ len = buf_size;
+
+ /* we parse the DTG active format information */
+ if (len >= 5 &&
+ p[0] == 'D' && p[1] == 'T' && p[2] == 'G' && p[3] == '1') {
+ flags = p[4];
+ p += 5;
+ len -= 5;
+ if (flags & 0x80) {
+ /* skip event id */
+ if (len < 2)
+ return;
+ p += 2;
+ len -= 2;
+ }
+ if (flags & 0x40) {
+ if (len < 1)
+ return;
+ avctx->dtg_active_format = p[0] & 0x0f;
+ }
+ }
+}
+
/* handle buffering and image synchronisation */
static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
- UINT8 *buf_end, *buf_ptr, *buf_start;
+ uint8_t *buf_end, *buf_ptr, *buf_start;
int len, start_code_found, ret, code, start_code, input_size;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
@@ -1988,12 +2176,16 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
mpeg_decode_extension(avctx,
s->buffer, input_size);
break;
+ case USER_START_CODE:
+ mpeg_decode_user_data(avctx,
+ s->buffer, input_size);
+ break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE) {
/* skip b frames if we dont have reference frames */
- if(s2->last_picture.data[0]==NULL && s2->pict_type==B_TYPE) break;
+ if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break;
/* skip b frames if we are in a hurry */
if(avctx->hurry_up && s2->pict_type==B_TYPE) break;
/* skip everything if we are in a hurry>=5 */
@@ -2001,30 +2193,8 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
ret = mpeg_decode_slice(avctx, picture,
start_code, s->buffer, input_size);
+
if (ret == DECODE_SLICE_EOP) {
- /* got a picture: exit */
- /* first check if we must repeat the frame */
- avctx->repeat_pict = 0;
-#if 0
- if (s2->progressive_frame && s2->repeat_first_field) {
- //fprintf(stderr,"\nRepeat this frame: %d! pict: %d",avctx->frame_number,s2->picture_number);
- //s2->repeat_first_field = 0;
- //s2->progressive_frame = 0;
- if (++s->repeat_field > 2)
- s->repeat_field = 0;
- avctx->repeat_pict = 1;
- }
-#endif
- if (s2->repeat_first_field) {
- if (s2->progressive_sequence) {
- if (s2->top_field_first)
- avctx->repeat_pict = 4;
- else
- avctx->repeat_pict = 2;
- } else if (s2->progressive_frame) {
- avctx->repeat_pict = 1;
- }
- }
*data_size = sizeof(AVPicture);
goto the_end;
}else if(ret<0){
diff --git a/src/libffmpeg/libavcodec/mpeg12data.h b/src/libffmpeg/libavcodec/mpeg12data.h
index 8bf063ec1..16d607067 100644
--- a/src/libffmpeg/libavcodec/mpeg12data.h
+++ b/src/libffmpeg/libavcodec/mpeg12data.h
@@ -1,8 +1,9 @@
-/*
- * MPEG1/2 tables
+/**
+ * @file mpeg12data.h
+ * MPEG1/2 tables.
*/
-const INT16 ff_mpeg1_default_intra_matrix[64] = {
+const int16_t ff_mpeg1_default_intra_matrix[64] = {
8, 16, 19, 22, 26, 27, 29, 34,
16, 16, 22, 24, 27, 29, 34, 37,
19, 22, 26, 27, 29, 34, 34, 38,
@@ -13,7 +14,7 @@ const INT16 ff_mpeg1_default_intra_matrix[64] = {
27, 29, 35, 38, 46, 56, 69, 83
};
-const INT16 ff_mpeg1_default_non_intra_matrix[64] = {
+const int16_t ff_mpeg1_default_non_intra_matrix[64] = {
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
@@ -47,14 +48,14 @@ const unsigned char vlc_dc_table[256] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
-const UINT16 vlc_dc_lum_code[12] = {
+const uint16_t vlc_dc_lum_code[12] = {
0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
};
const unsigned char vlc_dc_lum_bits[12] = {
3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
};
-const UINT16 vlc_dc_chroma_code[12] = {
+const uint16_t vlc_dc_chroma_code[12] = {
0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff,
};
const unsigned char vlc_dc_chroma_bits[12] = {
@@ -62,10 +63,10 @@ const unsigned char vlc_dc_chroma_bits[12] = {
};
/* simple include everything table for dc, first byte is bits number next 3 are code*/
-static UINT32 mpeg1_lum_dc_uni[512];
-static UINT32 mpeg1_chr_dc_uni[512];
+static uint32_t mpeg1_lum_dc_uni[512];
+static uint32_t mpeg1_chr_dc_uni[512];
-static const UINT16 mpeg1_vlc[113][2] = {
+static const uint16_t mpeg1_vlc[113][2] = {
{ 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
{ 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
{ 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 },
@@ -98,7 +99,7 @@ static const UINT16 mpeg1_vlc[113][2] = {
{ 0x2, 2 }, /* EOB */
};
-static const UINT16 mpeg2_vlc[113][2] = {
+static const uint16_t mpeg2_vlc[113][2] = {
{0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
{0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
{0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
@@ -131,7 +132,7 @@ static const UINT16 mpeg2_vlc[113][2] = {
{0x06,4}, /* EOB */
};
-static const INT8 mpeg1_level[111] = {
+static const int8_t mpeg1_level[111] = {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
@@ -148,7 +149,7 @@ static const INT8 mpeg1_level[111] = {
1, 1, 1, 1, 1, 1, 1,
};
-static const INT8 mpeg1_run[111] = {
+static const int8_t mpeg1_run[111] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -165,8 +166,8 @@ static const INT8 mpeg1_run[111] = {
25, 26, 27, 28, 29, 30, 31,
};
-static UINT8 mpeg1_index_run[2][64];
-static INT8 mpeg1_max_level[2][64];
+static uint8_t mpeg1_index_run[2][64];
+static int8_t mpeg1_max_level[2][64];
static RLTable rl_mpeg1 = {
111,
@@ -184,7 +185,7 @@ static RLTable rl_mpeg2 = {
mpeg1_level,
};
-static const UINT8 mbAddrIncrTable[35][2] = {
+static const uint8_t mbAddrIncrTable[35][2] = {
{0x1, 1},
{0x3, 3},
{0x2, 3},
@@ -222,7 +223,7 @@ static const UINT8 mbAddrIncrTable[35][2] = {
{0xf, 11}, /* stuffing */
};
-static const UINT8 mbPatTable[63][2] = {
+static const uint8_t mbPatTable[63][2] = {
{0xb, 5},
{0x9, 5},
{0xd, 6},
@@ -294,7 +295,7 @@ static const UINT8 mbPatTable[63][2] = {
#define MB_FOR 0x08
#define MB_QUANT 0x10
-static const UINT8 table_mb_ptype[32][2] = {
+static const uint8_t table_mb_ptype[32][2] = {
{ 0, 0 }, // 0x00
{ 3, 5 }, // 0x01 MB_INTRA
{ 1, 2 }, // 0x02 MB_PAT
@@ -329,7 +330,7 @@ static const UINT8 table_mb_ptype[32][2] = {
{ 0, 0 }, // 0x1F
};
-static const UINT8 table_mb_btype[32][2] = {
+static const uint8_t table_mb_btype[32][2] = {
{ 0, 0 }, // 0x00
{ 3, 5 }, // 0x01 MB_INTRA
{ 0, 0 }, // 0x02
@@ -364,7 +365,7 @@ static const UINT8 table_mb_btype[32][2] = {
{ 0, 0 }, // 0x1F
};
-static const UINT8 mbMotionVectorTable[17][2] = {
+static const uint8_t mbMotionVectorTable[17][2] = {
{ 0x1, 1 },
{ 0x1, 2 },
{ 0x1, 3 },
@@ -384,26 +385,38 @@ static const UINT8 mbMotionVectorTable[17][2] = {
{ 0xc, 10 },
};
-static const int frame_rate_tab[9] = {
- 0,
- (int)(23.976 * FRAME_RATE_BASE),
- (int)(24 * FRAME_RATE_BASE),
- (int)(25 * FRAME_RATE_BASE),
- (int)(29.97 * FRAME_RATE_BASE),
- (int)(30 * FRAME_RATE_BASE),
- (int)(50 * FRAME_RATE_BASE),
- (int)(59.94 * FRAME_RATE_BASE),
- (int)(60 * FRAME_RATE_BASE),
+#define MPEG1_FRAME_RATE_BASE 1001
+
+static const int frame_rate_tab[16] = {
+ 0,
+ 24000,
+ 24024,
+ 25025,
+ 30000,
+ 30030,
+ 50050,
+ 60000,
+ 60060,
+ // Xing's 15fps: (9)
+ 15015,
+ // libmpeg3's "Unofficial economy rates": (10-13)
+ 5005,
+ 10010,
+ 12012,
+ 15015,
+ // random, just to avoid segfault !never encode these
+ 25025,
+ 25025,
};
-static const UINT8 non_linear_qscale[32] = {
+static const uint8_t non_linear_qscale[32] = {
0, 1, 2, 3, 4, 5, 6, 7,
8,10,12,14,16,18,20,22,
24,28,32,36,40,44,48,52,
56,64,72,80,88,96,104,112,
};
-UINT8 ff_mpeg1_dc_scale_table[128]={ // MN: mpeg2 really can have such large qscales?
+uint8_t ff_mpeg1_dc_scale_table[128]={ // MN: mpeg2 really can have such large qscales?
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
diff --git a/src/libffmpeg/libavcodec/mpeg4data.h b/src/libffmpeg/libavcodec/mpeg4data.h
index 54a280d07..fbaca8d5e 100644
--- a/src/libffmpeg/libavcodec/mpeg4data.h
+++ b/src/libffmpeg/libavcodec/mpeg4data.h
@@ -1,3 +1,8 @@
+/**
+ * @file mpeg4data.h
+ * mpeg4 tables.
+ */
+
// shapes
#define RECT_SHAPE 0
#define BIN_SHAPE 1
@@ -34,19 +39,19 @@
#define VOP_STARTCODE 0x1B6
/* dc encoding for mpeg4 */
-const UINT8 DCtab_lum[13][2] =
+const uint8_t DCtab_lum[13][2] =
{
{3,3}, {3,2}, {2,2}, {2,3}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7},
{1,8}, {1,9}, {1,10}, {1,11},
};
-const UINT8 DCtab_chrom[13][2] =
+const uint8_t DCtab_chrom[13][2] =
{
{3,2}, {2,2}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7}, {1,8},
{1,9}, {1,10}, {1,11}, {1,12},
};
-const UINT16 intra_vlc[103][2] = {
+const uint16_t intra_vlc[103][2] = {
{ 0x2, 2 },
{ 0x6, 3 },{ 0xf, 4 },{ 0xd, 5 },{ 0xc, 5 },
{ 0x15, 6 },{ 0x13, 6 },{ 0x12, 6 },{ 0x17, 7 },
@@ -76,7 +81,7 @@ const UINT16 intra_vlc[103][2] = {
{ 0x5f, 12 },{ 0x3, 7 },
};
-const INT8 intra_level[102] = {
+const int8_t intra_level[102] = {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
@@ -92,7 +97,7 @@ const INT8 intra_level[102] = {
1, 1, 1, 1, 1, 1,
};
-const INT8 intra_run[102] = {
+const int8_t intra_run[102] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -116,17 +121,225 @@ static RLTable rl_intra = {
intra_level,
};
-static const UINT16 sprite_trajectory_tab[15][2] = {
+static const uint16_t inter_rvlc[170][2]={ //note this is identical to the intra rvlc except that its reordered
+{0x0006, 3},{0x0001, 4},{0x0004, 5},{0x001C, 7},
+{0x003C, 8},{0x003D, 8},{0x007C, 9},{0x00FC, 10},
+{0x00FD, 10},{0x01FC, 11},{0x01FD, 11},{0x03FC, 12},
+{0x07FC, 13},{0x07FD, 13},{0x0BFC, 13},{0x0BFD, 13},
+{0x0FFC, 14},{0x0FFD, 14},{0x1FFC, 15},{0x0007, 3},
+{0x000C, 6},{0x005C, 8},{0x007D, 9},{0x017C, 10},
+{0x02FC, 11},{0x03FD, 12},{0x0DFC, 13},{0x17FC, 14},
+{0x17FD, 14},{0x000A, 4},{0x001D, 7},{0x00BC, 9},
+{0x02FD, 11},{0x05FC, 12},{0x1BFC, 14},{0x1BFD, 14},
+{0x0005, 5},{0x005D, 8},{0x017D, 10},{0x05FD, 12},
+{0x0DFD, 13},{0x1DFC, 14},{0x1FFD, 15},{0x0008, 5},
+{0x006C, 8},{0x037C, 11},{0x0EFC, 13},{0x2FFC, 15},
+{0x0009, 5},{0x00BD, 9},{0x037D, 11},{0x0EFD, 13},
+{0x000D, 6},{0x01BC, 10},{0x06FC, 12},{0x1DFD, 14},
+{0x0014, 6},{0x01BD, 10},{0x06FD, 12},{0x2FFD, 15},
+{0x0015, 6},{0x01DC, 10},{0x0F7C, 13},{0x002C, 7},
+{0x01DD, 10},{0x1EFC, 14},{0x002D, 7},{0x03BC, 11},
+{0x0034, 7},{0x077C, 12},{0x006D, 8},{0x0F7D, 13},
+{0x0074, 8},{0x1EFD, 14},{0x0075, 8},{0x1F7C, 14},
+{0x00DC, 9},{0x1F7D, 14},{0x00DD, 9},{0x1FBC, 14},
+{0x00EC, 9},{0x37FC, 15},{0x01EC, 10},{0x01ED, 10},
+{0x01F4, 10},{0x03BD, 11},{0x03DC, 11},{0x03DD, 11},
+{0x03EC, 11},{0x03ED, 11},{0x03F4, 11},{0x077D, 12},
+{0x07BC, 12},{0x07BD, 12},{0x0FBC, 13},{0x0FBD, 13},
+{0x0FDC, 13},{0x0FDD, 13},{0x1FBD, 14},{0x1FDC, 14},
+{0x1FDD, 14},{0x37FD, 15},{0x3BFC, 15},
+{0x000B, 4},{0x0078, 8},{0x03F5, 11},{0x0FEC, 13},
+{0x1FEC, 14},{0x0012, 5},{0x00ED, 9},{0x07DC, 12},
+{0x1FED, 14},{0x3BFD, 15},{0x0013, 5},{0x03F8, 11},
+{0x3DFC, 15},{0x0018, 6},{0x07DD, 12},{0x0019, 6},
+{0x07EC, 12},{0x0022, 6},{0x0FED, 13},{0x0023, 6},
+{0x0FF4, 13},{0x0035, 7},{0x0FF5, 13},{0x0038, 7},
+{0x0FF8, 13},{0x0039, 7},{0x0FF9, 13},{0x0042, 7},
+{0x1FF4, 14},{0x0043, 7},{0x1FF5, 14},{0x0079, 8},
+{0x1FF8, 14},{0x0082, 8},{0x3DFD, 15},{0x0083, 8},
+{0x00F4, 9},{0x00F5, 9},{0x00F8, 9},{0x00F9, 9},
+{0x0102, 9},{0x0103, 9},{0x01F5, 10},{0x01F8, 10},
+{0x01F9, 10},{0x0202, 10},{0x0203, 10},{0x03F9, 11},
+{0x0402, 11},{0x0403, 11},{0x07ED, 12},{0x07F4, 12},
+{0x07F5, 12},{0x07F8, 12},{0x07F9, 12},{0x0802, 12},
+{0x0803, 12},{0x1002, 13},{0x1003, 13},{0x1FF9, 14},
+{0x2002, 14},{0x2003, 14},{0x3EFC, 15},{0x3EFD, 15},
+{0x3F7C, 15},{0x3F7D, 15},{0x0000, 4}
+};
+
+static const uint8_t inter_rvlc_run[169]={
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 2, 2, 2,
+ 2, 2, 2, 2, 3, 3, 3, 3,
+ 3, 3, 3, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 6, 6, 6, 6,
+ 7, 7, 7, 7, 8, 8, 8, 9,
+ 9, 9, 10, 10, 11, 11, 12, 12,
+13, 13, 14, 14, 15, 15, 16, 16,
+17, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38,
+ 0, 0, 0, 0, 0, 1, 1, 1,
+ 1, 1, 2, 2, 2, 3, 3, 4,
+ 4, 5, 5, 6, 6, 7, 7, 8,
+ 8, 9, 9, 10, 10, 11, 11, 12,
+12, 13, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26,
+27, 28, 29, 30, 31, 32, 33, 34,
+35, 36, 37, 38, 39, 40, 41, 42,
+43, 44,
+};
+
+static const uint8_t inter_rvlc_level[169]={
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 1, 2, 3,
+ 4, 5, 6, 7, 1, 2, 3, 4,
+ 5, 6, 7, 1, 2, 3, 4, 5,
+ 1, 2, 3, 4, 1, 2, 3, 4,
+ 1, 2, 3, 4, 1, 2, 3, 1,
+ 2, 3, 1, 2, 1, 2, 1, 2,
+ 1, 2, 1, 2, 1, 2, 1, 2,
+ 1, 2, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 3, 4, 5, 1, 2, 3,
+ 4, 5, 1, 2, 3, 1, 2, 1,
+ 2, 1, 2, 1, 2, 1, 2, 1,
+ 2, 1, 2, 1, 2, 1, 2, 1,
+ 2, 1, 2, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1,
+};
+
+static RLTable rvlc_rl_inter = {
+ 169,
+ 103,
+ inter_rvlc,
+ inter_rvlc_run,
+ inter_rvlc_level,
+};
+
+static const uint16_t intra_rvlc[170][2]={
+{0x0006, 3},{0x0007, 3},{0x000A, 4},{0x0009, 5},
+{0x0014, 6},{0x0015, 6},{0x0034, 7},{0x0074, 8},
+{0x0075, 8},{0x00DD, 9},{0x00EC, 9},{0x01EC, 10},
+{0x01ED, 10},{0x01F4, 10},{0x03EC, 11},{0x03ED, 11},
+{0x03F4, 11},{0x077D, 12},{0x07BC, 12},{0x0FBD, 13},
+{0x0FDC, 13},{0x07BD, 12},{0x0FDD, 13},{0x1FBD, 14},
+{0x1FDC, 14},{0x1FDD, 14},{0x1FFC, 15},{0x0001, 4},
+{0x0008, 5},{0x002D, 7},{0x006C, 8},{0x006D, 8},
+{0x00DC, 9},{0x01DD, 10},{0x03DC, 11},{0x03DD, 11},
+{0x077C, 12},{0x0FBC, 13},{0x1F7D, 14},{0x1FBC, 14},
+{0x0004, 5},{0x002C, 7},{0x00BC, 9},{0x01DC, 10},
+{0x03BC, 11},{0x03BD, 11},{0x0EFD, 13},{0x0F7C, 13},
+{0x0F7D, 13},{0x1EFD, 14},{0x1F7C, 14},{0x0005, 5},
+{0x005C, 8},{0x00BD, 9},{0x037D, 11},{0x06FC, 12},
+{0x0EFC, 13},{0x1DFD, 14},{0x1EFC, 14},{0x1FFD, 15},
+{0x000C, 6},{0x005D, 8},{0x01BD, 10},{0x03FD, 12},
+{0x06FD, 12},{0x1BFD, 14},{0x000D, 6},{0x007D, 9},
+{0x02FC, 11},{0x05FC, 12},{0x1BFC, 14},{0x1DFC, 14},
+{0x001C, 7},{0x017C, 10},{0x02FD, 11},{0x05FD, 12},
+{0x2FFC, 15},{0x001D, 7},{0x017D, 10},{0x037C, 11},
+{0x0DFD, 13},{0x2FFD, 15},{0x003C, 8},{0x01BC, 10},
+{0x0BFD, 13},{0x17FD, 14},{0x003D, 8},{0x01FD, 11},
+{0x0DFC, 13},{0x37FC, 15},{0x007C, 9},{0x03FC, 12},
+{0x00FC, 10},{0x0BFC, 13},{0x00FD, 10},{0x37FD, 15},
+{0x01FC, 11},{0x07FC, 13},{0x07FD, 13},{0x0FFC, 14},
+{0x0FFD, 14},{0x17FC, 14},{0x3BFC, 15},
+{0x000B, 4},{0x0078, 8},{0x03F5, 11},{0x0FEC, 13},
+{0x1FEC, 14},{0x0012, 5},{0x00ED, 9},{0x07DC, 12},
+{0x1FED, 14},{0x3BFD, 15},{0x0013, 5},{0x03F8, 11},
+{0x3DFC, 15},{0x0018, 6},{0x07DD, 12},{0x0019, 6},
+{0x07EC, 12},{0x0022, 6},{0x0FED, 13},{0x0023, 6},
+{0x0FF4, 13},{0x0035, 7},{0x0FF5, 13},{0x0038, 7},
+{0x0FF8, 13},{0x0039, 7},{0x0FF9, 13},{0x0042, 7},
+{0x1FF4, 14},{0x0043, 7},{0x1FF5, 14},{0x0079, 8},
+{0x1FF8, 14},{0x0082, 8},{0x3DFD, 15},{0x0083, 8},
+{0x00F4, 9},{0x00F5, 9},{0x00F8, 9},{0x00F9, 9},
+{0x0102, 9},{0x0103, 9},{0x01F5, 10},{0x01F8, 10},
+{0x01F9, 10},{0x0202, 10},{0x0203, 10},{0x03F9, 11},
+{0x0402, 11},{0x0403, 11},{0x07ED, 12},{0x07F4, 12},
+{0x07F5, 12},{0x07F8, 12},{0x07F9, 12},{0x0802, 12},
+{0x0803, 12},{0x1002, 13},{0x1003, 13},{0x1FF9, 14},
+{0x2002, 14},{0x2003, 14},{0x3EFC, 15},{0x3EFD, 15},
+{0x3F7C, 15},{0x3F7D, 15},{0x0000, 4}
+};
+
+static const uint8_t intra_rvlc_run[169]={
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 4, 4, 4, 4,
+ 4, 4, 5, 5, 5, 5, 5, 5,
+ 6, 6, 6, 6, 6, 7, 7, 7,
+ 7, 7, 8, 8, 8, 8, 9, 9,
+ 9, 9, 10, 10, 11, 11, 12, 12,
+13, 14, 15, 16, 17, 18, 19,
+ 0, 0, 0, 0, 0, 1, 1, 1,
+ 1, 1, 2, 2, 2, 3, 3, 4,
+ 4, 5, 5, 6, 6, 7, 7, 8,
+ 8, 9, 9, 10, 10, 11, 11, 12,
+12, 13, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26,
+27, 28, 29, 30, 31, 32, 33, 34,
+35, 36, 37, 38, 39, 40, 41, 42,
+43, 44,
+};
+
+static const uint8_t intra_rvlc_level[169]={
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13,
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 1, 2, 3, 4,
+ 5, 6, 1, 2, 3, 4, 5, 6,
+ 1, 2, 3, 4, 5, 1, 2, 3,
+ 4, 5, 1, 2, 3, 4, 1, 2,
+ 3, 4, 1, 2, 1, 2, 1, 2,
+ 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 3, 4, 5, 1, 2, 3,
+ 4, 5, 1, 2, 3, 1, 2, 1,
+ 2, 1, 2, 1, 2, 1, 2, 1,
+ 2, 1, 2, 1, 2, 1, 2, 1,
+ 2, 1, 2, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1,
+};
+
+static RLTable rvlc_rl_intra = {
+ 169,
+ 103,
+ intra_rvlc,
+ intra_rvlc_run,
+ intra_rvlc_level,
+};
+
+static const uint16_t sprite_trajectory_tab[15][2] = {
{0x00, 2}, {0x02, 3}, {0x03, 3}, {0x04, 3}, {0x05, 3}, {0x06, 3},
{0x0E, 4}, {0x1E, 5}, {0x3E, 6}, {0x7E, 7}, {0xFE, 8},
{0x1FE, 9},{0x3FE, 10},{0x7FE, 11},{0xFFE, 12},
};
-static const UINT8 mb_type_b_tab[4][2] = {
+static const uint8_t mb_type_b_tab[4][2] = {
{1, 1}, {1, 2}, {1, 3}, {1, 4},
};
-static const UINT16 pixel_aspect[16][2]={
+static const uint16_t pixel_aspect[16][2]={
{0, 0},
{1, 1},
{12, 11},
@@ -146,7 +359,7 @@ static const UINT16 pixel_aspect[16][2]={
};
/* these matrixes will be permuted for the idct */
-const INT16 ff_mpeg4_default_intra_matrix[64] = {
+const int16_t ff_mpeg4_default_intra_matrix[64] = {
8, 17, 18, 19, 21, 23, 25, 27,
17, 18, 19, 21, 23, 25, 27, 28,
20, 21, 22, 23, 24, 26, 28, 30,
@@ -157,7 +370,7 @@ const INT16 ff_mpeg4_default_intra_matrix[64] = {
27, 28, 30, 32, 35, 38, 41, 45,
};
-const INT16 ff_mpeg4_default_non_intra_matrix[64] = {
+const int16_t ff_mpeg4_default_non_intra_matrix[64] = {
16, 17, 18, 19, 20, 21, 22, 23,
17, 18, 19, 20, 21, 22, 23, 24,
18, 19, 20, 21, 22, 23, 24, 25,
@@ -168,15 +381,15 @@ const INT16 ff_mpeg4_default_non_intra_matrix[64] = {
23, 24, 25, 27, 28, 30, 31, 33,
};
-UINT8 ff_mpeg4_y_dc_scale_table[32]={
+uint8_t ff_mpeg4_y_dc_scale_table[32]={
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0, 8, 8, 8, 8,10,12,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,40,42,44,46
};
-UINT8 ff_mpeg4_c_dc_scale_table[32]={
+uint8_t ff_mpeg4_c_dc_scale_table[32]={
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,20,21,22,23,24,25
};
-const UINT16 ff_mpeg4_resync_prefix[8]={
+const uint16_t ff_mpeg4_resync_prefix[8]={
0x7F00, 0x7E00, 0x7C00, 0x7800, 0x7000, 0x6000, 0x4000, 0x0000
};
diff --git a/src/libffmpeg/libavcodec/mpegaudio.h b/src/libffmpeg/libavcodec/mpegaudio.h
index 3381dbed2..7aba13200 100644
--- a/src/libffmpeg/libavcodec/mpegaudio.h
+++ b/src/libffmpeg/libavcodec/mpegaudio.h
@@ -1,4 +1,7 @@
-/* mpeg audio declarations for both encoder and decoder */
+/**
+ * @file mpegaudio.h
+ * mpeg audio declarations for both encoder and decoder.
+ */
/* max frame size, in samples */
#define MPA_FRAME_SIZE 1152
@@ -17,11 +20,11 @@
int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
-extern const UINT16 mpa_bitrate_tab[2][3][15];
-extern const UINT16 mpa_freq_tab[3];
+extern const uint16_t mpa_bitrate_tab[2][3][15];
+extern const uint16_t mpa_freq_tab[3];
extern const unsigned char *alloc_tables[5];
extern const double enwindow[512];
extern const int sblimit_table[5];
extern const int quant_steps[17];
extern const int quant_bits[17];
-extern const INT32 mpa_enwindow[257];
+extern const int32_t mpa_enwindow[257];
diff --git a/src/libffmpeg/libavcodec/mpegaudiodec.c b/src/libffmpeg/libavcodec/mpegaudiodec.c
index 9a066c905..1d1074aa7 100644
--- a/src/libffmpeg/libavcodec/mpegaudiodec.c
+++ b/src/libffmpeg/libavcodec/mpegaudiodec.c
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file mpegaudiodec.c
+ * MPEG Audio decoder.
+ */
+
//#define DEBUG
#include "avcodec.h"
#include "mpegaudio.h"
@@ -42,17 +48,17 @@
#define FRAC_ONE (1 << FRAC_BITS)
-#define MULL(a,b) (((INT64)(a) * (INT64)(b)) >> FRAC_BITS)
-#define MUL64(a,b) ((INT64)(a) * (INT64)(b))
+#define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
+#define MUL64(a,b) ((int64_t)(a) * (int64_t)(b))
#define FIX(a) ((int)((a) * FRAC_ONE))
/* WARNING: only correct for posititive numbers */
#define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
#define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS)
#if FRAC_BITS <= 15
-typedef INT16 MPA_INT;
+typedef int16_t MPA_INT;
#else
-typedef INT32 MPA_INT;
+typedef int32_t MPA_INT;
#endif
/****************/
@@ -61,14 +67,14 @@ typedef INT32 MPA_INT;
#define BACKSTEP_SIZE 512
typedef struct MPADecodeContext {
- UINT8 inbuf1[2][MPA_MAX_CODED_FRAME_SIZE + BACKSTEP_SIZE]; /* input buffer */
+ uint8_t inbuf1[2][MPA_MAX_CODED_FRAME_SIZE + BACKSTEP_SIZE]; /* input buffer */
int inbuf_index;
- UINT8 *inbuf_ptr, *inbuf;
+ uint8_t *inbuf_ptr, *inbuf;
int frame_size;
int free_format_frame_size; /* frame size in case of free format
(zero if currently unknown) */
/* next header (used in free format parsing) */
- UINT32 free_format_next_header;
+ uint32_t free_format_next_header;
int error_protection;
int layer;
int sample_rate;
@@ -80,10 +86,10 @@ typedef struct MPADecodeContext {
int mode;
int mode_ext;
int lsf;
- MPA_INT synth_buf[MPA_MAX_CHANNELS][512 * 2];
+ MPA_INT synth_buf[MPA_MAX_CHANNELS][512 * 2] __attribute__((aligned(16)));
int synth_buf_offset[MPA_MAX_CHANNELS];
- INT32 sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT];
- INT32 mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */
+ int32_t sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT] __attribute__((aligned(16)));
+ int32_t mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */
#ifdef DEBUG
int frame_count;
#endif
@@ -91,22 +97,22 @@ typedef struct MPADecodeContext {
/* layer 3 "granule" */
typedef struct GranuleDef {
- UINT8 scfsi;
+ uint8_t scfsi;
int part2_3_length;
int big_values;
int global_gain;
int scalefac_compress;
- UINT8 block_type;
- UINT8 switch_point;
+ uint8_t block_type;
+ uint8_t switch_point;
int table_select[3];
int subblock_gain[3];
- UINT8 scalefac_scale;
- UINT8 count1table_select;
+ uint8_t scalefac_scale;
+ uint8_t count1table_select;
int region_size[3]; /* number of huffman codes in each region */
int preflag;
int short_start, long_end; /* long/short band indexes */
- UINT8 scale_factors[40];
- INT32 sb_hybrid[SBLIMIT * 18]; /* 576 samples */
+ uint8_t scale_factors[40];
+ int32_t sb_hybrid[SBLIMIT * 18]; /* 576 samples */
} GranuleDef;
#define MODE_EXT_MS_STEREO 2
@@ -115,63 +121,63 @@ typedef struct GranuleDef {
/* layer 3 huffman tables */
typedef struct HuffTable {
int xsize;
- const UINT8 *bits;
- const UINT16 *codes;
+ const uint8_t *bits;
+ const uint16_t *codes;
} HuffTable;
#include "mpegaudiodectab.h"
/* vlc structure for decoding layer 3 huffman tables */
static VLC huff_vlc[16];
-static UINT8 *huff_code_table[16];
+static uint8_t *huff_code_table[16];
static VLC huff_quad_vlc[2];
/* computed from band_size_long */
-static UINT16 band_index_long[9][23];
+static uint16_t band_index_long[9][23];
/* XXX: free when all decoders are closed */
#define TABLE_4_3_SIZE (8191 + 16)
-static INT8 *table_4_3_exp;
+static int8_t *table_4_3_exp;
#if FRAC_BITS <= 15
-static UINT16 *table_4_3_value;
+static uint16_t *table_4_3_value;
#else
-static UINT32 *table_4_3_value;
+static uint32_t *table_4_3_value;
#endif
/* intensity stereo coef table */
-static INT32 is_table[2][16];
-static INT32 is_table_lsf[2][2][16];
-static INT32 csa_table[8][2];
-static INT32 mdct_win[8][36];
+static int32_t is_table[2][16];
+static int32_t is_table_lsf[2][2][16];
+static int32_t csa_table[8][2];
+static int32_t mdct_win[8][36];
/* lower 2 bits: modulo 3, higher bits: shift */
-static UINT16 scale_factor_modshift[64];
+static uint16_t scale_factor_modshift[64];
/* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */
-static INT32 scale_factor_mult[15][3];
+static int32_t scale_factor_mult[15][3];
/* mult table for layer 2 group quantization */
#define SCALE_GEN(v) \
{ FIXR(1.0 * (v)), FIXR(0.7937005259 * (v)), FIXR(0.6299605249 * (v)) }
-static INT32 scale_factor_mult2[3][3] = {
+static int32_t scale_factor_mult2[3][3] = {
SCALE_GEN(4.0 / 3.0), /* 3 steps */
SCALE_GEN(4.0 / 5.0), /* 5 steps */
SCALE_GEN(4.0 / 9.0), /* 9 steps */
};
/* 2^(n/4) */
-static UINT32 scale_factor_mult3[4] = {
+static uint32_t scale_factor_mult3[4] = {
FIXR(1.0),
FIXR(1.18920711500272106671),
FIXR(1.41421356237309504880),
FIXR(1.68179283050742908605),
};
-static MPA_INT window[512];
+static MPA_INT window[512] __attribute__((aligned(16)));
/* layer 1 unscaling */
/* n = number of bits of the mantissa minus 1 */
static inline int l1_unscale(int n, int mant, int scale_factor)
{
int shift, mod;
- INT64 val;
+ int64_t val;
shift = scale_factor_modshift[scale_factor];
mod = shift & 3;
@@ -203,7 +209,7 @@ static inline int l3_unscale(int value, int exponent)
#if FRAC_BITS <= 15
unsigned int m;
#else
- UINT64 m;
+ uint64_t m;
#endif
int e;
@@ -221,7 +227,7 @@ static inline int l3_unscale(int value, int exponent)
return m;
#else
m = MUL64(m, scale_factor_mult3[exponent & 3]);
- m = (m + (UINT64_C(1) << (e-1))) >> e;
+ m = (m + (uint64_t_C(1) << (e-1))) >> e;
return m;
#endif
}
@@ -232,7 +238,7 @@ static inline int l3_unscale(int value, int exponent)
#define POW_FRAC_BITS 24
#define POW_FRAC_ONE (1 << POW_FRAC_BITS)
#define POW_FIX(a) ((int)((a) * POW_FRAC_ONE))
-#define POW_MULL(a,b) (((INT64)(a) * (INT64)(b)) >> POW_FRAC_BITS)
+#define POW_MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> POW_FRAC_BITS)
static int dev_4_3_coefs[DEV_ORDER];
@@ -318,7 +324,7 @@ static int decode_init(AVCodecContext * avctx)
for(i=0;i<15;i++) {
int n, norm;
n = i + 2;
- norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
+ norm = ((int64_t_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm);
scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm);
scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm);
@@ -348,8 +354,9 @@ static int decode_init(AVCodecContext * avctx)
huff_code_table[0] = NULL;
for(i=1;i<16;i++) {
const HuffTable *h = &mpa_huff_tables[i];
- int xsize, n, x, y;
- UINT8 *code_table;
+ int xsize, x, y;
+ unsigned int n;
+ uint8_t *code_table;
xsize = h->xsize;
n = xsize * xsize;
@@ -576,7 +583,7 @@ static int decode_init(AVCodecContext * avctx)
#define ADD(a, b) tab[a] += tab[b]
/* DCT32 without 1/sqrt(2) coef zero scaling. */
-static void dct32(INT32 *out, INT32 *tab)
+static void dct32(int32_t *out, int32_t *tab)
{
int tmp0, tmp1;
@@ -759,7 +766,7 @@ static void dct32(INT32 *out, INT32 *tab)
#define OUT_SAMPLE(sum)\
{\
int sum1;\
- sum1 = (int)((sum + (INT64_C(1) << (OUT_SHIFT - 1))) >> OUT_SHIFT);\
+ sum1 = (int)((sum + (int64_t_C(1) << (OUT_SHIFT - 1))) >> OUT_SHIFT);\
if (sum1 < -32768)\
sum1 = -32768;\
else if (sum1 > 32767)\
@@ -786,17 +793,17 @@ static void dct32(INT32 *out, INT32 *tab)
32 samples. */
/* XXX: optimize by avoiding ring buffer usage */
static void synth_filter(MPADecodeContext *s1,
- int ch, INT16 *samples, int incr,
- INT32 sb_samples[SBLIMIT])
+ int ch, int16_t *samples, int incr,
+ int32_t sb_samples[SBLIMIT])
{
- INT32 tmp[32];
+ int32_t tmp[32];
register MPA_INT *synth_buf, *p;
register MPA_INT *w;
int j, offset, v;
#if FRAC_BITS <= 15
int sum;
#else
- INT64 sum;
+ int64_t sum;
#endif
dct32(tmp, sb_samples);
@@ -862,7 +869,7 @@ static void synth_filter(MPADecodeContext *s1,
static void imdct12(int *out, int *in)
{
int tmp;
- INT64 in1_3, in1_9, in4_3, in4_9;
+ int64_t in1_3, in1_9, in4_3, in4_9;
in1_3 = MUL64(in[1], C3);
in1_9 = MUL64(in[1], C9);
@@ -954,7 +961,7 @@ static void imdct36(int *out, int *in)
{
int i, j, t0, t1, t2, t3, s0, s1, s2, s3;
int tmp[18], *tmp1, *in1;
- INT64 in3_3, in6_6;
+ int64_t in3_3, in6_6;
for(i=17;i>=1;i--)
in[i] += in[i-1];
@@ -1029,7 +1036,7 @@ static void imdct36(int *out, int *in)
}
/* fast header check for resync */
-static int check_header(UINT32 header)
+static int check_header(uint32_t header)
{
/* header */
if ((header & 0xffe00000) != 0xffe00000)
@@ -1053,7 +1060,7 @@ static int check_header(UINT32 header)
/* header decoding. MUST check the header before because no
consistency check is done there. Return 1 if free format found and
that the frame size must be computed externally */
-static int decode_header(MPADecodeContext *s, UINT32 header)
+static int decode_header(MPADecodeContext *s, uint32_t header)
{
int sample_rate, frame_size, mpeg25, padding;
int sample_rate_index, bitrate_index;
@@ -1154,8 +1161,8 @@ static int decode_header(MPADecodeContext *s, UINT32 header)
static int mp_decode_layer1(MPADecodeContext *s)
{
int bound, i, v, n, ch, j, mant;
- UINT8 allocation[MPA_MAX_CHANNELS][SBLIMIT];
- UINT8 scale_factors[MPA_MAX_CHANNELS][SBLIMIT];
+ uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT];
+ uint8_t scale_factors[MPA_MAX_CHANNELS][SBLIMIT];
if (s->mode == MPA_JSTEREO)
bound = (s->mode_ext + 1) * 4;
@@ -1448,9 +1455,9 @@ static int mp_decode_layer2(MPADecodeContext *s)
/*
* Seek back in the stream for backstep bytes (at most 511 bytes)
*/
-static void seek_to_maindata(MPADecodeContext *s, long backstep)
+static void seek_to_maindata(MPADecodeContext *s, unsigned int backstep)
{
- UINT8 *ptr;
+ uint8_t *ptr;
/* compute current position in stream */
ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
@@ -1490,11 +1497,11 @@ static inline void lsf_sf_expand(int *slen,
static void exponents_from_scale_factors(MPADecodeContext *s,
GranuleDef *g,
- INT16 *exponents)
+ int16_t *exponents)
{
- const UINT8 *bstab, *pretab;
+ const uint8_t *bstab, *pretab;
int len, i, j, k, l, v0, shift, gain, gains[3];
- INT16 *exp_ptr;
+ int16_t *exp_ptr;
exp_ptr = exponents;
gain = g->global_gain - 210;
@@ -1536,13 +1543,13 @@ static inline int get_bitsz(GetBitContext *s, int n)
}
static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
- INT16 *exponents, int end_pos)
+ int16_t *exponents, int end_pos)
{
int s_index;
int linbits, code, x, y, l, v, i, j, k, pos;
GetBitContext last_gb;
VLC *vlc;
- UINT8 *code_table;
+ uint8_t *code_table;
/* low frequencies (called big values) */
s_index = 0;
@@ -1641,8 +1648,8 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
static void reorder_block(MPADecodeContext *s, GranuleDef *g)
{
int i, j, k, len;
- INT32 *ptr, *dst, *ptr1;
- INT32 tmp[576];
+ int32_t *ptr, *dst, *ptr1;
+ int32_t tmp[576];
if (g->block_type != 2)
return;
@@ -1667,7 +1674,7 @@ static void reorder_block(MPADecodeContext *s, GranuleDef *g)
dst += 3;
}
}
- memcpy(ptr1, tmp, len * 3 * sizeof(INT32));
+ memcpy(ptr1, tmp, len * 3 * sizeof(int32_t));
}
}
@@ -1677,10 +1684,10 @@ static void compute_stereo(MPADecodeContext *s,
GranuleDef *g0, GranuleDef *g1)
{
int i, j, k, l;
- INT32 v1, v2;
+ int32_t v1, v2;
int sf_max, tmp0, tmp1, sf, len, non_zero_found;
- INT32 (*is_tab)[16];
- INT32 *tab0, *tab1;
+ int32_t (*is_tab)[16];
+ int32_t *tab0, *tab1;
int non_zero_found_short[3];
/* intensity stereo */
@@ -1803,7 +1810,7 @@ static void compute_stereo(MPADecodeContext *s,
static void compute_antialias(MPADecodeContext *s,
GranuleDef *g)
{
- INT32 *ptr, *p0, *p1, *csa;
+ int32_t *ptr, *p0, *p1, *csa;
int n, tmp0, tmp1, i, j;
/* we antialias only "long" bands */
@@ -1836,13 +1843,13 @@ static void compute_antialias(MPADecodeContext *s,
static void compute_imdct(MPADecodeContext *s,
GranuleDef *g,
- INT32 *sb_samples,
- INT32 *mdct_buf)
+ int32_t *sb_samples,
+ int32_t *mdct_buf)
{
- INT32 *ptr, *win, *win1, *buf, *buf2, *out_ptr, *ptr1;
- INT32 in[6];
- INT32 out[36];
- INT32 out2[12];
+ int32_t *ptr, *win, *win1, *buf, *buf2, *out_ptr, *ptr1;
+ int32_t in[6];
+ int32_t out[36];
+ int32_t out2[12];
int i, j, k, mdct_long_end, v, sblimit;
/* find last non zero block */
@@ -1935,12 +1942,12 @@ static void compute_imdct(MPADecodeContext *s,
}
#if defined(DEBUG)
-void sample_dump(int fnum, INT32 *tab, int n)
+void sample_dump(int fnum, int32_t *tab, int n)
{
static FILE *files[16], *f;
char buf[512];
int i;
- INT32 v;
+ int32_t v;
f = files[fnum];
if (!f) {
@@ -1971,7 +1978,7 @@ void sample_dump(int fnum, INT32 *tab, int n)
for(i=0;i<n;i++) {
/* normalize to 23 frac bits */
v = tab[i] << (23 - FRAC_BITS);
- fwrite(&v, 1, sizeof(INT32), f);
+ fwrite(&v, 1, sizeof(int32_t), f);
}
}
#endif
@@ -1983,7 +1990,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
int nb_granules, main_data_begin, private_bits;
int gr, ch, blocksplit_flag, i, j, k, n, bits_pos, bits_left;
GranuleDef granules[2][2], *g;
- INT16 exponents[576];
+ int16_t exponents[576];
/* read side info */
if (s->lsf) {
@@ -2123,7 +2130,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
bits_pos = get_bits_count(&s->gb);
if (!s->lsf) {
- UINT8 *sc;
+ uint8_t *sc;
int slen, slen1, slen2;
/* MPEG1 scale factors */
@@ -2327,11 +2334,11 @@ static int mp_decode_frame(MPADecodeContext *s,
static int decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
- UINT8 * buf, int buf_size)
+ uint8_t * buf, int buf_size)
{
MPADecodeContext *s = avctx->priv_data;
- UINT32 header;
- UINT8 *buf_ptr;
+ uint32_t header;
+ uint8_t *buf_ptr;
int len, out_size;
short *out_samples = data;
@@ -2398,8 +2405,8 @@ static int decode_frame(AVCodecContext * avctx,
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
} else {
- UINT8 *p, *pend;
- UINT32 header1;
+ uint8_t *p, *pend;
+ uint32_t header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
diff --git a/src/libffmpeg/libavcodec/mpegaudiodectab.h b/src/libffmpeg/libavcodec/mpegaudiodectab.h
index 7cec73ebe..8a13127ad 100644
--- a/src/libffmpeg/libavcodec/mpegaudiodectab.h
+++ b/src/libffmpeg/libavcodec/mpegaudiodectab.h
@@ -1,5 +1,9 @@
+/**
+ * @file mpegaudiodectab.h
+ * mpeg audio layer decoder tables.
+ */
-const UINT16 mpa_bitrate_tab[2][3][15] = {
+const uint16_t mpa_bitrate_tab[2][3][15] = {
{ {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
@@ -9,11 +13,11 @@ const UINT16 mpa_bitrate_tab[2][3][15] = {
}
};
-const UINT16 mpa_freq_tab[3] = { 44100, 48000, 32000 };
+const uint16_t mpa_freq_tab[3] = { 44100, 48000, 32000 };
/*******************************************************/
/* half mpeg encoding window (full precision) */
-const INT32 mpa_enwindow[257] = {
+const int32_t mpa_enwindow[257] = {
0, -1, -1, -1, -1, -1, -1, -2,
-2, -2, -2, -3, -3, -4, -4, -5,
-5, -6, -7, -7, -8, -9, -10, -11,
@@ -200,13 +204,13 @@ const unsigned char *alloc_tables[5] =
/* layer 3 tables */
/* layer3 scale factor size */
-static const UINT8 slen_table[2][16] = {
+static const uint8_t slen_table[2][16] = {
{ 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
{ 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 },
};
/* number of lsf scale factors for a given size */
-static const UINT8 lsf_nsf_table[6][3][4] = {
+static const uint8_t lsf_nsf_table[6][3][4] = {
{ { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } },
{ { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } },
{ { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } },
@@ -217,55 +221,55 @@ static const UINT8 lsf_nsf_table[6][3][4] = {
/* mpegaudio layer 3 huffman tables */
-const UINT16 mpa_huffcodes_1[4] = {
+const uint16_t mpa_huffcodes_1[4] = {
0x0001, 0x0001, 0x0001, 0x0000,
};
-const UINT8 mpa_huffbits_1[4] = {
+const uint8_t mpa_huffbits_1[4] = {
1, 3, 2, 3,
};
-const UINT16 mpa_huffcodes_2[9] = {
+const uint16_t mpa_huffcodes_2[9] = {
0x0001, 0x0002, 0x0001, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002,
0x0000,
};
-const UINT8 mpa_huffbits_2[9] = {
+const uint8_t mpa_huffbits_2[9] = {
1, 3, 6, 3, 3, 5, 5, 5,
6,
};
-const UINT16 mpa_huffcodes_3[9] = {
+const uint16_t mpa_huffcodes_3[9] = {
0x0003, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0003, 0x0002,
0x0000,
};
-const UINT8 mpa_huffbits_3[9] = {
+const uint8_t mpa_huffbits_3[9] = {
2, 2, 6, 3, 2, 5, 5, 5,
6,
};
-const UINT16 mpa_huffcodes_5[16] = {
+const uint16_t mpa_huffcodes_5[16] = {
0x0001, 0x0002, 0x0006, 0x0005, 0x0003, 0x0001, 0x0004, 0x0004,
0x0007, 0x0005, 0x0007, 0x0001, 0x0006, 0x0001, 0x0001, 0x0000,
};
-const UINT8 mpa_huffbits_5[16] = {
+const uint8_t mpa_huffbits_5[16] = {
1, 3, 6, 7, 3, 3, 6, 7,
6, 6, 7, 8, 7, 6, 7, 8,
};
-const UINT16 mpa_huffcodes_6[16] = {
+const uint16_t mpa_huffcodes_6[16] = {
0x0007, 0x0003, 0x0005, 0x0001, 0x0006, 0x0002, 0x0003, 0x0002,
0x0005, 0x0004, 0x0004, 0x0001, 0x0003, 0x0003, 0x0002, 0x0000,
};
-const UINT8 mpa_huffbits_6[16] = {
+const uint8_t mpa_huffbits_6[16] = {
3, 3, 5, 7, 3, 2, 4, 5,
4, 4, 5, 6, 6, 5, 6, 7,
};
-const UINT16 mpa_huffcodes_7[36] = {
+const uint16_t mpa_huffcodes_7[36] = {
0x0001, 0x0002, 0x000a, 0x0013, 0x0010, 0x000a, 0x0003, 0x0003,
0x0007, 0x000a, 0x0005, 0x0003, 0x000b, 0x0004, 0x000d, 0x0011,
0x0008, 0x0004, 0x000c, 0x000b, 0x0012, 0x000f, 0x000b, 0x0002,
@@ -273,7 +277,7 @@ const UINT16 mpa_huffcodes_7[36] = {
0x0005, 0x0003, 0x0002, 0x0000,
};
-const UINT8 mpa_huffbits_7[36] = {
+const uint8_t mpa_huffbits_7[36] = {
1, 3, 6, 8, 8, 9, 3, 4,
6, 7, 7, 8, 6, 5, 7, 8,
8, 9, 7, 7, 8, 9, 9, 9,
@@ -281,7 +285,7 @@ const UINT8 mpa_huffbits_7[36] = {
9, 10, 10, 10,
};
-const UINT16 mpa_huffcodes_8[36] = {
+const uint16_t mpa_huffcodes_8[36] = {
0x0003, 0x0004, 0x0006, 0x0012, 0x000c, 0x0005, 0x0005, 0x0001,
0x0002, 0x0010, 0x0009, 0x0003, 0x0007, 0x0003, 0x0005, 0x000e,
0x0007, 0x0003, 0x0013, 0x0011, 0x000f, 0x000d, 0x000a, 0x0004,
@@ -289,7 +293,7 @@ const UINT16 mpa_huffcodes_8[36] = {
0x0004, 0x0001, 0x0001, 0x0000,
};
-const UINT8 mpa_huffbits_8[36] = {
+const uint8_t mpa_huffbits_8[36] = {
2, 3, 6, 8, 8, 9, 3, 2,
4, 8, 8, 8, 6, 4, 6, 8,
8, 9, 8, 8, 8, 9, 9, 10,
@@ -297,7 +301,7 @@ const UINT8 mpa_huffbits_8[36] = {
9, 9, 11, 11,
};
-const UINT16 mpa_huffcodes_9[36] = {
+const uint16_t mpa_huffcodes_9[36] = {
0x0007, 0x0005, 0x0009, 0x000e, 0x000f, 0x0007, 0x0006, 0x0004,
0x0005, 0x0005, 0x0006, 0x0007, 0x0007, 0x0006, 0x0008, 0x0008,
0x0008, 0x0005, 0x000f, 0x0006, 0x0009, 0x000a, 0x0005, 0x0001,
@@ -305,7 +309,7 @@ const UINT16 mpa_huffcodes_9[36] = {
0x0006, 0x0002, 0x0006, 0x0000,
};
-const UINT8 mpa_huffbits_9[36] = {
+const uint8_t mpa_huffbits_9[36] = {
3, 3, 5, 6, 8, 9, 3, 3,
4, 5, 6, 8, 4, 4, 5, 6,
7, 8, 6, 5, 6, 7, 7, 8,
@@ -313,7 +317,7 @@ const UINT8 mpa_huffbits_9[36] = {
8, 8, 9, 9,
};
-const UINT16 mpa_huffcodes_10[64] = {
+const uint16_t mpa_huffcodes_10[64] = {
0x0001, 0x0002, 0x000a, 0x0017, 0x0023, 0x001e, 0x000c, 0x0011,
0x0003, 0x0003, 0x0008, 0x000c, 0x0012, 0x0015, 0x000c, 0x0007,
0x000b, 0x0009, 0x000f, 0x0015, 0x0020, 0x0028, 0x0013, 0x0006,
@@ -324,7 +328,7 @@ const UINT16 mpa_huffcodes_10[64] = {
0x0009, 0x0008, 0x0007, 0x0008, 0x0004, 0x0004, 0x0002, 0x0000,
};
-const UINT8 mpa_huffbits_10[64] = {
+const uint8_t mpa_huffbits_10[64] = {
1, 3, 6, 8, 9, 9, 9, 10,
3, 4, 6, 7, 8, 9, 8, 8,
6, 6, 7, 8, 9, 10, 9, 9,
@@ -335,7 +339,7 @@ const UINT8 mpa_huffbits_10[64] = {
9, 8, 9, 10, 10, 11, 11, 11,
};
-const UINT16 mpa_huffcodes_11[64] = {
+const uint16_t mpa_huffcodes_11[64] = {
0x0003, 0x0004, 0x000a, 0x0018, 0x0022, 0x0021, 0x0015, 0x000f,
0x0005, 0x0003, 0x0004, 0x000a, 0x0020, 0x0011, 0x000b, 0x000a,
0x000b, 0x0007, 0x000d, 0x0012, 0x001e, 0x001f, 0x0014, 0x0005,
@@ -346,7 +350,7 @@ const UINT16 mpa_huffcodes_11[64] = {
0x000b, 0x0004, 0x0006, 0x0006, 0x0006, 0x0003, 0x0002, 0x0000,
};
-const UINT8 mpa_huffbits_11[64] = {
+const uint8_t mpa_huffbits_11[64] = {
2, 3, 5, 7, 8, 9, 8, 9,
3, 3, 4, 6, 8, 8, 7, 8,
5, 5, 6, 7, 8, 9, 8, 8,
@@ -357,7 +361,7 @@ const UINT8 mpa_huffbits_11[64] = {
8, 7, 8, 9, 10, 10, 10, 10,
};
-const UINT16 mpa_huffcodes_12[64] = {
+const uint16_t mpa_huffcodes_12[64] = {
0x0009, 0x0006, 0x0010, 0x0021, 0x0029, 0x0027, 0x0026, 0x001a,
0x0007, 0x0005, 0x0006, 0x0009, 0x0017, 0x0010, 0x001a, 0x000b,
0x0011, 0x0007, 0x000b, 0x000e, 0x0015, 0x001e, 0x000a, 0x0007,
@@ -368,7 +372,7 @@ const UINT16 mpa_huffcodes_12[64] = {
0x001b, 0x000c, 0x0008, 0x000c, 0x0006, 0x0003, 0x0001, 0x0000,
};
-const UINT8 mpa_huffbits_12[64] = {
+const uint8_t mpa_huffbits_12[64] = {
4, 3, 5, 7, 8, 9, 9, 9,
3, 3, 4, 5, 7, 7, 8, 8,
5, 4, 5, 6, 7, 8, 7, 8,
@@ -379,7 +383,7 @@ const UINT8 mpa_huffbits_12[64] = {
9, 8, 8, 9, 9, 9, 9, 10,
};
-const UINT16 mpa_huffcodes_13[256] = {
+const uint16_t mpa_huffcodes_13[256] = {
0x0001, 0x0005, 0x000e, 0x0015, 0x0022, 0x0033, 0x002e, 0x0047,
0x002a, 0x0034, 0x0044, 0x0034, 0x0043, 0x002c, 0x002b, 0x0013,
0x0003, 0x0004, 0x000c, 0x0013, 0x001f, 0x001a, 0x002c, 0x0021,
@@ -414,7 +418,7 @@ const UINT16 mpa_huffcodes_13[256] = {
0x0011, 0x000c, 0x0010, 0x0008, 0x0001, 0x0001, 0x0000, 0x0001,
};
-const UINT8 mpa_huffbits_13[256] = {
+const uint8_t mpa_huffbits_13[256] = {
1, 4, 6, 7, 8, 9, 9, 10,
9, 10, 11, 11, 12, 12, 13, 13,
3, 4, 6, 7, 8, 8, 9, 9,
@@ -449,7 +453,7 @@ const UINT8 mpa_huffbits_13[256] = {
15, 15, 16, 16, 19, 18, 19, 16,
};
-const UINT16 mpa_huffcodes_15[256] = {
+const uint16_t mpa_huffcodes_15[256] = {
0x0007, 0x000c, 0x0012, 0x0035, 0x002f, 0x004c, 0x007c, 0x006c,
0x0059, 0x007b, 0x006c, 0x0077, 0x006b, 0x0051, 0x007a, 0x003f,
0x000d, 0x0005, 0x0010, 0x001b, 0x002e, 0x0024, 0x003d, 0x0033,
@@ -484,7 +488,7 @@ const UINT16 mpa_huffcodes_15[256] = {
0x0015, 0x0010, 0x000a, 0x0006, 0x0008, 0x0006, 0x0002, 0x0000,
};
-const UINT8 mpa_huffbits_15[256] = {
+const uint8_t mpa_huffbits_15[256] = {
3, 4, 5, 7, 7, 8, 9, 9,
9, 10, 10, 11, 11, 11, 12, 13,
4, 3, 5, 6, 7, 7, 8, 8,
@@ -519,7 +523,7 @@ const UINT8 mpa_huffbits_15[256] = {
12, 12, 12, 12, 13, 13, 13, 13,
};
-const UINT16 mpa_huffcodes_16[256] = {
+const uint16_t mpa_huffcodes_16[256] = {
0x0001, 0x0005, 0x000e, 0x002c, 0x004a, 0x003f, 0x006e, 0x005d,
0x00ac, 0x0095, 0x008a, 0x00f2, 0x00e1, 0x00c3, 0x0178, 0x0011,
0x0003, 0x0004, 0x000c, 0x0014, 0x0023, 0x003e, 0x0035, 0x002f,
@@ -554,7 +558,7 @@ const UINT16 mpa_huffcodes_16[256] = {
0x000d, 0x000c, 0x000a, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003,
};
-const UINT8 mpa_huffbits_16[256] = {
+const uint8_t mpa_huffbits_16[256] = {
1, 4, 6, 8, 9, 9, 10, 10,
11, 11, 11, 12, 12, 12, 13, 9,
3, 4, 6, 7, 8, 9, 9, 9,
@@ -589,7 +593,7 @@ const UINT8 mpa_huffbits_16[256] = {
11, 11, 11, 11, 11, 11, 11, 8,
};
-const UINT16 mpa_huffcodes_24[256] = {
+const uint16_t mpa_huffcodes_24[256] = {
0x000f, 0x000d, 0x002e, 0x0050, 0x0092, 0x0106, 0x00f8, 0x01b2,
0x01aa, 0x029d, 0x028d, 0x0289, 0x026d, 0x0205, 0x0408, 0x0058,
0x000e, 0x000c, 0x0015, 0x0026, 0x0047, 0x0082, 0x007a, 0x00d8,
@@ -624,7 +628,7 @@ const UINT16 mpa_huffcodes_24[256] = {
0x0007, 0x0006, 0x0004, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003,
};
-const UINT8 mpa_huffbits_24[256] = {
+const uint8_t mpa_huffbits_24[256] = {
4, 4, 6, 7, 8, 9, 9, 10,
10, 11, 11, 11, 11, 11, 12, 9,
4, 4, 5, 6, 7, 8, 8, 9,
@@ -678,7 +682,7 @@ const HuffTable mpa_huff_tables[16] = {
{ 16, mpa_huffbits_24, mpa_huffcodes_24 },
};
-const UINT8 mpa_huff_data[32][2] = {
+const uint8_t mpa_huff_data[32][2] = {
{ 0, 0 },
{ 1, 0 },
{ 2, 0 },
@@ -715,18 +719,18 @@ const UINT8 mpa_huff_data[32][2] = {
/* huffman tables for quadrules */
-static UINT8 mpa_quad_codes[2][16] = {
+static uint8_t mpa_quad_codes[2][16] = {
{ 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1, },
{ 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, },
};
-static UINT8 mpa_quad_bits[2][16] = {
+static uint8_t mpa_quad_bits[2][16] = {
{ 1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6, },
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, },
};
/* band size tables */
-const UINT8 band_size_long[9][22] = {
+const uint8_t band_size_long[9][22] = {
{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10,
12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158, }, /* 44100 */
{ 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10,
@@ -747,7 +751,7 @@ const UINT8 band_size_long[9][22] = {
40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2, }, /* 8000 */
};
-const UINT8 band_size_short[9][13] = {
+const uint8_t band_size_short[9][13] = {
{ 4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56, }, /* 44100 */
{ 4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66, }, /* 48000 */
{ 4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12, }, /* 32000 */
@@ -759,7 +763,7 @@ const UINT8 band_size_short[9][13] = {
{ 8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26, }, /* 8000 */
};
-const UINT8 mpa_pretab[2][22] = {
+const uint8_t mpa_pretab[2][22] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 },
};
diff --git a/src/libffmpeg/libavcodec/mpegaudiotab.h b/src/libffmpeg/libavcodec/mpegaudiotab.h
index 41fb0fdbd..59bf86893 100644
--- a/src/libffmpeg/libavcodec/mpegaudiotab.h
+++ b/src/libffmpeg/libavcodec/mpegaudiotab.h
@@ -8,6 +8,12 @@
* same archive
*/
+/**
+ * @file mpegaudiotab.h
+ * mpeg audio layer 2 tables.
+ * Most of them come from the mpeg audio specification.
+ */
+
#define SQRT2 1.41421356237309514547
static const int costab32[30] = {
@@ -54,13 +60,13 @@ static const int bitinv32[32] = {
};
-static INT16 filter_bank[512];
+static int16_t filter_bank[512];
static int scale_factor_table[64];
#ifdef USE_FLOATS
static float scale_factor_inv_table[64];
#else
-static INT8 scale_factor_shift[64];
+static int8_t scale_factor_shift[64];
static unsigned short scale_factor_mult[64];
#endif
static unsigned char scale_diff_table[128];
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c
index 31535c263..393e3828b 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.c
+++ b/src/libffmpeg/libavcodec/mpegvideo.c
@@ -19,12 +19,16 @@
* 4MV & hq & b-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at>
*/
+/**
+ * @file mpegvideo.c
+ * The simplest mpeg encoder (well, it was the simplest!).
+ */
+
#include <ctype.h>
#include <limits.h>
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "simple_idct.h"
#ifdef USE_FASTMEMCPY
#include "fastmemcpy.h"
@@ -32,18 +36,22 @@
#define CONFIG_RISKY
+#ifdef CONFIG_ENCODERS
static void encode_picture(MpegEncContext *s, int picture_number);
+#endif //CONFIG_ENCODERS
static void dct_unquantize_mpeg1_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale);
static void dct_unquantize_mpeg2_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale);
static void dct_unquantize_h263_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale);
-static void draw_edges_c(UINT8 *buf, int wrap, int width, int height, int w);
+static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w);
+#ifdef CONFIG_ENCODERS
static int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
+#endif //CONFIG_ENCODERS
-void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w)= draw_edges_c;
+void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w)= draw_edges_c;
/* enable all paranoid tests for rounding, overflows, etc... */
@@ -67,66 +75,55 @@ static const uint16_t aanscales[64] = {
4520 , 6270, 5906, 5315, 4520, 3552, 2446, 1247
};
-/* Input permutation for the simple_idct_mmx */
-static const uint8_t simple_mmx_permutation[64]={
- 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
- 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
- 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
- 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
- 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
- 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
- 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
- 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
-};
-
static const uint8_t h263_chroma_roundtab[16] = {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
};
-static UINT16 (*default_mv_penalty)[MAX_MV*2+1]=NULL;
-static UINT8 default_fcode_tab[MAX_MV*2+1];
+#ifdef CONFIG_ENCODERS
+static uint16_t (*default_mv_penalty)[MAX_MV*2+1]=NULL;
+static uint8_t default_fcode_tab[MAX_MV*2+1];
enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1};
static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[64], uint16_t (*qmat16_bias)[64],
- const UINT16 *quant_matrix, int bias, int qmin, int qmax)
+ const uint16_t *quant_matrix, int bias, int qmin, int qmax)
{
int qscale;
for(qscale=qmin; qscale<=qmax; qscale++){
int i;
- if (s->fdct == ff_jpeg_fdct_islow) {
+ if (s->dsp.fdct == ff_jpeg_fdct_islow) {
for(i=0;i<64;i++) {
- const int j= s->idct_permutation[i];
+ const int j= s->dsp.idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905 */
/* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */
/* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
/* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
- qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
+ qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) /
(qscale * quant_matrix[j]));
}
- } else if (s->fdct == fdct_ifast) {
+ } else if (s->dsp.fdct == fdct_ifast) {
for(i=0;i<64;i++) {
- const int j= s->idct_permutation[i];
+ const int j= s->dsp.idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905 */
/* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */
/* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
/* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
- qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) /
+ qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) /
(aanscales[i] * qscale * quant_matrix[j]));
}
} else {
for(i=0;i<64;i++) {
- const int j= s->idct_permutation[i];
+ const int j= s->dsp.idct_permutation[i];
/* We can safely suppose that 16 <= quant_matrix[i] <= 255
So 16 <= qscale * quant_matrix[i] <= 7905
so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905
so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67
*/
- qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));
+ qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));
// qmat [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]);
qmat16[qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]);
@@ -136,6 +133,8 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16
}
}
}
+#endif //CONFIG_ENCODERS
+
// move into common.c perhaps
#define CHECKED_ALLOCZ(p, size)\
{\
@@ -146,7 +145,7 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16
}\
}
-void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scantable){
+void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable){
int i;
int end;
@@ -155,7 +154,7 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scanta
for(i=0; i<64; i++){
int j;
j = src_scantable[i];
- st->permutated[i] = s->idct_permutation[j];
+ st->permutated[i] = s->dsp.idct_permutation[j];
#ifdef ARCH_POWERPC
st->inverse[j] = i;
#endif
@@ -170,49 +169,16 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scanta
}
}
-/* XXX: those functions should be suppressed ASAP when all IDCTs are
- converted */
-// *FIXME* this is ugly hack using local static
-static void (*ff_put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
-static void (*ff_add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
-static void ff_jref_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
-{
- j_rev_dct (block);
- ff_put_pixels_clamped(block, dest, line_size);
-}
-static void ff_jref_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
-{
- j_rev_dct (block);
- ff_add_pixels_clamped(block, dest, line_size);
-}
-
/* init common dct for both encoder and decoder */
int DCT_common_init(MpegEncContext *s)
{
- int i;
-
- ff_put_pixels_clamped = s->dsp.put_pixels_clamped;
- ff_add_pixels_clamped = s->dsp.add_pixels_clamped;
-
s->dct_unquantize_h263 = dct_unquantize_h263_c;
s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_c;
s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_c;
- s->dct_quantize= dct_quantize_c;
-
- if(s->avctx->dct_algo==FF_DCT_FASTINT)
- s->fdct = fdct_ifast;
- else
- s->fdct = ff_jpeg_fdct_islow; //slow/accurate/default
- if(s->avctx->idct_algo==FF_IDCT_INT){
- s->idct_put= ff_jref_idct_put;
- s->idct_add= ff_jref_idct_add;
- s->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
- }else{ //accurate/default
- s->idct_put= simple_idct_put;
- s->idct_add= simple_idct_add;
- s->idct_permutation_type= FF_NO_IDCT_PERM;
- }
+#ifdef CONFIG_ENCODERS
+ s->dct_quantize= dct_quantize_c;
+#endif
#ifdef HAVE_MMX
MPV_common_init_mmx(s);
@@ -233,34 +199,14 @@ int DCT_common_init(MpegEncContext *s)
MPV_common_init_ppc(s);
#endif
+#ifdef CONFIG_ENCODERS
s->fast_dct_quantize= s->dct_quantize;
if(s->flags&CODEC_FLAG_TRELLIS_QUANT){
s->dct_quantize= dct_quantize_trellis_c; //move before MPV_common_init_*
}
- switch(s->idct_permutation_type){
- case FF_NO_IDCT_PERM:
- for(i=0; i<64; i++)
- s->idct_permutation[i]= i;
- break;
- case FF_LIBMPEG2_IDCT_PERM:
- for(i=0; i<64; i++)
- s->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
- break;
- case FF_SIMPLE_IDCT_PERM:
- for(i=0; i<64; i++)
- s->idct_permutation[i]= simple_mmx_permutation[i];
- break;
- case FF_TRANSPOSE_IDCT_PERM:
- for(i=0; i<64; i++)
- s->idct_permutation[i]= ((i&7)<<3) | (i>>3);
- break;
- default:
- fprintf(stderr, "Internal error, IDCT permutation not set\n");
- return -1;
- }
-
+#endif //CONFIG_ENCODERS
/* load & permutate scantables
note: only wmv uses differnt ones
@@ -270,6 +216,8 @@ int DCT_common_init(MpegEncContext *s)
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan);
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ s->picture_structure= PICT_FRAME;
+
return 0;
}
@@ -280,13 +228,13 @@ int DCT_common_init(MpegEncContext *s)
static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
if(shared){
- XINE_ASSERT(pic->data[0], "pic->data[0] is NULL.");
- XINE_ASSERT((pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED), "Invalid pic->type: %d", pic->type);
+ assert(pic->data[0]);
+ assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
pic->type= FF_BUFFER_TYPE_SHARED;
}else{
int r;
- XINE_ASSERT(!pic->data[0],"pic->data[0] is not NULL.");
+ assert(!pic->data[0]);
r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
@@ -311,14 +259,14 @@ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
if(pic->qscale_table==NULL){
if (s->encoding) {
- CHECKED_ALLOCZ(pic->mb_var , s->mb_num * sizeof(INT16))
- CHECKED_ALLOCZ(pic->mc_mb_var, s->mb_num * sizeof(INT16))
- CHECKED_ALLOCZ(pic->mb_mean , s->mb_num * sizeof(INT8))
+ CHECKED_ALLOCZ(pic->mb_var , s->mb_num * sizeof(int16_t))
+ CHECKED_ALLOCZ(pic->mc_mb_var, s->mb_num * sizeof(int16_t))
+ CHECKED_ALLOCZ(pic->mb_mean , s->mb_num * sizeof(int8_t))
CHECKED_ALLOCZ(pic->mb_cmp_score, s->mb_num * sizeof(int32_t))
}
- CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(UINT8)+1) //the +1 is for the slice end check
- CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(uint8_t)+1) //the +1 is for the slice end check
+ CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(uint8_t))
pic->qstride= s->mb_width;
}
@@ -371,7 +319,7 @@ int MPV_common_init(MpegEncContext *s)
{
int y_size, c_size, yc_size, i;
- dsputil_init(&s->dsp, s->avctx->dsp_mask);
+ dsputil_init(&s->dsp, s->avctx);
DCT_common_init(s);
s->flags= s->avctx->flags;
@@ -390,10 +338,10 @@ int MPV_common_init(MpegEncContext *s)
yc_size = y_size + 2 * c_size;
/* convert fourcc to upper case */
- s->avctx->fourcc= toupper( s->avctx->fourcc &0xFF)
- + (toupper((s->avctx->fourcc>>8 )&0xFF)<<8 )
- + (toupper((s->avctx->fourcc>>16)&0xFF)<<16)
- + (toupper((s->avctx->fourcc>>24)&0xFF)<<24);
+ s->avctx->codec_tag= toupper( s->avctx->codec_tag &0xFF)
+ + (toupper((s->avctx->codec_tag>>8 )&0xFF)<<8 )
+ + (toupper((s->avctx->codec_tag>>16)&0xFF)<<16)
+ + (toupper((s->avctx->codec_tag>>24)&0xFF)<<24);
CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*17;
@@ -404,12 +352,12 @@ int MPV_common_init(MpegEncContext *s)
int mv_table_size= (s->mb_width+2)*(s->mb_height+2);
/* Allocate MV tables */
- CHECKED_ALLOCZ(s->p_mv_table , mv_table_size * 2 * sizeof(INT16))
- CHECKED_ALLOCZ(s->b_forw_mv_table , mv_table_size * 2 * sizeof(INT16))
- CHECKED_ALLOCZ(s->b_back_mv_table , mv_table_size * 2 * sizeof(INT16))
- CHECKED_ALLOCZ(s->b_bidir_forw_mv_table , mv_table_size * 2 * sizeof(INT16))
- CHECKED_ALLOCZ(s->b_bidir_back_mv_table , mv_table_size * 2 * sizeof(INT16))
- CHECKED_ALLOCZ(s->b_direct_mv_table , mv_table_size * 2 * sizeof(INT16))
+ CHECKED_ALLOCZ(s->p_mv_table , mv_table_size * 2 * sizeof(int16_t))
+ CHECKED_ALLOCZ(s->b_forw_mv_table , mv_table_size * 2 * sizeof(int16_t))
+ CHECKED_ALLOCZ(s->b_back_mv_table , mv_table_size * 2 * sizeof(int16_t))
+ CHECKED_ALLOCZ(s->b_bidir_forw_mv_table , mv_table_size * 2 * sizeof(int16_t))
+ CHECKED_ALLOCZ(s->b_bidir_back_mv_table , mv_table_size * 2 * sizeof(int16_t))
+ CHECKED_ALLOCZ(s->b_direct_mv_table , mv_table_size * 2 * sizeof(int16_t))
//FIXME should be linesize instead of s->width*2 but that isnt known before get_buffer()
CHECKED_ALLOCZ(s->me.scratchpad, s->width*2*16*3*sizeof(uint8_t))
@@ -428,29 +376,29 @@ int MPV_common_init(MpegEncContext *s)
CHECKED_ALLOCZ(s->avctx->stats_out, 256);
}
- CHECKED_ALLOCZ(s->error_status_table, s->mb_num*sizeof(UINT8))
+ CHECKED_ALLOCZ(s->error_status_table, s->mb_num*sizeof(uint8_t))
if (s->out_format == FMT_H263 || s->encoding) {
int size;
/* Allocate MB type table */
- CHECKED_ALLOCZ(s->mb_type , s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(s->mb_type , s->mb_num * sizeof(uint8_t))
/* MV prediction */
size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
- CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(INT16));
+ CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(int16_t));
}
if(s->codec_id==CODEC_ID_MPEG4){
/* interlaced direct mode decoding tables */
- CHECKED_ALLOCZ(s->field_mv_table, s->mb_num*2*2 * sizeof(INT16))
- CHECKED_ALLOCZ(s->field_select_table, s->mb_num*2* sizeof(INT8))
+ CHECKED_ALLOCZ(s->field_mv_table, s->mb_num*2*2 * sizeof(int16_t))
+ CHECKED_ALLOCZ(s->field_select_table, s->mb_num*2* sizeof(int8_t))
}
/* 4mv b frame decoding table */
//note this is needed for h263 without b frames too (segfault on damaged streams otherwise)
- CHECKED_ALLOCZ(s->co_located_type_table, s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(s->co_located_type_table, s->mb_num * sizeof(uint8_t))
if (s->out_format == FMT_H263) {
/* ac values */
- CHECKED_ALLOCZ(s->ac_val[0], yc_size * sizeof(INT16) * 16);
+ CHECKED_ALLOCZ(s->ac_val[0], yc_size * sizeof(int16_t) * 16);
s->ac_val[1] = s->ac_val[0] + y_size;
s->ac_val[2] = s->ac_val[1] + c_size;
@@ -461,14 +409,14 @@ int MPV_common_init(MpegEncContext *s)
CHECKED_ALLOCZ(s->bitstream_buffer, BITSTREAM_BUFFER_SIZE);
/* cbp, ac_pred, pred_dir */
- CHECKED_ALLOCZ(s->cbp_table , s->mb_num * sizeof(UINT8))
- CHECKED_ALLOCZ(s->pred_dir_table, s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(s->cbp_table , s->mb_num * sizeof(uint8_t))
+ CHECKED_ALLOCZ(s->pred_dir_table, s->mb_num * sizeof(uint8_t))
}
if (s->h263_pred || s->h263_plus || !s->encoding) {
/* dc values */
//MN: we need these for error resilience of intra-frames
- CHECKED_ALLOCZ(s->dc_val[0], yc_size * sizeof(INT16));
+ CHECKED_ALLOCZ(s->dc_val[0], yc_size * sizeof(int16_t));
s->dc_val[1] = s->dc_val[0] + y_size;
s->dc_val[2] = s->dc_val[1] + c_size;
for(i=0;i<yc_size;i++)
@@ -543,6 +491,8 @@ void MPV_common_end(MpegEncContext *s)
s->context_initialized = 0;
}
+#ifdef CONFIG_ENCODERS
+
/* init video encoder */
int MPV_encode_init(AVCodecContext *avctx)
{
@@ -553,7 +503,6 @@ int MPV_encode_init(AVCodecContext *avctx)
s->bit_rate = avctx->bit_rate;
s->bit_rate_tolerance = avctx->bit_rate_tolerance;
- s->frame_rate = avctx->frame_rate;
s->width = avctx->width;
s->height = avctx->height;
if(avctx->gop_size > 600){
@@ -565,8 +514,6 @@ int MPV_encode_init(AVCodecContext *avctx)
s->rtp_payload_size = avctx->rtp_payload_size;
if (avctx->rtp_callback)
s->rtp_callback = avctx->rtp_callback;
- s->qmin= avctx->qmin;
- s->qmax= avctx->qmax;
s->max_qdiff= avctx->max_qdiff;
s->qcompress= avctx->qcompress;
s->qblur= avctx->qblur;
@@ -603,10 +550,27 @@ int MPV_encode_init(AVCodecContext *avctx)
s->progressive_sequence= !(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
+ if(s->codec_id==CODEC_ID_MJPEG){
+ s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
+ s->inter_quant_bias= 0;
+ }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO){
+ s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
+ s->inter_quant_bias= 0;
+ }else{
+ s->intra_quant_bias=0;
+ s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x
+ }
+
+ if(avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
+ s->intra_quant_bias= avctx->intra_quant_bias;
+ if(avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
+ s->inter_quant_bias= avctx->inter_quant_bias;
+
switch(avctx->codec->id) {
case CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
- avctx->delay=0; //FIXME not sure, should check the spec
+ s->low_delay= 0; //s->max_b_frames ? 0 : 1;
+ avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
@@ -637,12 +601,12 @@ int MPV_encode_init(AVCodecContext *avctx)
case CODEC_ID_H263P:
s->out_format = FMT_H263;
s->h263_plus = 1;
- s->unrestricted_mv = 1;
- s->h263_aic = 1;
-
+ /* Fx */
+ s->unrestricted_mv=(avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
+ s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
+ /* /Fx */
/* These are just to be sure */
- s->umvplus = 0;
- s->umvplus_dec = 0;
+ s->umvplus = 1;
avctx->delay=0;
s->low_delay=1;
break;
@@ -715,9 +679,9 @@ int MPV_encode_init(AVCodecContext *avctx)
int i;
done=1;
- default_mv_penalty= av_mallocz( sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1) );
- memset(default_mv_penalty, 0, sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1));
- memset(default_fcode_tab , 0, sizeof(UINT8)*(2*MAX_MV+1));
+ default_mv_penalty= av_mallocz( sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
+ memset(default_mv_penalty, 0, sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1));
+ memset(default_fcode_tab , 0, sizeof(uint8_t)*(2*MAX_MV+1));
for(i=-16; i<16; i++){
default_fcode_tab[i + MAX_MV]= 1;
@@ -754,7 +718,7 @@ int MPV_encode_init(AVCodecContext *avctx)
/* init default q matrix */
for(i=0;i<64;i++) {
- int j= s->idct_permutation[i];
+ int j= s->dsp.idct_permutation[i];
#ifdef CONFIG_RISKY
if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
@@ -809,10 +773,12 @@ int MPV_encode_end(AVCodecContext *avctx)
return 0;
}
+#endif //CONFIG_ENCODERS
+
void init_rl(RLTable *rl)
{
- INT8 max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
- UINT8 index_run[MAX_RUN+1];
+ int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
+ uint8_t index_run[MAX_RUN+1];
int last, run, level, start, end, i;
/* compute max_level[], max_run[] and index_run[] */
@@ -849,9 +815,9 @@ void init_rl(RLTable *rl)
/* draw the edges of width 'w' of an image of size width, height */
//FIXME check that this is ok for mpeg4 interlaced
-static void draw_edges_c(UINT8 *buf, int wrap, int width, int height, int w)
+static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w)
{
- UINT8 *ptr, *last_line;
+ uint8_t *ptr, *last_line;
int i;
last_line = buf + (height - 1) * wrap;
@@ -892,7 +858,7 @@ static int find_unused_picture(MpegEncContext *s, int shared){
}
}
- XINE_ASSERT(i<MAX_PICTURE_COUNT,"value 'i' is >= MAX_PICTURE_COUNT: %d >= %d", i, MAX_PICTURE_COUNT);
+ assert(i<MAX_PICTURE_COUNT);
return i;
}
@@ -900,57 +866,66 @@ static int find_unused_picture(MpegEncContext *s, int shared){
int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
int i;
- AVFrame *pic = NULL;
+ AVFrame *pic;
s->mb_skiped = 0;
/* mark&release old frames */
- if (s->pict_type != B_TYPE && s->last_picture.data[0]) {
- for(i=0; i<MAX_PICTURE_COUNT; i++){
-//printf("%8X %d %d %X %X\n", s->picture[i].data[0], s->picture[i].type, i, s->next_picture.data[0], s->last_picture.data[0]);
- if(s->picture[i].data[0] == s->last_picture.data[0]){
-// s->picture[i].reference=0;
- avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
- break;
- }
- }
- XINE_ASSERT(i<MAX_PICTURE_COUNT,"value 'i' is >= MAX_PICTURE_COUNT: %d >= %d", i, MAX_PICTURE_COUNT);
+ if (s->pict_type != B_TYPE && s->last_picture_ptr) {
+ avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
/* release forgotten pictures */
/* if(mpeg124/h263) */
if(!s->encoding){
for(i=0; i<MAX_PICTURE_COUNT; i++){
- if(s->picture[i].data[0] && s->picture[i].data[0] != s->next_picture.data[0] && s->picture[i].reference){
+ if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){
fprintf(stderr, "releasing zombie picture\n");
avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
}
}
}
}
-
+
+alloc:
if(!s->encoding){
i= find_unused_picture(s, 0);
pic= (AVFrame*)&s->picture[i];
pic->reference= s->pict_type != B_TYPE;
- pic->coded_picture_number= s->current_picture.coded_picture_number+1;
+
+ if(s->current_picture_ptr)
+ pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1;
alloc_picture(s, (Picture*)pic, 0);
- s->current_picture= s->picture[i];
+ s->current_picture_ptr= &s->picture[i];
}
if (s->pict_type != B_TYPE) {
- s->last_picture= s->next_picture;
- s->next_picture= s->current_picture;
+ s->last_picture_ptr= s->next_picture_ptr;
+ s->next_picture_ptr= s->current_picture_ptr;
+ }
+ s->current_picture= *s->current_picture_ptr;
+ if(s->last_picture_ptr) s->last_picture= *s->last_picture_ptr;
+ if(s->next_picture_ptr) s->next_picture= *s->next_picture_ptr;
+ if(s->new_picture_ptr ) s->new_picture = *s->new_picture_ptr;
+
+ if(s->picture_structure!=PICT_FRAME){
+ int i;
+ for(i=0; i<4; i++){
+ if(s->picture_structure == PICT_BOTTOM_FIELD){
+ s->current_picture.data[i] += s->current_picture.linesize[i];
+ }
+ s->current_picture.linesize[i] *= 2;
+ s->last_picture.linesize[i] *=2;
+ s->next_picture.linesize[i] *=2;
+ }
}
- if(s->pict_type != I_TYPE && s->last_picture.data[0]==NULL){
+ if(s->pict_type != I_TYPE && s->last_picture_ptr==NULL){
fprintf(stderr, "warning: first frame is no keyframe\n");
- XINE_ASSERT(s->pict_type != B_TYPE, "These should have been dropped if we dont have a reference");
- free_picture(s, (Picture*) pic);
- s->last_picture.data[0] = s->next_picture.data[0] = NULL;
- return -1;
+ assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
+ goto alloc;
}
s->hurry_up= s->avctx->hurry_up;
@@ -987,19 +962,19 @@ void MPV_frame_end(MpegEncContext *s)
if(s->pict_type!=B_TYPE){
s->last_non_b_pict_type= s->pict_type;
}
-
- s->current_picture.quality= s->qscale; //FIXME get average of qscale_table
- s->current_picture.pict_type= s->pict_type;
- s->current_picture.key_frame= s->pict_type == I_TYPE;
-
- /* copy back current_picture variables */
+#if 0
+ /* copy back current_picture variables */
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0] == s->current_picture.data[0]){
s->picture[i]= s->current_picture;
break;
}
}
- XINE_ASSERT(i<MAX_PICTURE_COUNT,"value 'i' is >= MAX_PICTURE_COUNT: %d >= %d", i, MAX_PICTURE_COUNT);
+ assert(i<MAX_PICTURE_COUNT);
+#endif
+ s->current_picture_ptr->quality= s->qscale; //FIXME get average of qscale_table
+ s->current_picture_ptr->pict_type= s->pict_type;
+ s->current_picture_ptr->key_frame= s->pict_type == I_TYPE;
/* release non refernce frames */
for(i=0; i<MAX_PICTURE_COUNT; i++){
@@ -1018,8 +993,17 @@ void MPV_frame_end(MpegEncContext *s)
}
printf("pict type: %d\n", s->pict_type);
}
+
+ // clear copies, to avoid confusion
+#if 0
+ memset(&s->last_picture, 0, sizeof(Picture));
+ memset(&s->next_picture, 0, sizeof(Picture));
+ memset(&s->current_picture, 0, sizeof(Picture));
+#endif
}
+#ifdef CONFIG_ENCODERS
+
static int get_sae(uint8_t *src, int ref, int stride){
int x,y;
int acc=0;
@@ -1085,6 +1069,12 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
pic->reference= 1;
alloc_picture(s, (Picture*)pic, 0);
+ for(i=0; i<4; i++){
+ /* the input will be 16 pixels to the right relative to the actual buffer start
+ * and the current_pic, so the buffer can be reused, yes its not beatifull
+ */
+ pic->data[i]+= 16;
+ }
if( pic->data[0] == pic_arg->data[0]
&& pic->data[1] == pic_arg->data[1]
@@ -1135,7 +1125,7 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
static void select_input_picture(MpegEncContext *s){
int i;
-
+ const int encoding_delay= s->max_b_frames;
int coded_pic_num=0;
if(s->reordered_input_picture[0])
@@ -1147,7 +1137,7 @@ static void select_input_picture(MpegEncContext *s){
/* set next picture types & ordering */
if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
- if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture.data[0]==NULL || s->intra_only){
+ if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
s->reordered_input_picture[0]= s->input_picture[0];
s->reordered_input_picture[0]->pict_type= I_TYPE;
s->reordered_input_picture[0]->coded_picture_number= coded_pic_num;
@@ -1221,19 +1211,22 @@ static void select_input_picture(MpegEncContext *s){
}
if(s->reordered_input_picture[0]){
- s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE;
+ s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE;
+
+ s->new_picture= *s->reordered_input_picture[0];
if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
+ // input is a shared pix, so we cant modifiy it -> alloc a new one & ensure that the shared one is reuseable
+
int i= find_unused_picture(s, 0);
Picture *pic= &s->picture[i];
- s->new_picture= *s->reordered_input_picture[0];
-
/* mark us unused / free shared pic */
for(i=0; i<4; i++)
s->reordered_input_picture[0]->data[i]= NULL;
s->reordered_input_picture[0]->type= 0;
+ //FIXME bad, copy * except
pic->pict_type = s->reordered_input_picture[0]->pict_type;
pic->quality = s->reordered_input_picture[0]->quality;
pic->coded_picture_number = s->reordered_input_picture[0]->coded_picture_number;
@@ -1241,21 +1234,20 @@ static void select_input_picture(MpegEncContext *s){
alloc_picture(s, pic, 0);
- s->current_picture= *pic;
+ s->current_picture_ptr= pic;
}else{
- XINE_ASSERT(
- (s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER
- || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL),
- "s->reordered_input_picture[0]->type is incorrect: %d",
- s->reordered_input_picture[0]->type);
-
- s->new_picture= *s->reordered_input_picture[0];
+ // input is not a shared pix -> reuse buffer for current_pix
+ assert( s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER
+ || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
+
+ s->current_picture_ptr= s->reordered_input_picture[0];
for(i=0; i<4; i++){
- s->reordered_input_picture[0]->data[i]-=16; //FIXME dirty
+ //reverse the +16 we did before storing the input
+ s->current_picture_ptr->data[i]-=16;
}
- s->current_picture= *s->reordered_input_picture[0];
}
+ s->current_picture= *s->current_picture_ptr;
s->picture_number= s->new_picture.display_picture_number;
//printf("dpn:%d\n", s->picture_number);
@@ -1285,7 +1277,7 @@ int MPV_encode_picture(AVCodecContext *avctx,
s->pict_type= s->new_picture.pict_type;
if (s->fixed_qscale){ /* the ratecontrol needs the last qscale so we dont touch it for CBR */
s->qscale= (int)(s->new_picture.quality+0.5);
- XINE_ASSERT(s->qscale,"s->qscale is NULL");
+ assert(s->qscale);
}
//emms_c();
//printf("qs:%f %f %d\n", s->new_picture.quality, s->current_picture.quality, s->qscale);
@@ -1310,6 +1302,10 @@ int MPV_encode_picture(AVCodecContext *avctx,
if(s->flags&CODEC_FLAG_PASS1)
ff_write_pass1_stats(s);
+
+ for(i=0; i<4; i++){
+ avctx->error[i] += s->current_picture_ptr->error[i];
+ }
}
s->input_picture_number++;
@@ -1319,20 +1315,18 @@ int MPV_encode_picture(AVCodecContext *avctx,
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;
-
- for(i=0; i<4; i++){
- avctx->error[i] += s->current_picture.error[i];
- }
return pbBufPtr(&s->pb) - s->pb.buf;
}
+#endif //CONFIG_ENCODERS
+
static inline void gmc1_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int dest_offset,
- UINT8 **ref_picture, int src_offset)
+ uint8_t **ref_picture, int src_offset)
{
- UINT8 *ptr;
+ uint8_t *ptr;
int offset, src_x, src_y, linesize, uvlinesize;
int motion_x, motion_y;
int emu=0;
@@ -1416,11 +1410,11 @@ static inline void gmc1_motion(MpegEncContext *s,
}
static inline void gmc_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int dest_offset,
- UINT8 **ref_picture, int src_offset)
+ uint8_t **ref_picture, int src_offset)
{
- UINT8 *ptr;
+ uint8_t *ptr;
int linesize, uvlinesize;
const int a= s->sprite_warping_accuracy;
int ox, oy;
@@ -1479,11 +1473,11 @@ static inline void gmc_motion(MpegEncContext *s,
}
-void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_w, int block_h,
+void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h){
int x, y;
int start_y, start_x, end_y, end_x;
- UINT8 *buf= s->edge_emu_buffer;
+ uint8_t *buf= s->edge_emu_buffer;
if(src_y>= h){
src+= (h-1-src_y)*linesize;
@@ -1542,13 +1536,13 @@ void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_
/* apply one mpeg motion vector to the three components */
static inline void mpeg_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int dest_offset,
- UINT8 **ref_picture, int src_offset,
+ uint8_t **ref_picture, int src_offset,
int field_based, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h)
{
- UINT8 *ptr;
+ uint8_t *ptr;
int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize;
int emu=0;
#if 0
@@ -1571,15 +1565,15 @@ if(s->quarter_sample)
src_y = clip(src_y, -16, height);
if (src_y == height)
dxy &= ~2;
- linesize = s->linesize << field_based;
- uvlinesize = s->uvlinesize << field_based;
+ linesize = s->current_picture.linesize[0] << field_based;
+ uvlinesize = s->current_picture.linesize[1] << field_based;
ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset;
dest_y += dest_offset;
if(s->flags&CODEC_FLAG_EMU_EDGE){
if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 16 > s->h_edge_pos
|| src_y + (motion_y&1) + h > v_edge_pos){
- ff_emulated_edge_mc(s, ptr - src_offset, s->linesize, 17, 17+field_based,
+ ff_emulated_edge_mc(s, ptr - src_offset, s->linesize, 17, 17+field_based, //FIXME linesize? and uv below
src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer + src_offset;
emu=1;
@@ -1632,14 +1626,14 @@ if(s->quarter_sample)
}
static inline void qpel_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int dest_offset,
- UINT8 **ref_picture, int src_offset,
+ uint8_t **ref_picture, int src_offset,
int field_based, op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int motion_x, int motion_y, int h)
{
- UINT8 *ptr;
+ uint8_t *ptr;
int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize;
int emu=0;
@@ -1697,6 +1691,7 @@ static inline void qpel_motion(MpegEncContext *s,
}
mx= (mx>>1)|(mx&1);
my= (my>>1)|(my&1);
+
dxy= (mx&1) | ((my&1)<<1);
mx>>=1;
my>>=1;
@@ -1738,13 +1733,13 @@ inline int ff_h263_round_chroma(int x){
}
static inline void MPV_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
- int dir, UINT8 **ref_picture,
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
+ int dir, uint8_t **ref_picture,
op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16])
{
int dxy, offset, mx, my, src_x, src_y, motion_x, motion_y;
int mb_x, mb_y, i;
- UINT8 *ptr, *dest;
+ uint8_t *ptr, *dest;
int emu=0;
mb_x = s->mb_x;
@@ -1909,8 +1904,18 @@ static inline void MPV_motion(MpegEncContext *s,
s->mv[dir][1][0], s->mv[dir][1][1], 8);
}
} else {
-
+ int offset;
+ if(s->picture_structure == s->field_select[dir][0] + 1 || s->pict_type == B_TYPE || s->first_field){
+ offset= s->field_select[dir][0] ? s->linesize : 0;
+ }else{
+ ref_picture= s->current_picture.data;
+ offset= s->field_select[dir][0] ? s->linesize : -s->linesize;
+ }
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
+ ref_picture, offset,
+ 0, pix_op,
+ s->mv[dir][0][0], s->mv[dir][0][1], 16);
}
break;
}
@@ -1919,28 +1924,28 @@ static inline void MPV_motion(MpegEncContext *s,
/* put block[] to dest[] */
static inline void put_dct(MpegEncContext *s,
- DCTELEM *block, int i, UINT8 *dest, int line_size)
+ DCTELEM *block, int i, uint8_t *dest, int line_size)
{
s->dct_unquantize(s, block, i, s->qscale);
- s->idct_put (dest, line_size, block);
+ s->dsp.idct_put (dest, line_size, block);
}
/* add block[] to dest[] */
static inline void add_dct(MpegEncContext *s,
- DCTELEM *block, int i, UINT8 *dest, int line_size)
+ DCTELEM *block, int i, uint8_t *dest, int line_size)
{
if (s->block_last_index[i] >= 0) {
- s->idct_add (dest, line_size, block);
+ s->dsp.idct_add (dest, line_size, block);
}
}
static inline void add_dequant_dct(MpegEncContext *s,
- DCTELEM *block, int i, UINT8 *dest, int line_size)
+ DCTELEM *block, int i, uint8_t *dest, int line_size)
{
if (s->block_last_index[i] >= 0) {
s->dct_unquantize(s, block, i, s->qscale);
- s->idct_add (dest, line_size, block);
+ s->dsp.idct_add (dest, line_size, block);
}
}
@@ -1957,8 +1962,8 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
s->dc_val[0][xy + wrap] =
s->dc_val[0][xy + 1 + wrap] = 1024;
/* ac pred */
- memset(s->ac_val[0][xy ], 0, 32 * sizeof(INT16));
- memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(INT16));
+ memset(s->ac_val[0][xy ], 0, 32 * sizeof(int16_t));
+ memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(int16_t));
if (s->msmpeg4_version>=3) {
s->coded_block[xy ] =
s->coded_block[xy + 1 ] =
@@ -1971,8 +1976,8 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
s->dc_val[1][xy] =
s->dc_val[2][xy] = 1024;
/* ac pred */
- memset(s->ac_val[1][xy], 0, 16 * sizeof(INT16));
- memset(s->ac_val[2][xy], 0, 16 * sizeof(INT16));
+ memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t));
+ memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t));
s->mbintra_table[s->mb_x + s->mb_y*s->mb_width]= 0;
}
@@ -2056,10 +2061,12 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
}
if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc
- UINT8 *dest_y, *dest_cb, *dest_cr;
+ uint8_t *dest_y, *dest_cb, *dest_cr;
int dct_linesize, dct_offset;
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
+ const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics
+ const int uvlinesize= s->current_picture.linesize[1];
/* avoid copy if macroblock skipped in last frame too */
if (s->pict_type != B_TYPE) {
@@ -2068,14 +2075,14 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
/* skip only during decoding as we might trash the buffers during encoding a bit */
if(!s->encoding){
- UINT8 *mbskip_ptr = &s->mbskip_table[mb_xy];
+ uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
const int age= s->current_picture.age;
- XINE_ASSERT(age, "value 'age' is NULL");
+ assert(age);
if (s->mb_skiped) {
s->mb_skiped= 0;
- XINE_ASSERT(s->pict_type!=I_TYPE, "s->pict_type (%d) != I_TYPE (%d)", s->pict_type, I_TYPE);
+ assert(s->pict_type!=I_TYPE);
(*mbskip_ptr) ++; /* indicate that this time we skiped it */
if(*mbskip_ptr >99) *mbskip_ptr= 99;
@@ -2093,22 +2100,22 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
}else
s->mb_skiped= 0;
- if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band){
+ if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME){ //FIXME precalc
dest_y = s->current_picture.data[0] + mb_x * 16;
dest_cb = s->current_picture.data[1] + mb_x * 8;
dest_cr = s->current_picture.data[2] + mb_x * 8;
}else{
- dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16;
- dest_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
- dest_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
+ dest_y = s->current_picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
+ dest_cb = s->current_picture.data[1] + (mb_y * 8 * uvlinesize) + mb_x * 8;
+ dest_cr = s->current_picture.data[2] + (mb_y * 8 * uvlinesize) + mb_x * 8;
}
if (s->interlaced_dct) {
- dct_linesize = s->linesize * 2;
- dct_offset = s->linesize;
+ dct_linesize = linesize * 2;
+ dct_offset = linesize;
} else {
- dct_linesize = s->linesize;
- dct_offset = s->linesize * 8;
+ dct_linesize = linesize;
+ dct_offset = linesize * 8;
}
if (!s->mb_intra) {
@@ -2145,8 +2152,8 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
if(!(s->flags&CODEC_FLAG_GRAY)){
- add_dequant_dct(s, block[4], 4, dest_cb, s->uvlinesize);
- add_dequant_dct(s, block[5], 5, dest_cr, s->uvlinesize);
+ add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize);
+ add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize);
}
} else if(s->codec_id != CODEC_ID_WMV2){
add_dct(s, block[0], 0, dest_y, dct_linesize);
@@ -2155,8 +2162,8 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
if(!(s->flags&CODEC_FLAG_GRAY)){
- add_dct(s, block[4], 4, dest_cb, s->uvlinesize);
- add_dct(s, block[5], 5, dest_cr, s->uvlinesize);
+ add_dct(s, block[4], 4, dest_cb, uvlinesize);
+ add_dct(s, block[5], 5, dest_cr, uvlinesize);
}
}
#ifdef CONFIG_RISKY
@@ -2173,24 +2180,26 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
if(!(s->flags&CODEC_FLAG_GRAY)){
- put_dct(s, block[4], 4, dest_cb, s->uvlinesize);
- put_dct(s, block[5], 5, dest_cr, s->uvlinesize);
+ put_dct(s, block[4], 4, dest_cb, uvlinesize);
+ put_dct(s, block[5], 5, dest_cr, uvlinesize);
}
}else{
- s->idct_put(dest_y , dct_linesize, block[0]);
- s->idct_put(dest_y + 8, dct_linesize, block[1]);
- s->idct_put(dest_y + dct_offset , dct_linesize, block[2]);
- s->idct_put(dest_y + dct_offset + 8, dct_linesize, block[3]);
+ s->dsp.idct_put(dest_y , dct_linesize, block[0]);
+ s->dsp.idct_put(dest_y + 8, dct_linesize, block[1]);
+ s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]);
+ s->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize, block[3]);
if(!(s->flags&CODEC_FLAG_GRAY)){
- s->idct_put(dest_cb, s->uvlinesize, block[4]);
- s->idct_put(dest_cr, s->uvlinesize, block[5]);
+ s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
+ s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
}
}
}
}
}
+#ifdef CONFIG_ENCODERS
+
static inline void dct_single_coeff_elimination(MpegEncContext *s, int n, int threshold)
{
static const char tab[64]=
@@ -2257,80 +2266,13 @@ static inline void clip_coeffs(MpegEncContext *s, DCTELEM *block, int last_index
if (level>maxlevel) level=maxlevel;
else if(level<minlevel) level=minlevel;
- block[j]= level;
- }
-}
-
-static inline void requantize_coeffs(MpegEncContext *s, DCTELEM block[64], int oldq, int newq, int n)
-{
- int i;
- if(s->mb_intra){
- i=1; //skip clipping of intra dc
- //FIXME requantize, note (mpeg1/h263/h263p-aic dont need it,...)
- }else
- i=0;
-
- for(;i<=s->block_last_index[n]; i++){
- const int j = s->intra_scantable.permutated[i];
- int level = block[j];
-
- block[j]= ROUNDED_DIV(level*oldq, newq);
- }
-
- for(i=s->block_last_index[n]; i>=0; i--){
- const int j = s->intra_scantable.permutated[i];
- if(block[j]) break;
+ block[j]= level;
}
- s->block_last_index[n]= i;
}
-static inline void auto_requantize_coeffs(MpegEncContext *s, DCTELEM block[6][64])
-{
- int i,n, newq;
- const int maxlevel= s->max_qcoeff;
- const int minlevel= s->min_qcoeff;
- int largest=0, smallest=0;
-
- XINE_ASSERT(s->adaptive_quant, "s->adaptive_quant is NULL");
-
- for(n=0; n<6; n++){
- if(s->mb_intra){
- i=1; //skip clipping of intra dc
- //FIXME requantize, note (mpeg1/h263/h263p-aic dont need it,...)
- }else
- i=0;
-
- for(;i<=s->block_last_index[n]; i++){
- const int j = s->intra_scantable.permutated[i];
- int level = block[n][j];
- if(largest < level) largest = level;
- if(smallest > level) smallest= level;
- }
- }
-
- for(newq=s->qscale+1; newq<32; newq++){
- if( ROUNDED_DIV(smallest*s->qscale, newq) >= minlevel
- && ROUNDED_DIV(largest *s->qscale, newq) <= maxlevel)
- break;
- }
-
- if(s->out_format==FMT_H263){
- /* h263 like formats cannot change qscale by more than 2 easiely */
- if(s->avctx->qmin + 2 < newq)
- newq= s->avctx->qmin + 2;
- }
-
- for(n=0; n<6; n++){
- requantize_coeffs(s, block[n], s->qscale, newq, n);
- clip_coeffs(s, block[n], s->block_last_index[n]);
- }
-
- s->dquant+= newq - s->qscale;
- s->qscale= newq;
-}
#if 0
-static int pix_vcmp16x8(UINT8 *s, int stride){ //FIXME move to dsputil & optimize
+static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize
int score=0;
int x,y;
@@ -2345,7 +2287,7 @@ static int pix_vcmp16x8(UINT8 *s, int stride){ //FIXME move to dsputil & optimiz
return score;
}
-static int pix_diff_vcmp16x8(UINT8 *s1, UINT8*s2, int stride){ //FIXME move to dsputil & optimize
+static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move to dsputil & optimize
int score=0;
int x,y;
@@ -2362,7 +2304,7 @@ static int pix_diff_vcmp16x8(UINT8 *s1, UINT8*s2, int stride){ //FIXME move to d
#else
#define SQ(a) ((a)*(a))
-static int pix_vcmp16x8(UINT8 *s, int stride){ //FIXME move to dsputil & optimize
+static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize
int score=0;
int x,y;
@@ -2377,7 +2319,7 @@ static int pix_vcmp16x8(UINT8 *s, int stride){ //FIXME move to dsputil & optimiz
return score;
}
-static int pix_diff_vcmp16x8(UINT8 *s1, UINT8*s2, int stride){ //FIXME move to dsputil & optimize
+static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move to dsputil & optimize
int score=0;
int x,y;
@@ -2394,17 +2336,20 @@ static int pix_diff_vcmp16x8(UINT8 *s1, UINT8*s2, int stride){ //FIXME move to d
#endif
-void ff_draw_horiz_band(MpegEncContext *s){
+#endif //CONFIG_ENCODERS
+
+/**
+ *
+ * @param h is the normal height, this will be reduced automatically if needed for the last row
+ */
+void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
if ( s->avctx->draw_horiz_band
- && (s->last_picture.data[0] || s->low_delay) ) {
- UINT8 *src_ptr[3];
- int y, h, offset;
- y = s->mb_y * 16;
- h = s->height - y;
- if (h > 16)
- h = 16;
-
- if(s->pict_type==B_TYPE)
+ && (s->last_picture_ptr || s->low_delay) ) {
+ uint8_t *src_ptr[3];
+ int offset;
+ h= FFMIN(h, s->height - y);
+
+ if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME)
offset = 0;
else
offset = y * s->linesize;
@@ -2425,6 +2370,8 @@ void ff_draw_horiz_band(MpegEncContext *s){
}
}
+#ifdef CONFIG_ENCODERS
+
static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
{
const int mb_x= s->mb_x;
@@ -2445,7 +2392,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
if(s->codec_id==CODEC_ID_MPEG4){
if(!s->mb_intra){
- XINE_ASSERT((s->dquant==0 || s->mv_type!=MV_TYPE_8X8), "?");
+ assert(s->dquant==0 || s->mv_type!=MV_TYPE_8X8);
if(s->mv_dir&MV_DIRECT)
s->dquant=0;
@@ -2457,7 +2404,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
}
if (s->mb_intra) {
- UINT8 *ptr;
+ uint8_t *ptr;
int wrap_y;
int emu=0;
@@ -2512,8 +2459,8 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
}else{
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
- UINT8 *dest_y, *dest_cb, *dest_cr;
- UINT8 *ptr_y, *ptr_cb, *ptr_cr;
+ uint8_t *dest_y, *dest_cb, *dest_cr;
+ uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int wrap_y, wrap_c;
int emu=0;
@@ -2661,7 +2608,6 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
s->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale;
}
-#ifdef CONFIG_ENCODERS
/* huffman encode */
switch(s->codec_id){ //FIXME funct ptr could be slightly faster
case CODEC_ID_MPEG1VIDEO:
@@ -2683,11 +2629,12 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
case CODEC_ID_MJPEG:
mjpeg_encode_mb(s, s->block); break;
default:
- XINE_ASSERT(0, "We have no default case. So if program control reaches here something is really wrong");
+ assert(0);
}
-#endif
}
+#endif //CONFIG_ENCODERS
+
/**
* combines the (truncated) bitstream to a complete frame
* @returns -1 if no complete frame could be created
@@ -2717,7 +2664,8 @@ int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size)
return 0;
}
-void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length)
+#ifdef CONFIG_ENCODERS
+void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
{
int bytes= length>>4;
int bits= length&15;
@@ -2838,7 +2786,7 @@ static inline int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, in
}
}
- XINE_ASSERT(acc>=0,"value 'acc' is < 0: %d", acc);
+ assert(acc>=0);
return acc;
}
@@ -2849,9 +2797,9 @@ static void encode_picture(MpegEncContext *s, int picture_number)
int i;
int bits;
MpegEncContext best_s, backup_s;
- UINT8 bit_buf[2][3000];
- UINT8 bit_buf2[2][3000];
- UINT8 bit_buf_tex[2][3000];
+ uint8_t bit_buf[2][3000];
+ uint8_t bit_buf2[2][3000];
+ uint8_t bit_buf_tex[2][3000];
PutBitContext pb[2], pb2[2], tex_pb[2];
for(i=0; i<2; i++){
@@ -2875,7 +2823,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
#ifdef CONFIG_RISKY
/* we need to initialize some time vars before we can encode b-frames */
- if (s->h263_pred && !s->h263_msmpeg4)
+ // RAL: Condition added for MPEG1VIDEO
+ if (s->codec_id == CODEC_ID_MPEG1VIDEO || (s->h263_pred && !s->h263_msmpeg4))
ff_set_mpeg4_time(s, s->picture_number);
#endif
@@ -2883,17 +2832,14 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->qscale= (int)(s->frame_qscale + 0.5); //FIXME qscale / ... stuff for ME ratedistoration
- if(s->msmpeg4_version){
- if(s->pict_type==I_TYPE)
- s->no_rounding=1;
- else if(s->flipflop_rounding)
- s->no_rounding ^= 1;
- }else if(s->out_format == FMT_H263){
- if(s->pict_type==I_TYPE)
- s->no_rounding=0;
- else if(s->pict_type!=B_TYPE)
+ if(s->pict_type==I_TYPE){
+ if(s->msmpeg4_version) s->no_rounding=1;
+ else s->no_rounding=0;
+ }else if(s->pict_type!=B_TYPE){
+ if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
+
/* Estimate motion for every MB */
s->mb_intra=0; //for the rate distoration & bit compare functions
if(s->pict_type != I_TYPE){
@@ -2937,9 +2883,9 @@ static void encode_picture(MpegEncContext *s, int picture_number)
}else /* if(s->pict_type == I_TYPE) */{
/* I-Frame */
//FIXME do we need to zero them?
- memset(s->motion_val[0], 0, sizeof(INT16)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2);
- memset(s->p_mv_table , 0, sizeof(INT16)*(s->mb_width+2)*(s->mb_height+2)*2);
- memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height);
+ memset(s->motion_val[0], 0, sizeof(int16_t)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2);
+ memset(s->p_mv_table , 0, sizeof(int16_t)*(s->mb_width+2)*(s->mb_height+2)*2);
+ memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_width*s->mb_height);
if(!s->fixed_qscale){
/* finding spatial complexity for I-frame rate control */
@@ -2964,21 +2910,33 @@ static void encode_picture(MpegEncContext *s, int picture_number)
if(s->scene_change_score > 0 && s->pict_type == P_TYPE){
s->pict_type= I_TYPE;
- memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height);
+ memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_width*s->mb_height);
//printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
}
- if(s->pict_type==P_TYPE || s->pict_type==S_TYPE)
- s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER);
- ff_fix_long_p_mvs(s);
- if(s->pict_type==B_TYPE){
- s->f_code= ff_get_best_fcode(s, s->b_forw_mv_table, MB_TYPE_FORWARD);
- s->b_code= ff_get_best_fcode(s, s->b_back_mv_table, MB_TYPE_BACKWARD);
+ if(!s->umvplus){
+ if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) {
+ s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER);
+
+ ff_fix_long_p_mvs(s);
+ }
+
+ if(s->pict_type==B_TYPE){
+ int a, b;
+
+ a = ff_get_best_fcode(s, s->b_forw_mv_table, MB_TYPE_FORWARD);
+ b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, MB_TYPE_BIDIR);
+ s->f_code = FFMAX(a, b);
- ff_fix_long_b_mvs(s, s->b_forw_mv_table, s->f_code, MB_TYPE_FORWARD);
- ff_fix_long_b_mvs(s, s->b_back_mv_table, s->b_code, MB_TYPE_BACKWARD);
- ff_fix_long_b_mvs(s, s->b_bidir_forw_mv_table, s->f_code, MB_TYPE_BIDIR);
- ff_fix_long_b_mvs(s, s->b_bidir_back_mv_table, s->b_code, MB_TYPE_BIDIR);
+ a = ff_get_best_fcode(s, s->b_back_mv_table, MB_TYPE_BACKWARD);
+ b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, MB_TYPE_BIDIR);
+ s->b_code = FFMAX(a, b);
+
+ ff_fix_long_b_mvs(s, s->b_forw_mv_table, s->f_code, MB_TYPE_FORWARD);
+ ff_fix_long_b_mvs(s, s->b_back_mv_table, s->b_code, MB_TYPE_BACKWARD);
+ ff_fix_long_b_mvs(s, s->b_bidir_forw_mv_table, s->f_code, MB_TYPE_BIDIR);
+ ff_fix_long_b_mvs(s, s->b_bidir_back_mv_table, s->b_code, MB_TYPE_BIDIR);
+ }
}
if (s->fixed_qscale)
@@ -3007,7 +2965,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
/* for mjpeg, we do include qscale in the matrix */
s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
for(i=1;i<64;i++){
- int j= s->idct_permutation[i];
+ int j= s->dsp.idct_permutation[i];
s->intra_matrix[j] = CLAMP_TO_8BIT((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
}
@@ -3062,11 +3020,15 @@ static void encode_picture(MpegEncContext *s, int picture_number)
/* note: quant matrix value (8) is implied here */
s->last_dc[i] = 128;
- s->current_picture.error[i] = 0;
+ s->current_picture_ptr->error[i] = 0;
}
s->mb_incr = 1;
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
+ s->last_mv[1][0][0] = 0;
+ s->last_mv[1][0][1] = 0;
+
+ s->last_mv_dir = 0;
#ifdef CONFIG_RISKY
if (s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)
@@ -3230,7 +3192,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
&dmin, &next_block, mx, my);
}
if(mb_type&MB_TYPE_INTRA){
- s->mv_dir = MV_DIR_FORWARD;
+ s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
@@ -3351,7 +3313,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
switch(mb_type){
case MB_TYPE_INTRA:
- s->mv_dir = MV_DIR_FORWARD;
+ s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
@@ -3408,8 +3370,13 @@ static void encode_picture(MpegEncContext *s, int picture_number)
motion_x=motion_y=0; //gcc warning fix
printf("illegal MB type\n");
}
+
encode_mb(s, motion_x, motion_y);
+
+ // RAL: Update last macrobloc type
+ s->last_mv_dir = s->mv_dir;
}
+
/* clean the MV table in IPS frames for direct mode in B frames */
if(s->mb_intra /* && I,P,S_TYPE */){
s->p_mv_table[xy][0]=0;
@@ -3425,17 +3392,17 @@ static void encode_picture(MpegEncContext *s, int picture_number)
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
- s->current_picture.error[0] += sse(
+ s->current_picture_ptr->error[0] += sse(
s,
s->new_picture .data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->current_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
w, h, s->linesize);
- s->current_picture.error[1] += sse(
+ s->current_picture_ptr->error[1] += sse(
s,
s->new_picture .data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
s->current_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
w>>1, h>>1, s->uvlinesize);
- s->current_picture.error[2] += sse(
+ s->current_picture_ptr->error[2] += sse(
s,
s->new_picture .data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
s->current_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
@@ -3487,7 +3454,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
DCTELEM *block, int n,
int qscale, int *overflow){
const int *qmat;
- const UINT8 *scantable= s->intra_scantable.scantable;
+ const uint8_t *scantable= s->intra_scantable.scantable;
int max=0;
unsigned int threshold1, threshold2;
int bias=0;
@@ -3507,7 +3474,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int score_limit=0;
int left_limit= 0;
- s->fdct (block);
+ s->dsp.fdct (block);
qmul= qscale*16;
qadd= ((qscale-1)|1)*8;
@@ -3597,7 +3564,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int level= coeff[level_index][i];
int unquant_coeff;
- XINE_ASSERT(level, "value 'level' is NULL");
+ assert(level);
if(s->out_format == FMT_H263){
if(level>0){
@@ -3606,7 +3573,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
unquant_coeff= level*qmul - qadd;
}
}else{ //MPEG1
- j= s->idct_permutation[ scantable[i + start_i] ]; //FIXME optimize
+ j= s->dsp.idct_permutation[ scantable[i + start_i] ]; //FIXME optimize
if(s->mb_intra){
if (level < 0) {
unquant_coeff = (int)((-level) * qscale * s->intra_matrix[j]) >> 3;
@@ -3716,16 +3683,16 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
return last_non_zero;
i= last_i;
- XINE_ASSERT(last_level, "value 'last_level' is NULL");
+ assert(last_level);
//FIXME use permutated scantable
- block[ s->idct_permutation[ scantable[last_non_zero] ] ]= last_level;
+ block[ s->dsp.idct_permutation[ scantable[last_non_zero] ] ]= last_level;
i -= last_run + 1;
for(;i>0 ; i -= run_tab[i] + 1){
- const int j= s->idct_permutation[ scantable[i - 1 + start_i] ];
+ const int j= s->dsp.idct_permutation[ scantable[i - 1 + start_i] ];
block[j]= level_tab[i];
- XINE_ASSERT(block[j], "value 'block[j]' is NULL");
+ assert(block[j]);
}
return last_non_zero;
@@ -3737,12 +3704,12 @@ static int dct_quantize_c(MpegEncContext *s,
{
int i, j, level, last_non_zero, q;
const int *qmat;
- const UINT8 *scantable= s->intra_scantable.scantable;
+ const uint8_t *scantable= s->intra_scantable.scantable;
int bias;
int max=0;
unsigned int threshold1, threshold2;
- s->fdct (block);
+ s->dsp.fdct (block);
if (s->mb_intra) {
if (!s->h263_aic) {
@@ -3794,17 +3761,19 @@ static int dct_quantize_c(MpegEncContext *s,
*overflow= s->max_qcoeff < max; //overflow might have happend
/* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
- if (s->idct_permutation_type != FF_NO_IDCT_PERM)
- ff_block_permute(block, s->idct_permutation, scantable, last_non_zero);
+ if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
+ ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
return last_non_zero;
}
+#endif //CONFIG_ENCODERS
+
static void dct_unquantize_mpeg1_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int i, level, nCoeffs;
- const UINT16 *quant_matrix;
+ const uint16_t *quant_matrix;
nCoeffs= s->block_last_index[n];
@@ -3867,7 +3836,7 @@ static void dct_unquantize_mpeg2_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int i, level, nCoeffs;
- const UINT16 *quant_matrix;
+ const uint16_t *quant_matrix;
if(s->alternate_scan) nCoeffs= 63;
else nCoeffs= s->block_last_index[n];
@@ -3932,7 +3901,7 @@ static void dct_unquantize_h263_c(MpegEncContext *s,
int i, level, qmul, qadd;
int nCoeffs;
- XINE_ASSERT(s->block_last_index[n]>=0 , "s->block_last_index[%d] is < 0: %d", n, s->block_last_index[n]);
+ assert(s->block_last_index[n]>=0);
qadd = (qscale - 1) | 1;
qmul = qscale << 1;
@@ -3949,7 +3918,7 @@ static void dct_unquantize_h263_c(MpegEncContext *s,
nCoeffs= 63; //does not allways use zigzag table
} else {
i = 0;
- nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
}
for(;i<=nCoeffs;i++) {
@@ -3969,6 +3938,7 @@ static void dct_unquantize_h263_c(MpegEncContext *s,
}
}
+
char ff_get_pict_type_char(int pict_type){
switch(pict_type){
case I_TYPE: return 'I';
@@ -3979,6 +3949,83 @@ char ff_get_pict_type_char(int pict_type){
}
}
+static const AVOption mpeg4_options[] =
+{
+ AVOPTION_CODEC_INT("bitrate", "desired video bitrate", bit_rate, 4, 240000000, 800000),
+ AVOPTION_CODEC_FLAG("vhq", "very high quality", flags, CODEC_FLAG_HQ, 0),
+ AVOPTION_CODEC_INT("ratetol", "number of bits the bitstream is allowed to diverge from the reference"
+ "the reference can be CBR (for CBR pass1) or VBR (for pass2)",
+ bit_rate_tolerance, 4, 240000000, 8000),
+ AVOPTION_CODEC_INT("qmin", "minimum quantizer", qmin, 1, 31, 2),
+ AVOPTION_CODEC_INT("qmax", "maximum quantizer", qmax, 1, 31, 31),
+ AVOPTION_CODEC_STRING("rc_eq", "rate control equation",
+ rc_eq, "tex^qComp,option1,options2", 0),
+ AVOPTION_CODEC_INT("rc_minrate", "rate control minimum bitrate",
+ rc_min_rate, 4, 24000000, 0),
+ AVOPTION_CODEC_INT("rc_maxrate", "rate control maximum bitrate",
+ rc_max_rate, 4, 24000000, 0),
+ AVOPTION_CODEC_DOUBLE("rc_buf_aggresivity", "rate control buffer aggresivity",
+ rc_buffer_aggressivity, 4, 24000000, 0),
+ AVOPTION_CODEC_DOUBLE("rc_initial_cplx", "initial complexity for pass1 ratecontrol",
+ rc_initial_cplx, 0., 9999999., 0),
+ AVOPTION_CODEC_DOUBLE("i_quant_factor", "qscale factor between p and i frames",
+ i_quant_factor, 0., 0., 0),
+ AVOPTION_CODEC_DOUBLE("i_quant_offset", "qscale offset between p and i frames",
+ i_quant_factor, -999999., 999999., 0),
+ AVOPTION_CODEC_INT("dct_algo", "dct alghorithm",
+ dct_algo, 0, 5, 0), // fixme - "Auto,FastInt,Int,MMX,MLib,Altivec"
+ AVOPTION_CODEC_DOUBLE("lumi_masking", "luminance masking",
+ lumi_masking, 0., 999999., 0),
+ AVOPTION_CODEC_DOUBLE("temporal_cplx_masking", "temporary complexity masking",
+ temporal_cplx_masking, 0., 999999., 0),
+ AVOPTION_CODEC_DOUBLE("spatial_cplx_masking", "spatial complexity masking",
+ spatial_cplx_masking, 0., 999999., 0),
+ AVOPTION_CODEC_DOUBLE("p_masking", "p block masking",
+ p_masking, 0., 999999., 0),
+ AVOPTION_CODEC_DOUBLE("dark_masking", "darkness masking",
+ dark_masking, 0., 999999., 0),
+ AVOPTION_CODEC_INT("idct_algo", "idct alghorithm",
+ idct_algo, 0, 8, 0), // fixme - "Auto,Int,Simple,SimpleMMX,LibMPEG2MMX,PS2,MLib,ARM,Altivec"
+
+ AVOPTION_CODEC_INT("mb_qmin", "minimum MB quantizer",
+ mb_qmin, 0, 8, 0),
+ AVOPTION_CODEC_INT("mb_qmax", "maximum MB quantizer",
+ mb_qmin, 0, 8, 0),
+
+ AVOPTION_CODEC_INT("me_cmp", "ME compare function",
+ me_cmp, 0, 24000000, 0),
+ AVOPTION_CODEC_INT("me_sub_cmp", "subpixel ME compare function",
+ me_sub_cmp, 0, 24000000, 0),
+
+
+ AVOPTION_CODEC_INT("dia_size", "ME diamond size & shape",
+ dia_size, 0, 24000000, 0),
+ AVOPTION_CODEC_INT("last_predictor_count", "amount of previous MV predictors",
+ last_predictor_count, 0, 24000000, 0),
+
+ AVOPTION_CODEC_INT("pre_me", "pre pass for ME",
+ pre_me, 0, 24000000, 0),
+ AVOPTION_CODEC_INT("me_pre_cmp", "ME pre pass compare function",
+ me_pre_cmp, 0, 24000000, 0),
+
+ AVOPTION_CODEC_INT("me_range", "maximum ME search range",
+ me_range, 0, 24000000, 0),
+ AVOPTION_CODEC_INT("pre_dia_size", "ME pre pass diamod size & shape",
+ pre_dia_size, 0, 24000000, 0),
+ AVOPTION_CODEC_INT("me_subpel_quality", "subpel ME quality",
+ me_subpel_quality, 0, 24000000, 0),
+ AVOPTION_CODEC_INT("me_range", "maximum ME search range",
+ me_range, 0, 24000000, 0),
+ AVOPTION_CODEC_FLAG("psnr", "calculate PSNR of compressed frames",
+ flags, CODEC_FLAG_PSNR, 0),
+ AVOPTION_CODEC_RCOVERRIDE("rc_override", "ratecontrol override (=startframe,endframe,qscale,quality_factor)",
+ rc_override),
+ AVOPTION_SUB(avoptions_common),
+ AVOPTION_END()
+};
+
+#ifdef CONFIG_ENCODERS
+
AVCodec mpeg1video_encoder = {
"mpeg1video",
CODEC_TYPE_VIDEO,
@@ -4029,6 +4076,7 @@ AVCodec mpeg4_encoder = {
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
+ .options = mpeg4_options,
};
AVCodec msmpeg4v1_encoder = {
@@ -4039,6 +4087,7 @@ AVCodec msmpeg4v1_encoder = {
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
+ .options = mpeg4_options,
};
AVCodec msmpeg4v2_encoder = {
@@ -4049,6 +4098,7 @@ AVCodec msmpeg4v2_encoder = {
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
+ .options = mpeg4_options,
};
AVCodec msmpeg4v3_encoder = {
@@ -4059,6 +4109,7 @@ AVCodec msmpeg4v3_encoder = {
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
+ .options = mpeg4_options,
};
AVCodec wmv1_encoder = {
@@ -4069,6 +4120,7 @@ AVCodec wmv1_encoder = {
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
+ .options = mpeg4_options,
};
#endif
@@ -4082,3 +4134,6 @@ AVCodec mjpeg_encoder = {
MPV_encode_picture,
MPV_encode_end,
};
+
+#endif //CONFIG_ENCODERS
+
diff --git a/src/libffmpeg/libavcodec/mpegvideo.h b/src/libffmpeg/libavcodec/mpegvideo.h
index 7ecc6fd38..eb45fe7b7 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.h
+++ b/src/libffmpeg/libavcodec/mpegvideo.h
@@ -17,10 +17,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * @file mpegvideo.h
+ * mpegvideo header.
+ */
+
#ifndef AVCODEC_MPEGVIDEO_H
#define AVCODEC_MPEGVIDEO_H
-#define FRAME_SKIPED 100 // return value for header parsers if frame is not coded
+#include "dsputil.h"
+
+#define FRAME_SKIPED 100 ///< return value for header parsers if frame is not coded
enum OutputFormat {
FMT_MPEG1,
@@ -48,10 +55,10 @@ enum OutputFormat {
#define MAX_RUN 64
#define MAX_LEVEL 64
-#define I_TYPE FF_I_TYPE // Intra
-#define P_TYPE FF_P_TYPE // Predicted
-#define B_TYPE FF_B_TYPE // Bi-dir predicted
-#define S_TYPE FF_S_TYPE // S(GMC)-VOP MPEG4
+#define I_TYPE FF_I_TYPE ///< Intra
+#define P_TYPE FF_P_TYPE ///< Predicted
+#define B_TYPE FF_B_TYPE ///< Bi-dir predicted
+#define S_TYPE FF_S_TYPE ///< S(GMC)-VOP MPEG4
typedef struct Predictor{
double coeff;
@@ -66,7 +73,7 @@ typedef struct RateControlEntry{
int i_tex_bits;
int p_tex_bits;
int misc_bits;
- UINT64 expected_bits;
+ uint64_t expected_bits;
int new_pict_type;
float new_qscale;
int mc_mb_var_sum;
@@ -76,52 +83,61 @@ typedef struct RateControlEntry{
int b_code;
}RateControlEntry;
+/**
+ * rate control context.
+ */
typedef struct RateControlContext{
FILE *stats_file;
- int num_entries; /* number of RateControlEntries */
+ int num_entries; ///< number of RateControlEntries
RateControlEntry *entry;
- int buffer_index; /* amount of bits in the video/audio buffer */
+ int buffer_index; ///< amount of bits in the video/audio buffer
Predictor pred[5];
- double short_term_qsum; /* sum of recent qscales */
- double short_term_qcount; /* count of recent qscales */
- double pass1_rc_eq_output_sum;/* sum of the output of the rc equation, this is used for normalization */
- double pass1_wanted_bits; /* bits which should have been outputed by the pass1 code (including complexity init) */
+ double short_term_qsum; ///< sum of recent qscales
+ double short_term_qcount; ///< count of recent qscales
+ double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
+ double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init)
double last_qscale;
- double last_qscale_for[5]; /* last qscale for a specific pict type, used for max_diff & ipb factor stuff */
+ double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
int last_mc_mb_var_sum;
int last_mb_var_sum;
- UINT64 i_cplx_sum[5];
- UINT64 p_cplx_sum[5];
- UINT64 mv_bits_sum[5];
- UINT64 qscale_sum[5];
+ uint64_t i_cplx_sum[5];
+ uint64_t p_cplx_sum[5];
+ uint64_t mv_bits_sum[5];
+ uint64_t qscale_sum[5];
int frame_count[5];
int last_non_b_pict_type;
}RateControlContext;
+/**
+ * Scantable.
+ */
typedef struct ScanTable{
- const UINT8 *scantable;
- UINT8 permutated[64];
- UINT8 raster_end[64];
+ const uint8_t *scantable;
+ uint8_t permutated[64];
+ uint8_t raster_end[64];
#ifdef ARCH_POWERPC
- /* Used by dct_quantise_alitvec to find last-non-zero */
- UINT8 __align8 inverse[64];
+ /** Used by dct_quantise_alitvec to find last-non-zero */
+ uint8_t __align8 inverse[64];
#endif
} ScanTable;
+/**
+ * Picture.
+ */
typedef struct Picture{
FF_COMMON_FRAME
- int mb_var_sum; /* sum of MB variance for current frame */
- int mc_mb_var_sum; /* motion compensated MB variance for current frame */
- uint16_t *mb_var; /* Table for MB variances */
- uint16_t *mc_mb_var; /* Table for motion compensated MB variances */
- uint8_t *mb_mean; /* Table for MB luminance */
- int32_t *mb_cmp_score; /* Table for MB cmp scores, for mb decission */
+ int mb_var_sum; ///< sum of MB variance for current frame
+ int mc_mb_var_sum; ///< motion compensated MB variance for current frame
+ uint16_t *mb_var; ///< Table for MB variances
+ uint16_t *mc_mb_var; ///< Table for motion compensated MB variances
+ uint8_t *mb_mean; ///< Table for MB luminance
+ int32_t *mb_cmp_score; ///< Table for MB cmp scores, for mb decission
int b_frame_score; /* */
} Picture;
typedef struct ParseContext{
- UINT8 *buffer;
+ uint8_t *buffer;
int index;
int last_index;
int buffer_size;
@@ -131,21 +147,24 @@ typedef struct ParseContext{
struct MpegEncContext;
+/**
+ * Motion estimation context.
+ */
typedef struct MotionEstContext{
- int skip; /* set if ME is skiped for the current MB */
- int co_located_mv[4][2]; /* mv from last p frame for direct mode ME */
+ int skip; ///< set if ME is skiped for the current MB
+ int co_located_mv[4][2]; ///< mv from last p frame for direct mode ME
int direct_basis_mv[4][2];
- uint8_t *scratchpad; /* data area for the me algo, so that the ME doesnt need to malloc/free */
- uint32_t *map; /* map to avoid duplicate evaluations */
- uint32_t *score_map; /* map to store the scores */
+ uint8_t *scratchpad; ///< data area for the me algo, so that the ME doesnt need to malloc/free
+ uint32_t *map; ///< map to avoid duplicate evaluations
+ uint32_t *score_map; ///< map to store the scores
int map_generation;
int pre_penalty_factor;
int penalty_factor;
int sub_penalty_factor;
int mb_penalty_factor;
- int pre_pass; /* = 1 for the pre pass */
+ int pre_pass; ///< = 1 for the pre pass
int dia_size;
- UINT16 (*mv_penalty)[MAX_MV*2+1]; /* amount of bits needed to encode a MV */
+ uint16_t (*mv_penalty)[MAX_MV*2+1]; ///< amount of bits needed to encode a MV
int (*sub_motion_search)(struct MpegEncContext * s,
int *mx_ptr, int *my_ptr, int dmin,
int xmin, int ymin, int xmax, int ymax,
@@ -165,138 +184,163 @@ typedef struct MotionEstContext{
uint16_t * const mv_penalty);
}MotionEstContext;
+/**
+ * MpegEncContext.
+ */
typedef struct MpegEncContext {
struct AVCodecContext *avctx;
/* the following parameters must be initialized before encoding */
- int width, height; /* picture size. must be a multiple of 16 */
+ int width, height;///< picture size. must be a multiple of 16
int gop_size;
- int frame_rate; /* number of frames per second */
- int intra_only; /* if true, only intra pictures are generated */
- int bit_rate; /* wanted bit rate */
- int bit_rate_tolerance; /* amount of +- bits (>0)*/
- enum OutputFormat out_format; /* output format */
- int h263_pred; /* use mpeg4/h263 ac/dc predictions */
+ int intra_only; ///< if true, only intra pictures are generated
+ int bit_rate; ///< wanted bit rate
+ int bit_rate_tolerance; ///< amount of +- bits (>0)
+ enum OutputFormat out_format; ///< output format
+ int h263_pred; ///< use mpeg4/h263 ac/dc predictions
/* the following codec id fields are deprecated in favor of codec_id */
- int h263_plus; /* h263 plus headers */
- int h263_rv10; /* use RV10 variation for H263 */
- int h263_msmpeg4; /* generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)*/
- int h263_intel; /* use I263 intel h263 header */
+ int h263_plus; ///< h263 plus headers
+ int h263_rv10; ///< use RV10 variation for H263
+ int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)
+ int h263_intel; ///< use I263 intel h263 header
int codec_id; /* see CODEC_ID_xxx */
- int fixed_qscale; /* fixed qscale if non zero */
- float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0) */
- float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
- int qmin; /* min qscale */
- int qmax; /* max qscale */
- int max_qdiff; /* max qscale difference between frames */
- int encoding; /* true if we are encoding (vs decoding) */
- int flags; /* AVCodecContext.flags (HQ, MV4, ...) */
- int max_b_frames; /* max number of b-frames for encoding */
+ int fixed_qscale; ///< fixed qscale if non zero
+ float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
+ float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
+ int max_qdiff; ///< max qscale difference between frames
+ int encoding; ///< true if we are encoding (vs decoding)
+ int flags; ///< AVCodecContext.flags (HQ, MV4, ...)
+ int max_b_frames; ///< max number of b-frames for encoding
int b_frame_strategy;
int luma_elim_threshold;
int chroma_elim_threshold;
- int strict_std_compliance; /* strictly follow the std (MPEG4, ...) */
- int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */
+ int strict_std_compliance; ///< strictly follow the std (MPEG4, ...)
+ int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically
/* the following fields are managed internally by the encoder */
- /* bit output */
+ /** bit output */
PutBitContext pb;
/* sequence parameters */
int context_initialized;
int input_picture_number;
int picture_number;
- int picture_in_gop_number; /* 0-> first pic in gop, ... */
- int b_frames_since_non_b; /* used for encoding, relative to not yet reordered input */
- int mb_width, mb_height; /* number of MBs horizontally & vertically */
- int h_edge_pos, v_edge_pos;/* horizontal / vertical position of the right/bottom edge (pixel replicateion)*/
- int mb_num; /* number of MBs of a picture */
- int linesize; /* line size, in bytes, may be different from width */
- int uvlinesize; /* line size, for chroma in bytes, may be different from width */
- Picture picture[MAX_PICTURE_COUNT]; /* main picture buffer */
- Picture *input_picture[MAX_PICTURE_COUNT]; /* next pictures on display order for encoding*/
- Picture *reordered_input_picture[MAX_PICTURE_COUNT]; /* pointer to the next pictures in codedorder for encoding*/
- Picture last_picture; /* previous picture */
- Picture next_picture; /* previous picture (for bidir pred) */
- Picture new_picture; /* source picture for encoding */
- Picture current_picture; /* buffer to store the decompressed current picture */
- int last_dc[3]; /* last DC values for MPEG1 */
- INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */
+ int picture_in_gop_number; ///< 0-> first pic in gop, ...
+ int b_frames_since_non_b; ///< used for encoding, relative to not yet reordered input
+ int mb_width, mb_height; ///< number of MBs horizontally & vertically
+ int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replicateion)
+ int mb_num; ///< number of MBs of a picture
+ int linesize; ///< line size, in bytes, may be different from width
+ int uvlinesize; ///< line size, for chroma in bytes, may be different from width
+ Picture picture[MAX_PICTURE_COUNT]; ///< main picture buffer
+ Picture *input_picture[MAX_PICTURE_COUNT]; ///< next pictures on display order for encoding
+ Picture *reordered_input_picture[MAX_PICTURE_COUNT]; ///< pointer to the next pictures in codedorder for encoding
+
+ /**
+ * copy of the previous picture structure.
+ * note, linesize & data, might not match the previous picture (for field pictures)
+ */
+ Picture last_picture;
+
+ /**
+ * copy of the next picture structure.
+ * note, linesize & data, might not match the next picture (for field pictures)
+ */
+ Picture next_picture;
+
+ /**
+ * copy of the source picture structure for encoding.
+ * note, linesize & data, might not match the source picture (for field pictures)
+ */
+ Picture new_picture;
+
+ /**
+ * copy of the current picture structure.
+ * note, linesize & data, might not match the current picture (for field pictures)
+ */
+ Picture current_picture; ///< buffer to store the decompressed current picture
+
+ Picture *last_picture_ptr; ///< pointer to the previous picture.
+ Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred)
+ Picture *new_picture_ptr; ///< pointer to the source picture for encoding
+ Picture *current_picture_ptr; ///< pointer to the current picture
+ int last_dc[3]; ///< last DC values for MPEG1
+ int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous
int y_dc_scale, c_dc_scale;
- UINT8 *y_dc_scale_table; /* qscale -> y_dc_scale table */
- UINT8 *c_dc_scale_table; /* qscale -> c_dc_scale table */
- UINT8 *coded_block; /* used for coded block pattern prediction (msmpeg4v3, wmv1)*/
- INT16 (*ac_val[3])[16]; /* used for for mpeg4 AC prediction, all 3 arrays must be continuous */
+ uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table
+ uint8_t *c_dc_scale_table; ///< qscale -> c_dc_scale table
+ uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
+ int16_t (*ac_val[3])[16]; ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous
int ac_pred;
- uint8_t *prev_pict_types; /* previous picture types in bitstream order, used for mb skip */
+ uint8_t *prev_pict_types; ///< previous picture types in bitstream order, used for mb skip
#define PREV_PICT_TYPES_BUFFER_SIZE 256
- int mb_skiped; /* MUST BE SET only during DECODING */
- UINT8 *mbskip_table; /* used to avoid copy if macroblock skipped (for black regions for example)
+ int mb_skiped; ///< MUST BE SET only during DECODING
+ uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example)
and used for b-frame encoding & decoding (contains skip table of next P Frame) */
- UINT8 *mbintra_table; /* used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding */
- UINT8 *cbp_table; /* used to store cbp, ac_pred for partitioned decoding */
- UINT8 *pred_dir_table; /* used to store pred_dir for partitioned decoding */
+ uint8_t *mbintra_table; ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
+ uint8_t *cbp_table; ///< used to store cbp, ac_pred for partitioned decoding
+ uint8_t *pred_dir_table; ///< used to store pred_dir for partitioned decoding
uint8_t *allocated_edge_emu_buffer;
- uint8_t *edge_emu_buffer; /* points into the middle of allocated_edge_emu_buffer */
+ uint8_t *edge_emu_buffer; ///< points into the middle of allocated_edge_emu_buffer
- int qscale; /* QP */
- float frame_qscale; /* qscale from the frame level rc FIXME remove*/
- int adaptive_quant; /* use adaptive quantization */
- int dquant; /* qscale difference to prev qscale */
- int pict_type; /* I_TYPE, P_TYPE, B_TYPE, ... */
+ int qscale; ///< QP
+ float frame_qscale; ///< qscale from the frame level rc FIXME remove
+ int adaptive_quant; ///< use adaptive quantization
+ int dquant; ///< qscale difference to prev qscale
+ int pict_type; ///< I_TYPE, P_TYPE, B_TYPE, ...
int last_pict_type;
- int last_non_b_pict_type; /* used for mpeg4 gmc b-frames & ratecontrol */
+ int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol
int frame_rate_index;
/* motion compensation */
- int unrestricted_mv;
- int h263_long_vectors; /* use horrible h263v1 long vector mode */
-
- DSPContext dsp; /* pointers for accelerated dsp fucntions */
- int f_code; /* forward MV resolution */
- int b_code; /* backward MV resolution for B Frames (mpeg4) */
- INT16 (*motion_val)[2]; /* used for MV prediction (4MV per MB) */
- INT16 (*p_mv_table)[2]; /* MV table (1MV per MB) p-frame encoding */
- INT16 (*b_forw_mv_table)[2]; /* MV table (1MV per MB) forward mode b-frame encoding */
- INT16 (*b_back_mv_table)[2]; /* MV table (1MV per MB) backward mode b-frame encoding */
- INT16 (*b_bidir_forw_mv_table)[2]; /* MV table (1MV per MB) bidir mode b-frame encoding */
- INT16 (*b_bidir_back_mv_table)[2]; /* MV table (1MV per MB) bidir mode b-frame encoding */
- INT16 (*b_direct_mv_table)[2]; /* MV table (1MV per MB) direct mode b-frame encoding */
- int me_method; /* ME algorithm */
+ int unrestricted_mv; ///< mv can point outside of the coded picture
+ int h263_long_vectors; ///< use horrible h263v1 long vector mode
+
+ DSPContext dsp; ///< pointers for accelerated dsp fucntions
+ int f_code; ///< forward MV resolution
+ int b_code; ///< backward MV resolution for B Frames (mpeg4)
+ int16_t (*motion_val)[2]; ///< used for MV prediction (4MV per MB)
+ int16_t (*p_mv_table)[2]; ///< MV table (1MV per MB) p-frame encoding
+ int16_t (*b_forw_mv_table)[2]; ///< MV table (1MV per MB) forward mode b-frame encoding
+ int16_t (*b_back_mv_table)[2]; ///< MV table (1MV per MB) backward mode b-frame encoding
+ int16_t (*b_bidir_forw_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding
+ int16_t (*b_bidir_back_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding
+ int16_t (*b_direct_mv_table)[2]; ///< MV table (1MV per MB) direct mode b-frame encoding
+ int me_method; ///< ME algorithm
int scene_change_score;
int mv_dir;
#define MV_DIR_BACKWARD 1
#define MV_DIR_FORWARD 2
-#define MV_DIRECT 4 // bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
+#define MV_DIRECT 4 ///< bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
int mv_type;
-#define MV_TYPE_16X16 0 /* 1 vector for the whole mb */
-#define MV_TYPE_8X8 1 /* 4 vectors (h263, mpeg4 4MV) */
-#define MV_TYPE_16X8 2 /* 2 vectors, one per 16x8 block */
-#define MV_TYPE_FIELD 3 /* 2 vectors, one per field */
-#define MV_TYPE_DMV 4 /* 2 vectors, special mpeg2 Dual Prime Vectors */
- /* motion vectors for a macroblock
+#define MV_TYPE_16X16 0 ///< 1 vector for the whole mb
+#define MV_TYPE_8X8 1 ///< 4 vectors (h263, mpeg4 4MV)
+#define MV_TYPE_16X8 2 ///< 2 vectors, one per 16x8 block
+#define MV_TYPE_FIELD 3 ///< 2 vectors, one per field
+#define MV_TYPE_DMV 4 ///< 2 vectors, special mpeg2 Dual Prime Vectors
+ /**motion vectors for a macroblock
first coordinate : 0 = forward 1 = backward
second " : depend on type
third " : 0 = x, 1 = y
*/
int mv[2][4][2];
int field_select[2][2];
- int last_mv[2][2][2]; /* last MV, used for MV prediction in MPEG1 & B-frame MPEG4 */
- UINT8 *fcode_tab; /* smallest fcode needed for each MV */
+ int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG1 & B-frame MPEG4
+ uint8_t *fcode_tab; ///< smallest fcode needed for each MV
MotionEstContext me;
- int no_rounding; /* apply no rounding to motion compensation (MPEG4, msmpeg4, ...)
+ int no_rounding; /**< apply no rounding to motion compensation (MPEG4, msmpeg4, ...)
for b-frames rounding mode is allways 0 */
- int hurry_up; /* when set to 1 during decoding, b frames will be skiped
+ int hurry_up; /**< when set to 1 during decoding, b frames will be skiped
when set to 2 idct/dequant will be skipped too */
/* macroblock layer */
int mb_x, mb_y;
int mb_incr;
int mb_intra;
- UINT8 *mb_type; /* Table for MB type */
+ uint8_t *mb_type; ///< Table for MB type
#define MB_TYPE_INTRA 0x01
#define MB_TYPE_INTER 0x02
#define MB_TYPE_INTER4V 0x04
@@ -308,20 +352,20 @@ typedef struct MpegEncContext {
#define MB_TYPE_BACKWARD 0x40
#define MB_TYPE_BIDIR 0x80
- int block_index[6]; /* index to current MB in block based arrays with edges*/
+ int block_index[6]; ///< index to current MB in block based arrays with edges
int block_wrap[6];
- /* matrix transmitted in the bitstream */
- UINT16 intra_matrix[64];
- UINT16 chroma_intra_matrix[64];
- UINT16 inter_matrix[64];
- UINT16 chroma_inter_matrix[64];
-#define QUANT_BIAS_SHIFT 4
- int intra_quant_bias; /* bias for the quantizer */
- int inter_quant_bias; /* bias for the quantizer */
- int min_qcoeff; /* minimum encodable coefficient */
- int max_qcoeff; /* maximum encodable coefficient */
- int ac_esc_length; /* num of bits needed to encode the longest esc */
+ /** matrix transmitted in the bitstream */
+ uint16_t intra_matrix[64];
+ uint16_t chroma_intra_matrix[64];
+ uint16_t inter_matrix[64];
+ uint16_t chroma_inter_matrix[64];
+#define QUANT_BIAS_SHIFT 8
+ int intra_quant_bias; ///< bias for the quantizer
+ int inter_quant_bias; ///< bias for the quantizer
+ int min_qcoeff; ///< minimum encodable coefficient
+ int max_qcoeff; ///< maximum encodable coefficient
+ int ac_esc_length; ///< num of bits needed to encode the longest esc
uint8_t *intra_ac_vlc_length;
uint8_t *intra_ac_vlc_last_length;
uint8_t *inter_ac_vlc_length;
@@ -330,35 +374,29 @@ typedef struct MpegEncContext {
uint8_t *chroma_dc_vlc_length;
#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
- /* precomputed matrix (combine qscale and DCT renorm) */
+ /** precomputed matrix (combine qscale and DCT renorm) */
int __align8 q_intra_matrix[32][64];
int __align8 q_inter_matrix[32][64];
- /* identical to the above but for MMX & these are not permutated */
- UINT16 __align8 q_intra_matrix16[32][64];
- UINT16 __align8 q_inter_matrix16[32][64];
- UINT16 __align8 q_intra_matrix16_bias[32][64];
- UINT16 __align8 q_inter_matrix16_bias[32][64];
- int block_last_index[6]; /* last non zero coefficient in block */
+ /** identical to the above but for MMX & these are not permutated */
+ uint16_t __align8 q_intra_matrix16[32][64];
+ uint16_t __align8 q_inter_matrix16[32][64];
+ uint16_t __align8 q_intra_matrix16_bias[32][64];
+ uint16_t __align8 q_inter_matrix16_bias[32][64];
+ int block_last_index[6]; ///< last non zero coefficient in block
/* scantables */
ScanTable __align8 intra_scantable;
ScanTable intra_h_scantable;
ScanTable intra_v_scantable;
- ScanTable inter_scantable; // if inter == intra then intra should be used to reduce tha cache usage
- UINT8 idct_permutation[64];
- int idct_permutation_type;
-#define FF_NO_IDCT_PERM 1
-#define FF_LIBMPEG2_IDCT_PERM 2
-#define FF_SIMPLE_IDCT_PERM 3
-#define FF_TRANSPOSE_IDCT_PERM 4
+ ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
- void *opaque; /* private data for the user */
+ void *opaque; ///< private data for the user
/* bit rate control */
int I_frame_bits; //FIXME used in mpeg12 ...
- INT64 wanted_bits;
- INT64 total_bits;
- int frame_bits; /* bits used for the current frame */
- RateControlContext rc_context; // contains stuff only accessed in ratecontrol.c
+ int64_t wanted_bits;
+ int64_t total_bits;
+ int frame_bits; ///< bits used for the current frame
+ RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c
/* statistics, used for 2-pass encoding */
int mv_bits;
@@ -369,12 +407,12 @@ typedef struct MpegEncContext {
int f_count;
int b_count;
int skip_count;
- int misc_bits; // cbp, mb_type
- int last_bits; //temp var used for calculating the above vars
+ int misc_bits; ///< cbp, mb_type
+ int last_bits; ///< temp var used for calculating the above vars
/* error concealment / resync */
- UINT8 *error_status_table; /* table of the error status of each MB */
-#define VP_START 1 /* current MB is the first after a resync marker */
+ uint8_t *error_status_table; ///< table of the error status of each MB
+#define VP_START 1 ///< current MB is the first after a resync marker
#define AC_ERROR 2
#define DC_ERROR 4
#define MV_ERROR 8
@@ -383,11 +421,11 @@ typedef struct MpegEncContext {
#define MV_END 64
//FIXME some prefix?
- int resync_mb_x; /* x position of last resync marker */
- int resync_mb_y; /* y position of last resync marker */
- GetBitContext last_resync_gb; /* used to search for the next resync marker */
- int mb_num_left; /* number of MBs left in this video packet (for partitioned Slices only)*/
- int next_p_frame_damaged; /* set if the next p frame is damaged, to avoid showing trashed b frames */
+ int resync_mb_x; ///< x position of last resync marker
+ int resync_mb_y; ///< y position of last resync marker
+ GetBitContext last_resync_gb; ///< used to search for the next resync marker
+ int mb_num_left; ///< number of MBs left in this video packet (for partitioned Slices only)
+ int next_p_frame_damaged; ///< set if the next p frame is damaged, to avoid showing trashed b frames
int error_resilience;
ParseContext parse_context;
@@ -397,22 +435,21 @@ typedef struct MpegEncContext {
int gob_index;
/* H.263+ specific */
- int umvplus;
- int umvplus_dec;
- int h263_aic; /* Advanded INTRA Coding (AIC) */
- int h263_aic_dir; /* AIC direction: 0 = left, 1 = top */
+ int umvplus; ///< == H263+ && unrestricted_mv
+ int h263_aic; ///< Advanded INTRA Coding (AIC)
+ int h263_aic_dir; ///< AIC direction: 0 = left, 1 = top
/* mpeg4 specific */
int time_increment_resolution;
- int time_increment_bits; /* number of bits to represent the fractional part of time */
+ int time_increment_bits; ///< number of bits to represent the fractional part of time
int last_time_base;
- int time_base; /* time in seconds of last I,P,S Frame */
- INT64 time; /* time of current frame */
- INT64 last_non_b_time;
- UINT16 pp_time; /* time distance between the last 2 p,s,i frames */
- UINT16 pb_time; /* time distance between the last b and p,s,i frame */
- UINT16 pp_field_time;
- UINT16 pb_field_time; /* like above, just for interlaced */
+ int time_base; ///< time in seconds of last I,P,S Frame
+ int64_t time; ///< time of current frame
+ int64_t last_non_b_time;
+ uint16_t pp_time; ///< time distance between the last 2 p,s,i frames
+ uint16_t pb_time; ///< time distance between the last b and p,s,i frame
+ uint16_t pp_field_time;
+ uint16_t pb_field_time; ///< like above, just for interlaced
int shape;
int vol_sprite_usage;
int sprite_width;
@@ -422,12 +459,12 @@ typedef struct MpegEncContext {
int sprite_brightness_change;
int num_sprite_warping_points;
int real_sprite_warping_points;
- int sprite_offset[2][2]; /* sprite offset[isChroma][isMVY] */
- int sprite_delta[2][2]; /* sprite_delta [isY][isMVY] */
- int sprite_shift[2]; /* sprite shift [isChroma] */
+ int sprite_offset[2][2]; ///< sprite offset[isChroma][isMVY]
+ int sprite_delta[2][2]; ///< sprite_delta [isY][isMVY]
+ int sprite_shift[2]; ///< sprite shift [isChroma]
int mcsel;
int quant_precision;
- int quarter_sample; /* 1->qpel, 0->half pel ME/MC */
+ int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
int scalability;
int hierachy_type;
int enhancement_type;
@@ -438,32 +475,33 @@ typedef struct MpegEncContext {
int aspected_height;
int sprite_warping_accuracy;
int low_latency_sprite;
- int data_partitioning; /* data partitioning flag from header */
- int partitioned_frame; /* is current frame partitioned */
- int rvlc; /* reversible vlc */
- int resync_marker; /* could this stream contain resync markers*/
- int low_delay; /* no reordering needed / has no b-frames */
+ int data_partitioning; ///< data partitioning flag from header
+ int partitioned_frame; ///< is current frame partitioned
+ int rvlc; ///< reversible vlc
+ int resync_marker; ///< could this stream contain resync markers
+ int low_delay; ///< no reordering needed / has no b-frames
int vo_type;
- int vol_control_parameters; /* does the stream contain the low_delay flag, used to workaround buggy encoders */
- PutBitContext tex_pb; /* used for data partitioned VOPs */
- PutBitContext pb2; /* used for data partitioned VOPs */
+ int vol_control_parameters; ///< does the stream contain the low_delay flag, used to workaround buggy encoders
+ PutBitContext tex_pb; ///< used for data partitioned VOPs
+ PutBitContext pb2; ///< used for data partitioned VOPs
#define PB_BUFFER_SIZE 1024*256
uint8_t *tex_pb_buffer;
uint8_t *pb2_buffer;
int mpeg_quant;
#define CO_LOCATED_TYPE_4MV 1
#define CO_LOCATED_TYPE_FIELDMV 2
- INT8 *co_located_type_table; /* 4mv & field_mv info for next b frame */
- INT16 (*field_mv_table)[2][2]; /* used for interlaced b frame decoding */
- INT8 (*field_select_table)[2]; /* wtf, no really another table for interlaced b frames */
- int t_frame; /* time distance of first I -> B, used for interlaced b frames */
- int padding_bug_score; /* used to detect the VERY common padding bug in MPEG4 */
+ int8_t *co_located_type_table; ///< 4mv & field_mv info for next b frame
+ int16_t (*field_mv_table)[2][2]; ///< used for interlaced b frame decoding
+ int8_t (*field_select_table)[2]; ///< wtf, no really another table for interlaced b frames
+ int t_frame; ///< time distance of first I -> B, used for interlaced b frames
+ int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG4
/* divx specific, used to workaround (many) bugs in divx5 */
int divx_version;
int divx_build;
+ int divx_packed;
#define BITSTREAM_BUFFER_SIZE 1024*256
- UINT8 *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
+ uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
int bitstream_buffer_size;
int xvid_build;
@@ -473,16 +511,15 @@ typedef struct MpegEncContext {
int lavc_build;
/* RV10 specific */
- int rv10_version; /* RV10 version: 0 or 3 */
+ int rv10_version; ///< RV10 version: 0 or 3
int rv10_first_dc_coded[3];
/* MJPEG specific */
struct MJpegContext *mjpeg_ctx;
- int mjpeg_vsample[3]; /* vertical sampling factors, default = {2, 1, 1} */
- int mjpeg_hsample[3]; /* horizontal sampling factors, default = {2, 1, 1} */
- int mjpeg_write_tables; /* do we want to have quantisation- and
- huffmantables in the jpeg file ? */
- int mjpeg_data_only_frames; /* frames only with SOI, SOS and EOI markers */
+ int mjpeg_vsample[3]; ///< vertical sampling factors, default = {2, 1, 1}
+ int mjpeg_hsample[3]; ///< horizontal sampling factors, default = {2, 1, 1}
+ int mjpeg_write_tables; ///< do we want to have quantisation- and huffmantables in the jpeg file ?
+ int mjpeg_data_only_frames; ///< frames only with SOI, SOS and EOI markers
/* MSMPEG4 specific */
int mv_table_index;
@@ -490,14 +527,14 @@ typedef struct MpegEncContext {
int rl_chroma_table_index;
int dc_table_index;
int use_skip_mb_code;
- int slice_height; /* in macroblocks */
- int first_slice_line; /* used in mpeg4 too to handle resync markers */
+ int slice_height; ///< in macroblocks
+ int first_slice_line; ///< used in mpeg4 too to handle resync markers
int flipflop_rounding;
- int msmpeg4_version; /* 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8*/
+ int msmpeg4_version; ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
int per_mb_rl_table;
int esc3_level_length;
int esc3_run_length;
- /* [mb_intra][isChroma][level][run][last] */
+ /** [mb_intra][isChroma][level][run][last] */
int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
int inter_intra_pred;
int mspel;
@@ -506,8 +543,9 @@ typedef struct MpegEncContext {
GetBitContext gb;
/* Mpeg1 specific */
- int fake_picture_number; /* picture number at the bitstream frame rate */
- int gop_picture_number; /* index of the first picture of a GOP based on fake_pic_num & mpeg1 specific */
+ int fake_picture_number; ///< picture number at the bitstream frame rate
+ int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num & mpeg1 specific
+ int last_mv_dir; ///< last mv_dir, used for b frame encoding
/* MPEG2 specific - I wish I had not to support this mess. */
int progressive_sequence;
@@ -532,17 +570,18 @@ typedef struct MpegEncContext {
int full_pel[2];
int interlaced_dct;
int first_slice;
+ int first_field;
/* RTP specific */
/* These are explained on avcodec.h */
int rtp_mode;
int rtp_payload_size;
void (*rtp_callback)(void *data, int size, int packet_number);
- UINT8 *ptr_lastgob;
- UINT8 *ptr_last_mb_line;
- UINT32 mb_line_avgsize;
+ uint8_t *ptr_lastgob;
+ uint8_t *ptr_last_mb_line;
+ uint32_t mb_line_avgsize;
- DCTELEM (*block)[64]; /* points to one of the following blocks */
+ DCTELEM (*block)[64]; ///< points to one of the following blocks
DCTELEM blocks[2][6][64] __align8; // for HQ mode we need to keep the best block
int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]); // used by some codecs to avoid a switch()
#define SLICE_OK 0
@@ -560,10 +599,6 @@ typedef struct MpegEncContext {
DCTELEM *block/*align 16*/, int n, int qscale);
int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
- void (*fdct)(DCTELEM *block/* align 16*/);
- void (*idct_put)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
- void (*idct_add)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
- //FIXME move above funcs into dspContext perhaps
} MpegEncContext;
@@ -594,21 +629,22 @@ void MPV_common_init_armv4l(MpegEncContext *s);
#ifdef ARCH_POWERPC
void MPV_common_init_ppc(MpegEncContext *s);
#endif
-extern void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w);
-void ff_conceal_past_errors(MpegEncContext *s, int conceal_all);
-void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length);
+extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
+void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length);
void ff_clean_intra_table_entries(MpegEncContext *s);
-void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scantable);
-void ff_error_resilience(MpegEncContext *s);
-void ff_draw_horiz_band(MpegEncContext *s);
-void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_w, int block_h,
+void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable);
+void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
+void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h);
char ff_get_pict_type_char(int pict_type);
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
-extern enum PixelFormat ff_yuv420p_list[2];
+void ff_er_frame_start(MpegEncContext *s);
+void ff_er_frame_end(MpegEncContext *s);
+void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status);
+
-extern int ff_bit_exact;
+extern enum PixelFormat ff_yuv420p_list[2];
static inline void ff_init_block_index(MpegEncContext *s){
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
@@ -642,9 +678,9 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
/* mpeg12.c */
-extern const INT16 ff_mpeg1_default_intra_matrix[64];
-extern const INT16 ff_mpeg1_default_non_intra_matrix[64];
-extern UINT8 ff_mpeg1_dc_scale_table[128];
+extern const int16_t ff_mpeg1_default_intra_matrix[64];
+extern const int16_t ff_mpeg1_default_non_intra_matrix[64];
+extern uint8_t ff_mpeg1_dc_scale_table[128];
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
void mpeg1_encode_mb(MpegEncContext *s,
@@ -653,18 +689,18 @@ void mpeg1_encode_mb(MpegEncContext *s,
void ff_mpeg1_encode_init(MpegEncContext *s);
-/* h263enc.c */
+/** RLTable. */
typedef struct RLTable {
- int n; /* number of entries of table_vlc minus 1 */
- int last; /* number of values for last = 0 */
- const UINT16 (*table_vlc)[2];
- const INT8 *table_run;
- const INT8 *table_level;
- UINT8 *index_run[2]; /* encoding only */
- INT8 *max_level[2]; /* encoding & decoding */
- INT8 *max_run[2]; /* encoding & decoding */
- VLC vlc; /* decoding only deprected FIXME remove*/
- RL_VLC_ELEM *rl_vlc[32]; /* decoding only */
+ int n; ///< number of entries of table_vlc minus 1
+ int last; ///< number of values for last = 0
+ const uint16_t (*table_vlc)[2];
+ const int8_t *table_run;
+ const int8_t *table_level;
+ uint8_t *index_run[2]; ///< encoding only
+ int8_t *max_level[2]; ///< encoding & decoding
+ int8_t *max_run[2]; ///< encoding & decoding
+ VLC vlc; ///< decoding only deprected FIXME remove
+ RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
} RLTable;
void init_rl(RLTable *rl);
@@ -681,14 +717,14 @@ static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
return index + level - 1;
}
-extern UINT8 ff_mpeg4_y_dc_scale_table[32];
-extern UINT8 ff_mpeg4_c_dc_scale_table[32];
-extern const INT16 ff_mpeg4_default_intra_matrix[64];
-extern const INT16 ff_mpeg4_default_non_intra_matrix[64];
+extern uint8_t ff_mpeg4_y_dc_scale_table[32];
+extern uint8_t ff_mpeg4_c_dc_scale_table[32];
+extern const int16_t ff_mpeg4_default_intra_matrix[64];
+extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
int ff_h263_decode_init(AVCodecContext *avctx);
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size);
+ uint8_t *buf, int buf_size);
int ff_h263_decode_end(AVCodecContext *avctx);
void h263_encode_mb(MpegEncContext *s,
DCTELEM block[6][64],
@@ -698,7 +734,7 @@ void mpeg4_encode_mb(MpegEncContext *s,
int motion_x, int motion_y);
void h263_encode_picture_header(MpegEncContext *s, int picture_number);
int h263_encode_gob_header(MpegEncContext * s, int mb_line);
-INT16 *h263_pred_motion(MpegEncContext * s, int block,
+int16_t *h263_pred_motion(MpegEncContext * s, int block,
int *px, int *py);
void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
int dir);
@@ -748,8 +784,8 @@ void ff_msmpeg4_encode_init(MpegEncContext *s);
int ff_wmv2_decode_picture_header(MpegEncContext * s);
void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
void ff_mspel_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
- UINT8 **ref_picture, op_pixels_func (*pix_op)[4],
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
+ uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h);
int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
void ff_wmv2_encode_mb(MpegEncContext * s,
@@ -770,8 +806,8 @@ int ff_rate_control_init(MpegEncContext *s);
float ff_rate_estimate_qscale(MpegEncContext *s);
void ff_write_pass1_stats(MpegEncContext *s);
void ff_rate_control_uninit(MpegEncContext *s);
-double ff_eval(char *s, double *const_value, char **const_name,
- double (**func1)(void *, double), char **func1_name,
+double ff_eval(char *s, double *const_value, const char **const_name,
+ double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
void *opaque);
diff --git a/src/libffmpeg/libavcodec/msmpeg4.c b/src/libffmpeg/libavcodec/msmpeg4.c
index 2c524a067..4bac6d3b7 100644
--- a/src/libffmpeg/libavcodec/msmpeg4.c
+++ b/src/libffmpeg/libavcodec/msmpeg4.c
@@ -18,6 +18,12 @@
*
* msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
*/
+
+/**
+ * @file msmpeg4.c
+ * MSMPEG4 backend for ffmpeg encoder and decoder.
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -50,24 +56,30 @@
#define DEFAULT_INTER_INDEX 3
-static UINT32 v2_dc_lum_table[512][2];
-static UINT32 v2_dc_chroma_table[512][2];
+static uint32_t v2_dc_lum_table[512][2];
+static uint32_t v2_dc_chroma_table[512][2];
+#ifdef CONFIG_ENCODERS
static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n);
+#endif //CONFIG_ENCODERS
static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, const uint8_t *scantable);
static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
static int msmpeg4_decode_motion(MpegEncContext * s,
int *mx_ptr, int *my_ptr);
+#ifdef CONFIG_ENCODERS
static void msmpeg4v2_encode_motion(MpegEncContext * s, int val);
+#endif //CONFIG_ENCODERS
static void init_h263_dc_for_msmpeg4(void);
static inline void msmpeg4_memsetw(short *tab, int val, int n);
+#ifdef CONFIG_ENCODERS
static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra);
+#endif //CONFIG_ENCODERS
static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
-extern UINT32 inverse[256];
+extern uint32_t inverse[256];
#ifdef DEBUG
@@ -77,7 +89,7 @@ int frame_count = 0;
#include "msmpeg4data.h"
-static UINT8 rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
+static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
#ifdef STATS
@@ -185,12 +197,14 @@ static void common_init(MpegEncContext * s)
}
}
+#ifdef CONFIG_ENCODERS
+
/* build the table which associate a (x,y) motion vector to a vlc */
static void init_mv_table(MVTable *tab)
{
int i, x, y;
- tab->table_mv_index = av_malloc(sizeof(UINT16) * 4096);
+ tab->table_mv_index = av_malloc(sizeof(uint16_t) * 4096);
/* mark all entries as not used */
for(i=0;i<4096;i++)
tab->table_mv_index[i] = tab->n;
@@ -421,7 +435,7 @@ void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
void msmpeg4_encode_ext_header(MpegEncContext * s)
{
- put_bits(&s->pb, 5, s->frame_rate / FRAME_RATE_BASE); //yes 29.97 -> 29
+ put_bits(&s->pb, 5, s->avctx->frame_rate / s->avctx->frame_rate_base); //yes 29.97 -> 29
put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
@@ -433,8 +447,10 @@ void msmpeg4_encode_ext_header(MpegEncContext * s)
}
}
+#endif //CONFIG_ENCODERS
+
/* predict coded block */
-static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_block_ptr)
+static inline int coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr)
{
int xy, wrap, pred, a, b, c;
@@ -460,6 +476,8 @@ static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_bloc
return pred;
}
+#ifdef CONFIG_ENCODERS
+
static void msmpeg4_encode_motion(MpegEncContext * s,
int mx, int my)
{
@@ -518,7 +536,7 @@ void msmpeg4_encode_mb(MpegEncContext * s,
{
int cbp, coded_cbp, i;
int pred_x, pred_y;
- UINT8 *coded_block;
+ uint8_t *coded_block;
handle_slices(s);
@@ -624,8 +642,10 @@ void msmpeg4_encode_mb(MpegEncContext * s,
}
}
+#endif //CONFIG_ENCODERS
+
/* old ffmpeg msmpeg4v3 mode */
-void ff_old_msmpeg4_dc_scale(MpegEncContext * s)
+static void ff_old_msmpeg4_dc_scale(MpegEncContext * s)
{
if (s->qscale < 5){
s->y_dc_scale = 8;
@@ -640,7 +660,7 @@ void ff_old_msmpeg4_dc_scale(MpegEncContext * s)
}
static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
- INT32 **dc_val_ptr)
+ int32_t **dc_val_ptr)
{
int i;
@@ -669,10 +689,10 @@ static int get_dc(uint8_t *src, int stride, int scale)
/* dir = 0: left, dir = 1: top prediction */
static inline int msmpeg4_pred_dc(MpegEncContext * s, int n,
- UINT16 **dc_val_ptr, int *dir_ptr)
+ uint16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred, scale;
- INT16 *dc_val;
+ int16_t *dc_val;
/* find prediction */
if (n < 4) {
@@ -817,19 +837,21 @@ static inline int msmpeg4_pred_dc(MpegEncContext * s, int n,
#define DC_MAX 119
+#ifdef CONFIG_ENCODERS
+
static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
{
int sign, code;
int pred;
if(s->msmpeg4_version==1){
- INT32 *dc_val;
+ int32_t *dc_val;
pred = msmpeg4v1_pred_dc(s, n, &dc_val);
/* update predictor */
*dc_val= level;
}else{
- UINT16 *dc_val;
+ uint16_t *dc_val;
pred = msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
/* update predictor */
@@ -895,7 +917,7 @@ static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int
int last_non_zero, sign, slevel;
int code, run_diff, dc_pred_dir;
const RLTable *rl;
- const UINT8 *scantable;
+ const uint8_t *scantable;
if (s->mb_intra) {
set_stat(ST_DC);
@@ -1009,6 +1031,8 @@ else
}
}
+#endif //CONFIG_ENCODERS
+
/****************************************/
/* decoding stuff */
@@ -1228,6 +1252,10 @@ return -1;
}
#endif
s->qscale = get_bits(&s->gb, 5);
+ if(s->qscale==0){
+ fprintf(stderr, "invalid qscale\n");
+ return -1;
+ }
if (s->pict_type == I_TYPE) {
code = get_bits(&s->gb, 5);
@@ -1387,6 +1415,8 @@ static inline void msmpeg4_memsetw(short *tab, int val, int n)
tab[i] = val;
}
+#ifdef CONFIG_ENCODERS
+
static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
{
int range, bit_size, sign, code, bits;
@@ -1420,6 +1450,8 @@ static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
}
}
+#endif //CONFIG_ENCODERS
+
/* this is identical to h263 except that its range is multiplied by 2 */
static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
{
@@ -1454,8 +1486,6 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
{
int cbp, code, i;
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0;
-
if (s->pict_type == P_TYPE) {
if (s->use_skip_mb_code) {
if (get_bits1(&s->gb)) {
@@ -1540,7 +1570,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
{
int cbp, code, i;
- UINT8 *coded_val;
+ uint8_t *coded_val;
#ifdef PRINT_MB
if(s->mb_x==0){
@@ -1549,8 +1579,6 @@ if(s->mb_x==0){
}
#endif
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0;
-
if (s->pict_type == P_TYPE) {
set_stat(ST_INTER_MB);
if (s->use_skip_mb_code) {
@@ -1935,14 +1963,14 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
}
if(s->msmpeg4_version==1){
- INT32 *dc_val;
+ int32_t *dc_val;
pred = msmpeg4v1_pred_dc(s, n, &dc_val);
level += pred;
/* update predictor */
*dc_val= level;
}else{
- UINT16 *dc_val;
+ uint16_t *dc_val;
pred = msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
level += pred;
diff --git a/src/libffmpeg/libavcodec/msmpeg4data.h b/src/libffmpeg/libavcodec/msmpeg4data.h
index 2c3a28f0e..69568cbf6 100644
--- a/src/libffmpeg/libavcodec/msmpeg4data.h
+++ b/src/libffmpeg/libavcodec/msmpeg4data.h
@@ -1,4 +1,5 @@
-/*
+/**
+ * @file msmpeg4data.h
* MSMPEG4 data tables.
*/
diff --git a/src/libffmpeg/libavcodec/opts.c b/src/libffmpeg/libavcodec/opts.c
new file mode 100644
index 000000000..44a213397
--- /dev/null
+++ b/src/libffmpeg/libavcodec/opts.c
@@ -0,0 +1,192 @@
+/*
+ * LGPL
+ */
+
+/**
+ * @file opts.c
+ * options parser.
+ * typical parsed command line:
+ * msmpeg4:bitrate=720000:qmax=16
+ *
+ */
+
+#include "avcodec.h"
+#include "os_support.h"
+
+const AVOption avoptions_common[] = {
+ AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
+ AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
+#ifdef HAVE_MMX
+ AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
+ AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
+ AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
+ AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
+ AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
+#endif
+ AVOPTION_END()
+};
+
+const AVOption avoptions_workaround_bug[] = {
+ AVOPTION_CODEC_FLAG("bug_autodetect", "workaround bug autodetection", workaround_bugs, FF_BUG_AUTODETECT, 1),
+ AVOPTION_CODEC_FLAG("bug_old_msmpeg4", "workaround old msmpeg4 bug", workaround_bugs, FF_BUG_OLD_MSMPEG4, 0),
+ AVOPTION_CODEC_FLAG("bug_xvid_ilace", "workaround XviD interlace bug", workaround_bugs, FF_BUG_XVID_ILACE, 0),
+ AVOPTION_CODEC_FLAG("bug_ump4", "workaround ump4 bug", workaround_bugs, FF_BUG_UMP4, 0),
+ AVOPTION_CODEC_FLAG("bug_no_padding", "workaround padding bug", workaround_bugs, FF_BUG_NO_PADDING, 0),
+ AVOPTION_CODEC_FLAG("bug_ac_vlc", "workaround ac VLC bug", workaround_bugs, FF_BUG_AC_VLC, 0),
+ AVOPTION_CODEC_FLAG("bug_qpel_chroma", "workaround qpel chroma bug", workaround_bugs, FF_BUG_QPEL_CHROMA, 0),
+ AVOPTION_CODEC_FLAG("bug_std_qpel", "workaround std qpel bug", workaround_bugs, FF_BUG_STD_QPEL, 0),
+ AVOPTION_CODEC_FLAG("bug_qpel_chroma2", "workaround qpel chroma2 bug", workaround_bugs, FF_BUG_QPEL_CHROMA2, 0),
+ AVOPTION_CODEC_FLAG("bug_direct_blocksize", "workaround direct blocksize bug", workaround_bugs, FF_BUG_DIRECT_BLOCKSIZE, 0),
+ AVOPTION_END()
+};
+
+
+static int parse_bool(const AVOption *c, char *s, int *var)
+{
+ int b = 1; /* by default -on- when present */
+ if (s) {
+ if (!strcasecmp(s, "off") || !strcasecmp(s, "false")
+ || !strcmp(s, "0"))
+ b = 0;
+ else if (!strcasecmp(s, "on") || !strcasecmp(s, "true")
+ || !strcmp(s, "1"))
+ b = 1;
+ else
+ return -1;
+ }
+
+ if (c->type == FF_OPT_TYPE_FLAG) {
+ if (b)
+ *var |= (int)c->min;
+ else
+ *var &= ~(int)c->min;
+ } else
+ *var = b;
+ return 0;
+}
+
+static int parse_double(const AVOption *c, char *s, double *var)
+{
+ double d;
+ if (!s)
+ return -1;
+ d = atof(s);
+ if (c->min != c->max) {
+ if (d < c->min || d > c->max) {
+ fprintf(stderr, "Option: %s double value: %f out of range <%f, %f>\n",
+ c->name, d, c->min, c->max);
+ return -1;
+ }
+ }
+ *var = d;
+ return 0;
+}
+
+static int parse_int(const AVOption* c, char* s, int* var)
+{
+ int i;
+ if (!s)
+ return -1;
+ i = atoi(s);
+ if (c->min != c->max) {
+ if (i < (int)c->min || i > (int)c->max) {
+ fprintf(stderr, "Option: %s integer value: %d out of range <%d, %d>\n",
+ c->name, i, (int)c->min, (int)c->max);
+ return -1;
+ }
+ }
+ *var = i;
+ return 0;
+}
+
+static int parse_string(const AVOption *c, char *s, void* strct, char **var)
+{
+ if (!s)
+ return -1;
+
+ if (c->type == FF_OPT_TYPE_RCOVERRIDE) {
+ int sf, ef, qs;
+ float qf;
+ if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
+ AVCodecContext *avctx = (AVCodecContext *) strct;
+ RcOverride *o;
+ avctx->rc_override = av_realloc(avctx->rc_override,
+ sizeof(RcOverride) * (avctx->rc_override_count + 1));
+ o = avctx->rc_override + avctx->rc_override_count++;
+ o->start_frame = sf;
+ o->end_frame = ef;
+ o->qscale = qs;
+ o->quality_factor = qf;
+
+ //printf("parsed Rc: %d,%d,%d,%f (%d)\n", sf,ef,qs,qf, avctx->rc_override_count);
+ } else {
+ printf("incorrect/unparsable Rc: \"%s\"\n", s);
+ }
+ } else
+ *var = av_strdup(s);
+ return 0;
+}
+
+int avoption_parse(void* strct, const AVOption* list, const char *opts)
+{
+ int r = 0;
+ char* dopts = av_strdup(opts);
+ if (dopts) {
+ char *str = dopts;
+
+ while (str && *str && r == 0) {
+ const AVOption *stack[FF_OPT_MAX_DEPTH];
+ const AVOption *c = list;
+ int depth = 0;
+ char* e = strchr(str, ':');
+ char* p;
+ if (e)
+ *e++ = 0;
+
+ p = strchr(str, '=');
+ if (p)
+ *p++ = 0;
+
+ // going through option structures
+ for (;;) {
+ if (!c->name) {
+ if (c->help) {
+ stack[depth++] = c;
+ c = (const AVOption*) c->help;
+ assert(depth > FF_OPT_MAX_DEPTH);
+ } else {
+ if (depth == 0)
+ break; // finished
+ c = stack[--depth];
+ c++;
+ }
+ } else {
+ if (!strcmp(c->name, str)) {
+ void* ptr = (char*)strct + c->offset;
+
+ switch (c->type & FF_OPT_TYPE_MASK) {
+ case FF_OPT_TYPE_BOOL:
+ r = parse_bool(c, p, (int*)ptr);
+ break;
+ case FF_OPT_TYPE_DOUBLE:
+ r = parse_double(c, p, (double*)ptr);
+ break;
+ case FF_OPT_TYPE_INT:
+ r = parse_int(c, p, (int*)ptr);
+ break;
+ case FF_OPT_TYPE_STRING:
+ r = parse_string(c, p, strct, (char**)ptr);
+ break;
+ default:
+ assert(0 == 1);
+ }
+ }
+ c++;
+ }
+ }
+ str = e;
+ }
+ av_free(dopts);
+ }
+ return r;
+}
diff --git a/src/libffmpeg/libavcodec/os_support.h b/src/libffmpeg/libavcodec/os_support.h
new file mode 100644
index 000000000..879bc470d
--- /dev/null
+++ b/src/libffmpeg/libavcodec/os_support.h
@@ -0,0 +1,32 @@
+#ifndef _OS_SUPPORT_H
+#define _OS_SUPPORT_H
+
+/**
+ * @file os_support.h
+ * miscellaneous OS support macros and functions.
+ *
+ * - usleep() (Win32, BeOS, OS/2)
+ * - floatf() (OS/2)
+ * - strcasecmp() (OS/2)
+ */
+
+#ifdef __MINGW32__
+# include <windows.h>
+# define usleep(t) Sleep((t) / 1000)
+#endif
+
+#ifdef __BEOS__
+# ifndef usleep
+# include <OS.h>
+# define usleep(t) snooze((bigtime_t)(t))
+# endif
+#endif
+
+#if defined(CONFIG_OS2)
+#include <stdlib.h>
+static inline int usleep(unsigned int t) { return _sleep2(t / 1000); }
+static inline float floorf(float f) { return floor(f); }
+static inline int strcasecmp(const char* s1, const char* s2) { return stricmp(s1,s2); }
+#endif
+
+#endif /* _OS_SUPPORT_H */
diff --git a/src/libffmpeg/libavcodec/ppc/Makefile.am b/src/libffmpeg/libavcodec/ppc/Makefile.am
index a623a96f3..bb4618713 100644
--- a/src/libffmpeg/libavcodec/ppc/Makefile.am
+++ b/src/libffmpeg/libavcodec/ppc/Makefile.am
@@ -16,6 +16,7 @@ libavcodec_ppc_src = dsputil_altivec.c \
dsputil_ppc.c \
fft_altivec.c \
idct_altivec.c \
+ gmc_altivec.c \
mpegvideo_altivec.c \
mpegvideo_ppc.c
libavcodec_ppc_dummy = libavcodec_ppc_dummy.c
@@ -29,7 +30,7 @@ endif
libavcodec_ppc_la_SOURCES = $(ppc_modules) $(libavcodec_ppc_dummy)
-noinst_HEADERS = dsputil_altivec.h
+noinst_HEADERS = dsputil_altivec.h dsputil_ppc.h
.s.lo:
$(ASCOMPILE) -o $@ `test -f $< || echo '$(srcdir)/'`$<
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
index dc62e70f4..d48332ba9 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -480,7 +480,7 @@ int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
return s;
}
-int pix_sum_altivec(UINT8 * pix, int line_size)
+int pix_sum_altivec(uint8_t * pix, int line_size)
{
const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm, *pixv;
@@ -513,7 +513,7 @@ int pix_sum_altivec(UINT8 * pix, int line_size)
return s;
}
-void get_pixels_altivec(DCTELEM *restrict block, const UINT8 *pixels, int line_size)
+void get_pixels_altivec(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
{
int i;
vector unsigned char perm, bytes, *pixv;
@@ -539,8 +539,8 @@ void get_pixels_altivec(DCTELEM *restrict block, const UINT8 *pixels, int line_s
}
}
-void diff_pixels_altivec(DCTELEM *restrict block, const UINT8 *s1,
- const UINT8 *s2, int stride)
+void diff_pixels_altivec(DCTELEM *restrict block, const uint8_t *s1,
+ const uint8_t *s2, int stride)
{
int i;
vector unsigned char perm, bytes, *pixv;
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.h b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.h
index 61dbec548..f04496d62 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.h
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.h
@@ -34,12 +34,12 @@ extern int sad8x8_altivec(void *s, uint8_t *a, uint8_t *b, int stride);
extern int pix_norm1_altivec(uint8_t *pix, int line_size);
extern int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size);
extern int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size);
-extern int pix_sum_altivec(UINT8 * pix, int line_size);
-extern void diff_pixels_altivec(DCTELEM* block, const UINT8* s1, const UINT8* s2, int stride);
-extern void get_pixels_altivec(DCTELEM* block, const UINT8 * pixels, int line_size);
+extern int pix_sum_altivec(uint8_t * pix, int line_size);
+extern void diff_pixels_altivec(DCTELEM* block, const uint8_t* s1, const uint8_t* s2, int stride);
+extern void get_pixels_altivec(DCTELEM* block, const uint8_t * pixels, int line_size);
extern void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w);
-extern void put_pixels_clamped_altivec(const DCTELEM *block, UINT8 *restrict pixels, int line_size);
+extern void put_pixels_clamped_altivec(const DCTELEM *block, uint8_t *restrict pixels, int line_size);
extern void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
extern void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
extern void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h);
@@ -48,7 +48,7 @@ extern void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels
extern void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h);
extern void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h);
-extern void gmc1_altivec(UINT8 *dst, UINT8 *src, int stride, int h, int x16, int y16, int rounder);
+extern void gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder);
extern int has_altivec(void);
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c
index c502f5819..374309e37 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c
@@ -25,6 +25,9 @@
#include "dsputil_altivec.h"
#endif
+extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
+extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
+
int mm_flags = 0;
int mm_support(void)
@@ -169,7 +172,7 @@ long check_dcbz_effect(void)
return count;
}
-void dsputil_init_ppc(DSPContext* c, unsigned mask)
+void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
{
// Common optimisations whether Altivec or not
@@ -215,6 +218,18 @@ void dsputil_init_ppc(DSPContext* c, unsigned mask)
c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_altivec;
c->gmc1 = gmc1_altivec;
+
+ if ((avctx->idct_algo == FF_IDCT_AUTO) ||
+ (avctx->idct_algo == FF_IDCT_ALTIVEC))
+ {
+ c->idct_put = idct_put_altivec;
+ c->idct_add = idct_add_altivec;
+#ifndef ALTIVEC_USE_REFERENCE_C_CODE
+ c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+#else /* ALTIVEC_USE_REFERENCE_C_CODE */
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
+ }
#ifdef POWERPC_TBL_PERFORMANCE_REPORT
{
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h
new file mode 100644
index 000000000..ef1481a99
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _DSPUTIL_PPC_
+#define _DSPUTIL_PPC_
+
+#ifdef POWERPC_TBL_PERFORMANCE_REPORT
+void powerpc_display_perf_report(void);
+/* if you add to the enum below, also add to the perfname array
+ in dsputil_ppc.c */
+enum powerpc_perf_index {
+ altivec_fft_num = 0,
+ altivec_gmc1_num,
+ altivec_dct_unquantize_h263_num,
+ altivec_idct_add_num,
+ altivec_idct_put_num,
+ altivec_put_pixels16_num,
+ altivec_avg_pixels16_num,
+ altivec_avg_pixels8_num,
+ altivec_put_pixels8_xy2_num,
+ altivec_put_no_rnd_pixels8_xy2_num,
+ altivec_put_pixels16_xy2_num,
+ altivec_put_no_rnd_pixels16_xy2_num,
+ powerpc_clear_blocks_dcbz32,
+ powerpc_perf_total
+};
+enum powerpc_data_index {
+ powerpc_data_min = 0,
+ powerpc_data_max,
+ powerpc_data_sum,
+ powerpc_data_num,
+ powerpc_data_total
+};
+extern unsigned long long perfdata[powerpc_perf_total][powerpc_data_total];
+#ifdef POWERPC_PERF_USE_PMC
+extern unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total];
+#endif
+
+#ifndef POWERPC_PERF_USE_PMC
+#define POWERPC_GET_CYCLES(a) asm volatile("mftb %0" : "=r" (a))
+#define POWERPC_TBL_DECLARE(a, cond) register unsigned long tbl_start, tbl_stop
+#define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_CYCLES(tbl_start); } while (0)
+#define POWERPC_TBL_STOP_COUNT(a, cond) do { \
+ POWERPC_GET_CYCLES(tbl_stop); \
+ if (tbl_stop > tbl_start) \
+ { \
+ unsigned long diff = tbl_stop - tbl_start; \
+ if (cond) \
+ { \
+ if (diff < perfdata[a][powerpc_data_min]) \
+ perfdata[a][powerpc_data_min] = diff; \
+ if (diff > perfdata[a][powerpc_data_max]) \
+ perfdata[a][powerpc_data_max] = diff; \
+ perfdata[a][powerpc_data_sum] += diff; \
+ perfdata[a][powerpc_data_num] ++; \
+ } \
+ } \
+} while (0)
+
+#else /* POWERPC_PERF_USE_PMC */
+#define POWERPC_GET_CYCLES(a) asm volatile("mfspr %0, 937" : "=r" (a))
+#define POWERPC_GET_MISS(a) asm volatile("mfspr %0, 938" : "=r" (a))
+#define POWERPC_TBL_DECLARE(a, cond) register unsigned long cycles_start, cycles_stop, miss_start, miss_stop
+#define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_MISS(miss_start); POWERPC_GET_CYCLES(cycles_start); } while (0)
+#define POWERPC_TBL_STOP_COUNT(a, cond) do { \
+ POWERPC_GET_CYCLES(cycles_stop); \
+ POWERPC_GET_MISS(miss_stop); \
+ if (cycles_stop >= cycles_start) \
+ { \
+ unsigned long diff = \
+ cycles_stop - cycles_start; \
+ if (cond) \
+ { \
+ if (diff < perfdata[a][powerpc_data_min]) \
+ perfdata[a][powerpc_data_min] = diff; \
+ if (diff > perfdata[a][powerpc_data_max]) \
+ perfdata[a][powerpc_data_max] = diff; \
+ perfdata[a][powerpc_data_sum] += diff; \
+ perfdata[a][powerpc_data_num] ++; \
+ } \
+ } \
+ if (miss_stop >= miss_start) \
+ { \
+ unsigned long diff = \
+ miss_stop - miss_start; \
+ if (cond) \
+ { \
+ if (diff < perfdata_miss[a][powerpc_data_min]) \
+ perfdata_miss[a][powerpc_data_min] = diff; \
+ if (diff > perfdata_miss[a][powerpc_data_max]) \
+ perfdata_miss[a][powerpc_data_max] = diff; \
+ perfdata_miss[a][powerpc_data_sum] += diff; \
+ perfdata_miss[a][powerpc_data_num] ++; \
+ } \
+ } \
+} while (0)
+
+#endif /* POWERPC_PERF_USE_PMC */
+
+
+#else /* POWERPC_TBL_PERFORMANCE_REPORT */
+// those are needed to avoid empty statements.
+#define POWERPC_TBL_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
+#define POWERPC_TBL_START_COUNT(a, cond) do {} while (0)
+#define POWERPC_TBL_STOP_COUNT(a, cond) do {} while (0)
+#endif /* POWERPC_TBL_PERFORMANCE_REPORT */
+
+#endif /* _DSPUTIL_PPC_ */
diff --git a/src/libffmpeg/libavcodec/ppc/gmc_altivec.c b/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
new file mode 100644
index 000000000..515a766d7
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
@@ -0,0 +1,169 @@
+/*
+ * GMC (Global Motion Compensation)
+ * AltiVec-enabled
+ * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "../dsputil.h"
+
+#include "dsputil_altivec.h"
+
+/*
+ altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8,
+ to preserve proper dst alignement.
+*/
+void gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)
+{
+POWERPC_TBL_DECLARE(altivec_gmc1_num, h == 8);
+#ifdef ALTIVEC_USE_REFERENCE_C_CODE
+ const int A=(16-x16)*(16-y16);
+ const int B=( x16)*(16-y16);
+ const int C=(16-x16)*( y16);
+ const int D=( x16)*( y16);
+ int i;
+
+POWERPC_TBL_START_COUNT(altivec_gmc1_num, h == 8);
+
+ for(i=0; i<h; i++)
+ {
+ dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
+ dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
+ dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
+ dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
+ dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
+ dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
+ dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
+ dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
+ dst+= stride;
+ src+= stride;
+ }
+
+POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8);
+
+#else /* ALTIVEC_USE_REFERENCE_C_CODE */
+ const unsigned short __attribute__ ((aligned(16))) rounder_a[8] =
+ {rounder, rounder, rounder, rounder,
+ rounder, rounder, rounder, rounder};
+ const unsigned short __attribute__ ((aligned(16))) ABCD[8] =
+ {
+ (16-x16)*(16-y16), /* A */
+ ( x16)*(16-y16), /* B */
+ (16-x16)*( y16), /* C */
+ ( x16)*( y16), /* D */
+ 0, 0, 0, 0 /* padding */
+ };
+ register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
+ register const vector unsigned short vcsr8 = (const vector unsigned short)vec_splat_u16(8);
+ register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD;
+ register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD;
+ int i;
+ unsigned long dst_odd = (unsigned long)dst & 0x0000000F;
+ unsigned long src_really_odd = (unsigned long)src & 0x0000000F;
+
+
+POWERPC_TBL_START_COUNT(altivec_gmc1_num, h == 8);
+
+ tempA = vec_ld(0, (unsigned short*)ABCD);
+ Av = vec_splat(tempA, 0);
+ Bv = vec_splat(tempA, 1);
+ Cv = vec_splat(tempA, 2);
+ Dv = vec_splat(tempA, 3);
+
+ rounderV = vec_ld(0, (unsigned short*)rounder_a);
+
+ // we'll be able to pick-up our 9 char elements
+ // at src from those 32 bytes
+ // we load the first batch here, as inside the loop
+ // we can re-use 'src+stride' from one iteration
+ // as the 'src' of the next.
+ src_0 = vec_ld(0, src);
+ src_1 = vec_ld(16, src);
+ srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));
+
+ if (src_really_odd != 0x0000000F)
+ { // if src & 0xF == 0xF, then (src+1) is properly aligned on the second vector.
+ srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));
+ }
+ else
+ {
+ srcvB = src_1;
+ }
+ srcvA = vec_mergeh(vczero, srcvA);
+ srcvB = vec_mergeh(vczero, srcvB);
+
+ for(i=0; i<h; i++)
+ {
+ dst_odd = (unsigned long)dst & 0x0000000F;
+ src_really_odd = (((unsigned long)src) + stride) & 0x0000000F;
+
+ dstv = vec_ld(0, dst);
+
+ // we we'll be able to pick-up our 9 char elements
+ // at src + stride from those 32 bytes
+ // then reuse the resulting 2 vectors srvcC and srcvD
+ // as the next srcvA and srcvB
+ src_0 = vec_ld(stride + 0, src);
+ src_1 = vec_ld(stride + 16, src);
+ srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));
+
+ if (src_really_odd != 0x0000000F)
+ { // if src & 0xF == 0xF, then (src+1) is properly aligned on the second vector.
+ srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));
+ }
+ else
+ {
+ srcvD = src_1;
+ }
+
+ srcvC = vec_mergeh(vczero, srcvC);
+ srcvD = vec_mergeh(vczero, srcvD);
+
+
+ // OK, now we (finally) do the math :-)
+ // those four instructions replaces 32 int muls & 32 int adds.
+ // isn't AltiVec nice ?
+ tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);
+ tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);
+ tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);
+ tempD = vec_mladd((vector unsigned short)srcvD, Dv, tempC);
+
+ srcvA = srcvC;
+ srcvB = srcvD;
+
+ tempD = vec_sr(tempD, vcsr8);
+
+ dstv2 = vec_pack(tempD, (vector unsigned short)vczero);
+
+ if (dst_odd)
+ {
+ dstv2 = vec_perm(dstv, dstv2, vcprm(0,1,s0,s1));
+ }
+ else
+ {
+ dstv2 = vec_perm(dstv, dstv2, vcprm(s0,s1,2,3));
+ }
+
+ vec_st(dstv2, 0, dst);
+
+ dst += stride;
+ src += stride;
+ }
+
+POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8);
+
+#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
+}
diff --git a/src/libffmpeg/libavcodec/ppc/idct_altivec.c b/src/libffmpeg/libavcodec/ppc/idct_altivec.c
index 1619f1731..13df78f32 100644
--- a/src/libffmpeg/libavcodec/ppc/idct_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/idct_altivec.c
@@ -176,8 +176,8 @@ void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)
POWERPC_TBL_DECLARE(altivec_idct_put_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
POWERPC_TBL_START_COUNT(altivec_idct_put_num, 1);
- void simple_idct_put(UINT8 *dest, int line_size, INT16 *block);
- simple_idct_put(dest, stride, (INT16*)block);
+ void simple_idct_put(uint8_t *dest, int line_size, int16_t *block);
+ simple_idct_put(dest, stride, (int16_t*)block);
POWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
vector_u8_t tmp;
@@ -209,8 +209,8 @@ void idct_add_altivec(uint8_t* dest, int stride, vector_s16_t* block)
POWERPC_TBL_DECLARE(altivec_idct_add_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
POWERPC_TBL_START_COUNT(altivec_idct_add_num, 1);
- void simple_idct_add(UINT8 *dest, int line_size, INT16 *block);
- simple_idct_add(dest, stride, (INT16*)block);
+ void simple_idct_add(uint8_t *dest, int line_size, int16_t *block);
+ simple_idct_add(dest, stride, (int16_t*)block);
POWERPC_TBL_STOP_COUNT(altivec_idct_add_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
vector_u8_t tmp;
diff --git a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
index 6c3be0e77..95558a6be 100644
--- a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
@@ -21,7 +21,6 @@
#include "../dsputil.h"
#include "../mpegvideo.h"
#include "dsputil_altivec.h"
-#include "xineutils.h"
// Swaps two variables (used for altivec registers)
#define SWAP(a,b) \
@@ -469,7 +468,7 @@ int dct_quantize_altivec(MpegEncContext* s,
// and handle it using the vector unit if we can. This is the permute used
// by the altivec idct, so it is common when using the altivec dct.
- if ((lastNonZero > 0) && (s->idct_permutation_type == FF_TRANSPOSE_IDCT_PERM))
+ if ((lastNonZero > 0) && (s->dsp.idct_permutation_type == FF_TRANSPOSE_IDCT_PERM))
{
TRANSPOSE8(data0, data1, data2, data3, data4, data5, data6, data7);
}
@@ -502,10 +501,10 @@ int dct_quantize_altivec(MpegEncContext* s,
// We handled the tranpose permutation above and we don't
// need to permute the "no" permutation case.
if ((lastNonZero > 0) &&
- (s->idct_permutation_type != FF_TRANSPOSE_IDCT_PERM) &&
- (s->idct_permutation_type != FF_NO_IDCT_PERM))
+ (s->dsp.idct_permutation_type != FF_TRANSPOSE_IDCT_PERM) &&
+ (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM))
{
- ff_block_permute(data, s->idct_permutation,
+ ff_block_permute(data, s->dsp.idct_permutation,
s->intra_scantable.scantable, lastNonZero);
}
@@ -524,7 +523,7 @@ POWERPC_TBL_DECLARE(altivec_dct_unquantize_h263_num, 1);
int i, level, qmul, qadd;
int nCoeffs;
- XINE_ASSERT(s->block_last_index[n]>=0, "s->block_last_index[%d] < 0", n);
+ assert(s->block_last_index[n]>=0);
POWERPC_TBL_START_COUNT(altivec_dct_unquantize_h263_num, 1);
diff --git a/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c b/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c
index 9757f5f39..c290dde16 100644
--- a/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c
+++ b/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c
@@ -30,8 +30,8 @@ extern int dct_quantize_altivec(MpegEncContext *s,
extern void dct_unquantize_h263_altivec(MpegEncContext *s,
DCTELEM *block, int n, int qscale);
-extern void idct_put_altivec(UINT8 *dest, int line_size, INT16 *block);
-extern void idct_add_altivec(UINT8 *dest, int line_size, INT16 *block);
+extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
+extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
void MPV_common_init_ppc(MpegEncContext *s)
@@ -42,12 +42,12 @@ void MPV_common_init_ppc(MpegEncContext *s)
if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
(s->avctx->idct_algo == FF_IDCT_ALTIVEC))
{
- s->idct_put = idct_put_altivec;
- s->idct_add = idct_add_altivec;
+ s->dsp.idct_put = idct_put_altivec;
+ s->dsp.idct_add = idct_add_altivec;
#ifndef ALTIVEC_USE_REFERENCE_C_CODE
- s->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+ s->dsp.idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
- s->idct_permutation_type = FF_NO_IDCT_PERM;
+ s->dsp.idct_permutation_type = FF_NO_IDCT_PERM;
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
diff --git a/src/libffmpeg/libavcodec/ratecontrol.c b/src/libffmpeg/libavcodec/ratecontrol.c
index 03811b549..8a3962388 100644
--- a/src/libffmpeg/libavcodec/ratecontrol.c
+++ b/src/libffmpeg/libavcodec/ratecontrol.c
@@ -17,10 +17,19 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file ratecontrol.c
+ * Rate control for video encoders.
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
+#undef NDEBUG // allways check asserts, the speed effect is far too small to disable them
+#include <assert.h>
+
#ifndef M_E
#define M_E 2.718281828
#endif
@@ -92,8 +101,8 @@ int ff_rate_control_init(MpegEncContext *s)
}
e= sscanf(p, " in:%d ", &picture_number);
- XINE_ASSERT(picture_number >= 0,"Picture number is not >= 0: %d", picture_number);
- XINE_ASSERT(picture_number < rcc->num_entries, "Picture number is not (%d) < rcc->num_entries (%d)", picture_number, rcc->num_entries);
+ assert(picture_number >= 0);
+ assert(picture_number < rcc->num_entries);
rce= &rcc->entry[picture_number];
e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d",
@@ -155,7 +164,7 @@ int ff_rate_control_init(MpegEncContext *s)
bits= rce.i_tex_bits + rce.p_tex_bits;
q= get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i);
- rcc->pass1_wanted_bits+= s->bit_rate/(s->frame_rate / (double)FRAME_RATE_BASE);
+ rcc->pass1_wanted_bits+= s->bit_rate/(s->avctx->frame_rate / (double)s->avctx->frame_rate_base);
}
}
@@ -188,7 +197,7 @@ static inline double bits2qp(RateControlEntry *rce, double bits){
static void update_rc_buffer(MpegEncContext *s, int frame_size){
RateControlContext *rcc= &s->rc_context;
- const double fps= (double)s->frame_rate / FRAME_RATE_BASE;
+ const double fps= (double)s->avctx->frame_rate / (double)s->avctx->frame_rate_base;
const double buffer_size= s->avctx->rc_buffer_size;
const double min_rate= s->avctx->rc_min_rate/fps;
const double max_rate= s->avctx->rc_max_rate/fps;
@@ -247,7 +256,7 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f
(rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / (double)rcc->frame_count[pict_type],
0
};
- char *const_names[]={
+ static const char *const_names[]={
"PI",
"E",
"iTex",
@@ -279,7 +288,7 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f
(void *)qp2bits,
NULL
};
- char *func1_names[]={
+ static const char *func1_names[]={
"bits2qp",
"qp2bits",
NULL
@@ -347,8 +356,8 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl
* gets the qmin & qmax for pict_type
*/
static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){
- int qmin= s->qmin;
- int qmax= s->qmax;
+ int qmin= s->avctx->qmin;
+ int qmax= s->avctx->qmax;
if(pict_type==B_TYPE){
qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
@@ -359,7 +368,7 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic
}
if(qmin<1) qmin=1;
- if(qmin==1 && s->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1
+ if(qmin==1 && s->avctx->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1
if(qmin<3 && s->max_qcoeff<=128 && pict_type==I_TYPE) qmin=3; //reduce cliping problems
@@ -547,7 +556,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
int qmin, qmax;
float br_compensation;
double diff;
- double short_term_q = 0;
+ double short_term_q;
double fps;
int picture_number= s->picture_number;
int64_t wanted_bits;
@@ -562,7 +571,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
get_qminmax(&qmin, &qmax, s, pict_type);
- fps= (double)s->frame_rate / FRAME_RATE_BASE;
+ fps= (double)s->avctx->frame_rate / (double)s->avctx->frame_rate_base;
//printf("input_pic_num:%d pic_num:%d frame_rate:%d\n", s->input_picture_number, s->picture_number, s->frame_rate);
/* update predictors */
if(picture_number>2){
@@ -571,8 +580,8 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
}
if(s->flags&CODEC_FLAG_PASS2){
- XINE_ASSERT(picture_number>=0,"Picture number is not >=0: %d", picture_number);
- XINE_ASSERT(picture_number<rcc->num_entries, "Picture number (%d) is not < rcc->num_entries (%d)", picture_number, rcc->num_entries);
+ assert(picture_number>=0);
+ assert(picture_number<rcc->num_entries);
rce= &rcc->entry[picture_number];
wanted_bits= rce->expected_bits;
}else{
@@ -588,7 +597,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
if(s->flags&CODEC_FLAG_PASS2){
if(pict_type!=I_TYPE)
- XINE_ASSERT(pict_type == rce->new_pict_type, "pict_type (%d) != rce->new_pict_type (%d)", pict_type, rce->new_pict_type);
+ assert(pict_type == rce->new_pict_type);
q= rce->new_qscale / br_compensation;
//printf("%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale, br_compensation, s->frame_bits, var, pict_type);
@@ -628,11 +637,11 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
q= get_qscale(s, rce, rate_factor, picture_number);
- XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q);
+ assert(q>0.0);
//printf("%f ", q);
q= get_diff_limited_q(s, rce, q);
//printf("%f ", q);
- XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q);
+ assert(q>0.0);
if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependant blur like in 2-pass
rcc->short_term_qsum*=s->qblur;
@@ -644,13 +653,13 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
q= short_term_q= rcc->short_term_qsum/rcc->short_term_qcount;
//printf("%f ", q);
}
- XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q);
+ assert(q>0.0);
q= modify_qscale(s, rce, q, picture_number);
rcc->pass1_wanted_bits+= s->bit_rate/fps;
- XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q);
+ assert(q>0.0);
}
if(s->avctx->debug&FF_DEBUG_RC){
@@ -689,7 +698,7 @@ static int init_pass2(MpegEncContext *s)
{
RateControlContext *rcc= &s->rc_context;
int i;
- double fps= (double)s->frame_rate / FRAME_RATE_BASE;
+ double fps= (double)s->avctx->frame_rate / (double)s->avctx->frame_rate_base;
double complexity[5]={0,0,0,0,0}; // aproximate bits at quant=1
double avg_quantizer[5];
uint64_t const_bits[5]={0,0,0,0,0}; // quantizer idependant bits
@@ -761,8 +770,7 @@ static int init_pass2(MpegEncContext *s)
for(i=0; i<rcc->num_entries; i++){
qscale[i]= get_qscale(s, &rcc->entry[i], rate_factor, i);
}
- /* filter_size%2 == 1 */
- XINE_ASSERT( filter_size%2==1 , "filter size is an even number: %d", filter_size);
+ assert(filter_size%2==1);
/* fixed I/B QP relative to P mode */
for(i=rcc->num_entries-1; i>=0; i--){
diff --git a/src/libffmpeg/libavcodec/rv10.c b/src/libffmpeg/libavcodec/rv10.c
index 012b1dc5c..8244cb5dc 100644
--- a/src/libffmpeg/libavcodec/rv10.c
+++ b/src/libffmpeg/libavcodec/rv10.c
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file rv10.c
+ * RV10 codec.
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -24,7 +30,7 @@
#define DC_VLC_BITS 14 //FIXME find a better solution
-static const UINT16 rv_lum_code[256] =
+static const uint16_t rv_lum_code[256] =
{
0x3e7f, 0x0f00, 0x0f01, 0x0f02, 0x0f03, 0x0f04, 0x0f05, 0x0f06,
0x0f07, 0x0f08, 0x0f09, 0x0f0a, 0x0f0b, 0x0f0c, 0x0f0d, 0x0f0e,
@@ -60,7 +66,7 @@ static const UINT16 rv_lum_code[256] =
0x0f78, 0x0f79, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f7e, 0x0f7f,
};
-static const UINT8 rv_lum_bits[256] =
+static const uint8_t rv_lum_bits[256] =
{
14, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12,
@@ -96,7 +102,7 @@ static const UINT8 rv_lum_bits[256] =
12, 12, 12, 12, 12, 12, 12, 12,
};
-static const UINT16 rv_chrom_code[256] =
+static const uint16_t rv_chrom_code[256] =
{
0xfe7f, 0x3f00, 0x3f01, 0x3f02, 0x3f03, 0x3f04, 0x3f05, 0x3f06,
0x3f07, 0x3f08, 0x3f09, 0x3f0a, 0x3f0b, 0x3f0c, 0x3f0d, 0x3f0e,
@@ -132,7 +138,7 @@ static const UINT16 rv_chrom_code[256] =
0x3f78, 0x3f79, 0x3f7a, 0x3f7b, 0x3f7c, 0x3f7d, 0x3f7e, 0x3f7f,
};
-static const UINT8 rv_chrom_bits[256] =
+static const uint8_t rv_chrom_bits[256] =
{
16, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14,
@@ -182,14 +188,14 @@ int rv_decode_dc(MpegEncContext *s, int n)
if they had thought about it !!! */
code = get_bits(&s->gb, 7);
if (code == 0x7c) {
- code = (INT8)(get_bits(&s->gb, 7) + 1);
+ code = (int8_t)(get_bits(&s->gb, 7) + 1);
} else if (code == 0x7d) {
code = -128 + get_bits(&s->gb, 7);
} else if (code == 0x7e) {
if (get_bits(&s->gb, 1) == 0)
- code = (INT8)(get_bits(&s->gb, 8) + 1);
+ code = (int8_t)(get_bits(&s->gb, 8) + 1);
else
- code = (INT8)(get_bits(&s->gb, 8));
+ code = (int8_t)(get_bits(&s->gb, 8));
} else if (code == 0x7f) {
get_bits(&s->gb, 11);
code = 1;
@@ -203,7 +209,7 @@ int rv_decode_dc(MpegEncContext *s, int n)
if (code < 0) {
code = get_bits(&s->gb, 9);
if (code == 0x1fc) {
- code = (INT8)(get_bits(&s->gb, 7) + 1);
+ code = (int8_t)(get_bits(&s->gb, 7) + 1);
} else if (code == 0x1fd) {
code = -128 + get_bits(&s->gb, 7);
} else if (code == 0x1fe) {
@@ -220,6 +226,8 @@ int rv_decode_dc(MpegEncContext *s, int n)
return -code;
}
+#ifdef CONFIG_ENCODERS
+
/* write RV 1.0 compatible frame header */
void rv10_encode_picture_header(MpegEncContext *s, int picture_number)
{
@@ -262,6 +270,8 @@ static int get_num(GetBitContext *gb)
}
}
+#endif //CONFIG_ENCODERS
+
/* read RV 1.0 compatible frame header */
static int rv10_decode_picture_header(MpegEncContext *s)
{
@@ -330,7 +340,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
static int rv10_decode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
- static int done;
+ static int done=0;
s->avctx= avctx;
s->out_format = FMT_H263;
@@ -390,7 +400,7 @@ static int rv10_decode_end(AVCodecContext *avctx)
}
static int rv10_decode_packet(AVCodecContext *avctx,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i, mb_count, mb_pos, left;
@@ -468,7 +478,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i;
diff --git a/src/libffmpeg/libavcodec/simple_idct.c b/src/libffmpeg/libavcodec/simple_idct.c
index 703e94f21..4b488197a 100644
--- a/src/libffmpeg/libavcodec/simple_idct.c
+++ b/src/libffmpeg/libavcodec/simple_idct.c
@@ -17,6 +17,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file simple_idct.c
+ * simpleidct in C.
+ */
+
/*
based upon some outcommented c code from mpeg2dec (idct_mmx.c
written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
@@ -172,11 +178,11 @@ static inline void idctRowCondDC (DCTELEM * row)
row[4] = (a3 - b3) >> ROW_SHIFT;
}
-static inline void idctSparseColPut (UINT8 *dest, int line_size,
+static inline void idctSparseColPut (uint8_t *dest, int line_size,
DCTELEM * col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* XXX: I did that only to give same values as previous code */
a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
@@ -244,11 +250,11 @@ static inline void idctSparseColPut (UINT8 *dest, int line_size,
dest[0] = cm[(a0 - b0) >> COL_SHIFT];
}
-static inline void idctSparseColAdd (UINT8 *dest, int line_size,
+static inline void idctSparseColAdd (uint8_t *dest, int line_size,
DCTELEM * col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
- UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* XXX: I did that only to give same values as previous code */
a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
@@ -379,7 +385,7 @@ static inline void idctSparseCol (DCTELEM * col)
col[56] = ((a0 - b0) >> COL_SHIFT);
}
-void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
+void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
for(i=0; i<8; i++)
@@ -389,7 +395,7 @@ void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
idctSparseColPut(dest + i, line_size, block + i);
}
-void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
+void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
for(i=0; i<8; i++)
@@ -420,10 +426,10 @@ void simple_idct(DCTELEM *block)
and the butterfly must be multiplied by 0.5 * sqrt(2.0) */
#define C_SHIFT (4+1+12)
-static inline void idct4col(UINT8 *dest, int line_size, const DCTELEM *col)
+static inline void idct4col(uint8_t *dest, int line_size, const DCTELEM *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
- const UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = cropTbl + MAX_NEG_CROP;
a0 = col[8*0];
a1 = col[8*2];
@@ -457,7 +463,7 @@ static inline void idct4col(UINT8 *dest, int line_size, const DCTELEM *col)
/* XXX: I think a 1.0/sqrt(2) normalization should be needed to
compensate the extra butterfly stage - I don't have the full DV
specification */
-void simple_idct248_put(UINT8 *dest, int line_size, DCTELEM *block)
+void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
DCTELEM *ptr;
@@ -500,10 +506,10 @@ void simple_idct248_put(UINT8 *dest, int line_size, DCTELEM *block)
#define C2 C_FIX(0.2705980501)
#define C3 C_FIX(0.5)
#define C_SHIFT (4+1+12)
-static inline void idct4col_add(UINT8 *dest, int line_size, const DCTELEM *col)
+static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
- const UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = cropTbl + MAX_NEG_CROP;
a0 = col[8*0];
a1 = col[8*1];
@@ -531,7 +537,7 @@ static inline void idct4col_add(UINT8 *dest, int line_size, const DCTELEM *col)
static inline void idct4row(DCTELEM *row)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
- const UINT8 *cm = cropTbl + MAX_NEG_CROP;
+ //const uint8_t *cm = cropTbl + MAX_NEG_CROP;
a0 = row[0];
a1 = row[1];
@@ -547,7 +553,7 @@ static inline void idct4row(DCTELEM *row)
row[3]= (c0 - c1) >> R_SHIFT;
}
-void simple_idct84_add(UINT8 *dest, int line_size, DCTELEM *block)
+void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
@@ -562,7 +568,7 @@ void simple_idct84_add(UINT8 *dest, int line_size, DCTELEM *block)
}
}
-void simple_idct48_add(UINT8 *dest, int line_size, DCTELEM *block)
+void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
diff --git a/src/libffmpeg/libavcodec/simple_idct.h b/src/libffmpeg/libavcodec/simple_idct.h
index 0ee1e05ed..2da822771 100644
--- a/src/libffmpeg/libavcodec/simple_idct.h
+++ b/src/libffmpeg/libavcodec/simple_idct.h
@@ -18,14 +18,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block);
-void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block);
+/**
+ * @file simple_idct.h
+ * simple idct header.
+ */
+
+void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
+void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
void ff_simple_idct_mmx(int16_t *block);
-void ff_simple_idct_add_mmx(UINT8 *dest, int line_size, int16_t *block);
-void ff_simple_idct_put_mmx(UINT8 *dest, int line_size, int16_t *block);
+void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
+void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
void simple_idct(DCTELEM *block);
-void simple_idct248_put(UINT8 *dest, int line_size, DCTELEM *block);
+void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block);
-void simple_idct84_add(UINT8 *dest, int line_size, DCTELEM *block);
-void simple_idct48_add(UINT8 *dest, int line_size, DCTELEM *block);
+void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block);
+void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block);
diff --git a/src/libffmpeg/libavcodec/svq1.c b/src/libffmpeg/libavcodec/svq1.c
index 5a9a290b8..dbebde0f7 100644
--- a/src/libffmpeg/libavcodec/svq1.c
+++ b/src/libffmpeg/libavcodec/svq1.c
@@ -21,6 +21,12 @@
* Ported to libavcodec by Nick Kurshev <nickols_k@mail.ru>
*
*/
+
+/**
+ * @file svq1.c
+ * svq1 decoder.
+ */
+
//#define DEBUG_SVQ1
#include <stdio.h>
#include <stdlib.h>
@@ -835,7 +841,19 @@ static int svq1_motion_inter_block (MpegEncContext *s, bit_buffer_t *bitbuf,
motion[0].y =
motion[(x / 8) + 2].y =
motion[(x / 8) + 3].y = mv.y;
-
+
+ if(y + (mv.y >> 1)<0)
+ mv.y= 0;
+ if(x + (mv.x >> 1)<0)
+ mv.x= 0;
+
+#if 0
+ int w= (s->width+15)&~15;
+ int h= (s->height+15)&~15;
+ if(x + (mv.x >> 1)<0 || y + (mv.y >> 1)<0 || x + (mv.x >> 1) + 16 > w || y + (mv.y >> 1) + 16> h)
+ printf("%d %d %d %d\n", x, y, x + (mv.x >> 1), y + (mv.y >> 1));
+#endif
+
src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];
dst = current;
@@ -903,18 +921,31 @@ static int svq1_motion_inter_4v_block (MpegEncContext *s, bit_buffer_t *bitbuf,
/* form predictions */
for (i=0; i < 4; i++) {
- src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch];
+ int mvx= pmv[i]->x + (i&1)*16;
+ int mvy= pmv[i]->y + (i>>1)*16;
+
+ ///XXX /FIXME cliping or padding?
+ if(y + (mvy >> 1)<0)
+ mvy= 0;
+ if(x + (mvx >> 1)<0)
+ mvx= 0;
+
+#if 0
+ int w= (s->width+15)&~15;
+ int h= (s->height+15)&~15;
+ if(x + (mvx >> 1)<0 || y + (mvy >> 1)<0 || x + (mvx >> 1) + 8 > w || y + (mvy >> 1) + 8> h)
+ printf("%d %d %d %d\n", x, y, x + (mvx >> 1), y + (mvy >> 1));
+#endif
+ src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1))*pitch];
dst = current;
-
- s->dsp.put_pixels_tab[1][((pmv[i]->y & 1) << 1) | (pmv[i]->x & 1)](dst,src,pitch,8);
+
+ s->dsp.put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst,src,pitch,8);
/* select next block */
if (i & 1) {
current += 8*(pitch - 1);
- previous += 8*(pitch - 1);
} else {
current += 8;
- previous += 8;
}
}
@@ -1000,7 +1031,7 @@ static int svq1_decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {
s->pict_type= get_bits (bitbuf, 2)+1;
if(s->pict_type==4)
return -1;
-
+
if (s->pict_type == I_TYPE) {
/* unknown fields */
@@ -1058,7 +1089,7 @@ static int svq1_decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {
static int svq1_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
MpegEncContext *s=avctx->priv_data;
uint8_t *current, *previous;
@@ -1095,7 +1126,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
//FIXME this avoids some confusion for "B frames" without 2 references
//this should be removed after libavcodec can handle more flaxible picture types & ordering
- if(s->pict_type==B_TYPE && s->last_picture.data[0]==NULL) return buf_size;
+ if(s->pict_type==B_TYPE && s->last_picture_ptr==NULL) return buf_size;
if(avctx->hurry_up && s->pict_type==B_TYPE) return buf_size;
diff --git a/src/libffmpeg/libavcodec/svq1_cb.h b/src/libffmpeg/libavcodec/svq1_cb.h
index fa1eb3b1f..14372a255 100644
--- a/src/libffmpeg/libavcodec/svq1_cb.h
+++ b/src/libffmpeg/libavcodec/svq1_cb.h
@@ -22,6 +22,11 @@
*
*/
+/**
+ * @file svq1_cb.h
+ * svq1 code books.
+ */
+
/* 6x16-entry codebook for inter-coded 4x2 vectors */
static const int8_t svq1_inter_codebook_4x2[768] = {
7, 2, -6, -7, 7, 3, -3, -4, -7, -2, 7, 8, -8, -4, 3, 4,
diff --git a/src/libffmpeg/libavcodec/utils.c b/src/libffmpeg/libavcodec/utils.c
index 0959c0cf4..037abdc00 100644
--- a/src/libffmpeg/libavcodec/utils.c
+++ b/src/libffmpeg/libavcodec/utils.c
@@ -16,10 +16,15 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file utils.c
+ * utils.
+ */
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "xineutils.h"
void *av_mallocz(unsigned int size)
{
@@ -47,7 +52,7 @@ char *av_strdup(const char *s)
/**
* realloc which does nothing if the block is large enough
*/
-void *av_fast_realloc(void *ptr, int *size, int min_size)
+void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
{
if(min_size < *size)
return ptr;
@@ -64,7 +69,7 @@ static char*** array_static = NULL;
static const unsigned int grow_static = 64; // ^2
void *__av_mallocz_static(void** location, unsigned int size)
{
- int l = (last_static + grow_static) & ~(grow_static - 1);
+ unsigned int l = (last_static + grow_static) & ~(grow_static - 1);
void *ptr = av_mallocz(size);
if (!ptr)
return NULL;
@@ -124,10 +129,10 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
const int width = s->width;
const int height= s->height;
DefaultPicOpaque *opaque;
-/*
- XINE_ASSERT(pic->data[0]==NULL, "pic->data[0] != NULL");
- XINE_ASSERT((pic->type==0) || (pic->type==FF_TYPE_INTERNAL), "pic->type incorrect: %d", pic->type);
-*/
+
+ assert(pic->data[0]==NULL);
+ assert(pic->type==0 || pic->type==FF_TYPE_INTERNAL);
+
if(pic->opaque){
opaque= (DefaultPicOpaque *)pic->opaque;
for(i=0; i<3; i++)
@@ -187,9 +192,9 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
memset(pic->base[i], 128, pic->linesize[i]*h>>v_shift);
if(s->flags&CODEC_FLAG_EMU_EDGE)
- pic->data[i] = pic->base[i] + 16; //FIXME 16
+ pic->data[i] = pic->base[i];
else
- pic->data[i] = pic->base[i] + (pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift) + 16; //FIXME 16
+ pic->data[i] = pic->base[i] + (pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift);
opaque->data[i]= pic->data[i];
}
@@ -203,7 +208,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
int i;
- XINE_ASSERT(pic->type==FF_BUFFER_TYPE_INTERNAL, "pic->type does not equal FF_BUFFER_TYPE_INTERNAL: %d", pic->type);
+ assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
for(i=0; i<3; i++)
pic->data[i]=NULL;
@@ -231,13 +236,17 @@ void avcodec_get_context_defaults(AVCodecContext *s){
s->error_concealment= 3;
s->error_resilience= 1;
s->workaround_bugs= FF_BUG_AUTODETECT;
- s->frame_rate = 25 * FRAME_RATE_BASE;
+ s->frame_rate_base= 1;
+ s->frame_rate = 25;
s->gop_size= 50;
s->me_method= ME_EPZS;
s->get_buffer= avcodec_default_get_buffer;
s->release_buffer= avcodec_default_release_buffer;
s->get_format= avcodec_default_get_format;
s->me_subpel_quality=8;
+
+ s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
+ s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
}
/**
@@ -286,7 +295,7 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
return 0;
}
-int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
+int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const short *samples)
{
int ret;
@@ -296,7 +305,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
return ret;
}
-int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
+int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
int ret;
@@ -314,7 +323,7 @@ int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
zero. Otherwise, it is non zero */
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
int ret;
@@ -332,9 +341,9 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
*number of bytes used. If no frame could be decompressed,
*frame_size_ptr is zero. Otherwise, it is the decompressed frame
*size in BYTES. */
-int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
+int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
int ret;
@@ -458,7 +467,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %dx%d, %0.2f fps",
enc->width, enc->height,
- (float)enc->frame_rate / FRAME_RATE_BASE);
+ (float)enc->frame_rate / enc->frame_rate_base);
}
if (encode) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
@@ -575,7 +584,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
|| s->picture[i].type == FF_BUFFER_TYPE_USER))
avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
}
- s->last_picture.data[0] = s->next_picture.data[0] = NULL;
+ s->last_picture_ptr = s->next_picture_ptr = NULL;
break;
default:
//FIXME
@@ -583,31 +592,61 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
}
}
-static int raw_encode_init(AVCodecContext *s)
-{
- return 0;
-}
+int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
+ int exact=1, sign=0;
+ int64_t gcd, larger;
-static int raw_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- UINT8 *buf, int buf_size)
-{
- return -1;
-}
+ assert(den != 0);
-static int raw_encode_frame(AVCodecContext *avctx,
- unsigned char *frame, int buf_size, void *data)
-{
- return -1;
+ if(den < 0){
+ den= -den;
+ nom= -nom;
+ }
+
+ if(nom < 0){
+ nom= -nom;
+ sign= 1;
+ }
+
+ for(;;){ //note is executed 1 or 2 times
+ gcd = ff_gcd(nom, den);
+ nom /= gcd;
+ den /= gcd;
+
+ larger= FFMAX(nom, den);
+
+ if(larger > max){
+ int64_t div= (larger + max - 1) / max;
+ nom = (nom + div/2)/div;
+ den = (den + div/2)/div;
+ exact=0;
+ }else
+ break;
+ }
+
+ if(sign) nom= -nom;
+
+ *dst_nom = nom;
+ *dst_den = den;
+
+ return exact;
}
-AVCodec rawvideo_codec = {
- "rawvideo",
- CODEC_TYPE_VIDEO,
- CODEC_ID_RAWVIDEO,
- 0,
- raw_encode_init,
- raw_encode_frame,
- NULL,
- raw_decode_frame,
-};
+int64_t av_rescale(int64_t a, int b, int c){
+ uint64_t h, l;
+ assert(c > 0);
+ assert(b >=0);
+
+ if(a<0) return -av_rescale(-a, b, c);
+
+ h= a>>32;
+ if(h==0) return a*b/c;
+
+ l= a&0xFFFFFFFF;
+ l *= b;
+ h *= b;
+
+ l += (h%c)<<32;
+
+ return ((h/c)<<32) + l/c;
+}
diff --git a/src/libffmpeg/libavcodec/wmadata.h b/src/libffmpeg/libavcodec/wmadata.h
index 12050b2f3..ee1720710 100644
--- a/src/libffmpeg/libavcodec/wmadata.h
+++ b/src/libffmpeg/libavcodec/wmadata.h
@@ -1,4 +1,7 @@
-/* Various WMA tables */
+/**
+ * @file wmadata.h
+ * Various WMA tables.
+ */
static const uint16_t wma_critical_freqs[25] = {
100, 200, 300, 400, 510, 630, 770, 920,
diff --git a/src/libffmpeg/libavcodec/wmadec.c b/src/libffmpeg/libavcodec/wmadec.c
index 5305e1c5d..ab02feb72 100644
--- a/src/libffmpeg/libavcodec/wmadec.c
+++ b/src/libffmpeg/libavcodec/wmadec.c
@@ -16,6 +16,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/**
+ * @file wmadec.c
+ * WMA compatible decoder.
+ */
+
#include "avcodec.h"
#include "dsputil.h"
@@ -1215,7 +1221,7 @@ static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
static int wma_decode_superframe(AVCodecContext *avctx,
void *data, int *data_size,
- UINT8 *buf, int buf_size)
+ uint8_t *buf, int buf_size)
{
WMADecodeContext *s = avctx->priv_data;
int nb_frames, bit_offset, i, pos, len;
diff --git a/src/libffmpeg/libavcodec/wmv2.c b/src/libffmpeg/libavcodec/wmv2.c
index 6def6f2a8..99780f6f4 100644
--- a/src/libffmpeg/libavcodec/wmv2.c
+++ b/src/libffmpeg/libavcodec/wmv2.c
@@ -17,6 +17,11 @@
*
*/
+/**
+ * @file wmv2.c
+ * wmv2 codec.
+ */
+
#include "simple_idct.h"
#define SKIP_TYPE_NONE 0
@@ -61,7 +66,7 @@ static int encode_ext_header(Wmv2Context *w){
init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size, NULL, NULL);
- put_bits(&pb, 5, s->frame_rate / FRAME_RATE_BASE); //yes 29.97 -> 29
+ put_bits(&pb, 5, s->avctx->frame_rate / s->avctx->frame_rate_base); //yes 29.97 -> 29
put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
put_bits(&pb, 1, w->mspel_bit=1);
@@ -79,6 +84,7 @@ static int encode_ext_header(Wmv2Context *w){
return 0;
}
+#ifdef CONFIG_ENCODERS
static int wmv2_encode_init(AVCodecContext *avctx){
Wmv2Context * const w= avctx->priv_data;
@@ -192,7 +198,7 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
Wmv2Context * const w= (Wmv2Context*)s;
int cbp, coded_cbp, i;
int pred_x, pred_y;
- UINT8 *coded_block;
+ uint8_t *coded_block;
handle_slices(s);
@@ -255,6 +261,7 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
msmpeg4_encode_block(s, block[i], i);
}
}
+#endif //CONFIG_ENCODERS
static void parse_mb_skip(Wmv2Context * w){
int mb_x, mb_y;
@@ -326,7 +333,7 @@ static int decode_ext_header(Wmv2Context *w){
code = get_bits(&gb, 3);
if(code==0) return -1;
-
+
s->slice_height = s->mb_height / code;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
@@ -467,7 +474,7 @@ s->picture_number++; //FIXME ?
return 0;
}
-void ff_wmv2_decode_init(MpegEncContext *s){
+static void ff_wmv2_decode_init(MpegEncContext *s){
}
static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){
@@ -491,7 +498,7 @@ static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){
static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
MpegEncContext * const s= &w->s;
int xy, wrap, diff, type;
- INT16 *A, *B, *C, *mot_val;
+ int16_t *A, *B, *C, *mot_val;
wrap = s->block_wrap[0];
xy = s->block_index[0];
@@ -576,12 +583,11 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, DCTELEM *block, int n,
static void wmv2_add_block(Wmv2Context *w, DCTELEM *block1, uint8_t *dst, int stride, int n){
MpegEncContext * const s= &w->s;
uint8_t temp[2][64];
- int i;
-
+
switch(w->abt_type_table[n]){
case 0:
if (s->block_last_index[n] >= 0) {
- s->idct_add (dst, stride, block1);
+ s->dsp.idct_add (dst, stride, block1);
}
break;
case 1:
@@ -614,12 +620,12 @@ void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block1[6][64], uint8_t *dest_y, u
}
void ff_mspel_motion(MpegEncContext *s,
- UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
- UINT8 **ref_picture, op_pixels_func (*pix_op)[4],
+ uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
+ uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h)
{
Wmv2Context * const w= (Wmv2Context*)s;
- UINT8 *ptr;
+ uint8_t *ptr;
int dxy, offset, mx, my, src_x, src_y, v_edge_pos, linesize, uvlinesize;
int emu=0;
@@ -700,12 +706,10 @@ static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
{
Wmv2Context * const w= (Wmv2Context*)s;
int cbp, code, i;
- UINT8 *coded_val;
+ uint8_t *coded_val;
if(w->j_type) return 0;
- s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0;
-
if (s->pict_type == P_TYPE) {
if(s->mb_type[s->mb_y * s->mb_width + s->mb_x]&MB_TYPE_SKIPED){
/* skip mb */
@@ -829,6 +833,7 @@ AVCodec wmv2_decoder = {
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
+#ifdef CONFIG_ENCODERS
AVCodec wmv2_encoder = {
"wmv2",
CODEC_TYPE_VIDEO,
@@ -838,4 +843,4 @@ AVCodec wmv2_encoder = {
MPV_encode_picture,
MPV_encode_end,
};
-
+#endif