diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-06 17:56:09 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-06 17:56:09 +0400 |
commit | 4b791fc8505ae11f91cab5f813e4e564acbe8e26 (patch) | |
tree | cc19bf8c86fc5e45f2dfa2df31f923ee707334ce /src/filters/transform/MPCVideoDec/ffmpeg/libavcodec | |
parent | 97a8a7805c2dfd2c5987c671602c2944cc4e655d (diff) |
updated ffmpeg
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2210 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/MPCVideoDec/ffmpeg/libavcodec')
24 files changed, 543 insertions, 280 deletions
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h index cb00b1520..40fed9b13 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h @@ -2797,15 +2797,14 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[4]);
+#if LIBAVCODEC_VERSION_MAJOR < 53
/**
- * Check if the given dimension of a picture is valid, meaning that all
- * bytes of the picture can be addressed with a signed int.
- *
- * @param[in] w Width of the picture.
- * @param[in] h Height of the picture.
- * @return Zero if valid, a negative value if invalid.
+ * @deprecated Deprecated in favor of av_check_image_size().
*/
+attribute_deprecated
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
+#endif
+
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
FF_EXPORT int avcodec_thread_init(AVCodecContext *s, int thread_count);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c index 2e0e1e7dc..eff067ad6 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c @@ -4332,10 +4332,6 @@ av_cold void attribute_align_arg dsputil_init(DSPContext* c, AVCodecContext *avc c->draw_edges = draw_edges_c;
-#if CONFIG_CAVS_DECODER
- ff_cavsdsp_init(c,avctx);
-#endif
-
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h index c2030f9b0..778d3dfc1 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h @@ -327,15 +327,6 @@ typedef struct DSPContext { qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
- /* AVS specific */
- qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
- qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
- void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
-
me_cmp_func pix_abs[2][4];
/* huffyuv specific */
@@ -618,7 +609,6 @@ extern int mm_flags; void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_dwt(DSPContext *c);
-void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/flvdec.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/flvdec.c index f1556167e..32f595a27 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/flvdec.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/flvdec.c @@ -20,6 +20,7 @@ #include "mpegvideo.h" #include "h263.h" #include "flv.h" +#include "libavcore/imgutils.h" void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){ int is11 = get_bits1(gb); @@ -82,7 +83,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s) width = height = 0; break; } - if(avcodec_check_dimensions(s->avctx, width, height)) + if(av_check_image_size(width, height, 0, s->avctx)) return -1; s->width = width; s->height = height; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mjpegdec.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mjpegdec.c index 4b2654256..05999713b 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mjpegdec.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mjpegdec.c @@ -33,6 +33,7 @@ //#define DEBUG
#include <assert.h>
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mjpeg.h"
@@ -218,7 +219,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) height= s->height;
av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
- if(avcodec_check_dimensions(s->avctx, width, height))
+ if(av_check_image_size(width, height, 0, s->avctx))
return -1;
nb_components = get_bits(&s->gb, 8);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv10.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv10.c index de7e3beca..829c9b3b1 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv10.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv10.c @@ -25,6 +25,7 @@ * RV10/RV20 decoder
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -369,7 +370,7 @@ static int rv20_decode_picture_header(MpegEncContext *s) }
if(new_w != s->width || new_h != s->height){
av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
- if (avcodec_check_dimensions(s->avctx, new_w, new_h) < 0)
+ if (av_check_image_size(new_w, new_h, 0, s->avctx) < 0)
return -1;
MPV_common_end(s);
avcodec_set_dimensions(s->avctx, new_w, new_h);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv40.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv40.c index d425c6ff1..13ba5b6ee 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv40.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/rv40.c @@ -24,6 +24,8 @@ * RV40 decoder */ +#include "libavcore/imgutils.h" + #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" @@ -142,7 +144,7 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn si->pts = get_bits(gb, 13); if(!si->type || !get_bits1(gb)) rv40_parse_picture_size(gb, &w, &h); - if(avcodec_check_dimensions(r->s.avctx, w, h) < 0) + if(av_check_image_size(w, h, 0, r->s.avctx) < 0) return -1; si->width = w; si->height = h; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c index 78925d915..240ae68f1 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c @@ -210,13 +210,11 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ *width=FFALIGN(*width, align);
}
+#if LIBAVCODEC_VERSION_MAJOR < 53
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
- if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
- return 0;
-
- av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
- return AVERROR(EINVAL);
+ return av_check_image_size(w, h, 0, av_log_ctx);
}
+#endif
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
@@ -234,7 +232,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ return -1;
}
- if(avcodec_check_dimensions(s,w,h))
+ if(av_check_image_size(w, h, 0, s))
return -1;
if(s->internal_buffer==NULL){
@@ -491,7 +489,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) #define SANE_NB_CHANNELS 128U
if (((avctx->coded_width || avctx->coded_height)
- && avcodec_check_dimensions(avctx, avctx->coded_width, avctx->coded_height))
+ && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx))
|| avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
@@ -550,7 +548,7 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
- if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
+ if(av_check_image_size(avctx->width, avctx->height, 0, avctx))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
@@ -569,7 +567,7 @@ int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *pic int ret;
*got_picture_ptr= 0;
- if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
+ if((avctx->coded_width||avctx->coded_height) && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp3.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp3.c index 4e0c1b512..4d0e2a4b0 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp3.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp3.c @@ -33,6 +33,7 @@ #include <stdlib.h>
#include <string.h>
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"
@@ -2024,7 +2025,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) visible_width = s->width = get_bits(gb, 16) << 4;
visible_height = s->height = get_bits(gb, 16) << 4;
- if(avcodec_check_dimensions(avctx, s->width, s->height)){
+ if(av_check_image_size(s->width, s->height, 0, avctx)){
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", s->width, s->height);
s->width= s->height= 0;
return -1;
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp5.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp5.c index bb9b62e07..1441fb9cb 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp5.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp5.c @@ -39,7 +39,7 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, VP56RangeCoder *c = &s->c; int rows, cols; - vp56_init_range_decoder(&s->c, buf, buf_size); + ff_vp56_init_range_decoder(&s->c, buf, buf_size); s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c); vp56_rac_get(c); ff_vp56_init_dequant(s, vp56_rac_gets(c, 6)); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h index 69518fa73..f3e0abdd7 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h @@ -181,19 +181,12 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, * vp56 specific range coder implementation */ -static inline void vp56_init_range_decoder(VP56RangeCoder *c, - const uint8_t *buf, int buf_size) -{ - c->high = 255; - c->bits = -8; - c->buffer = buf; - c->end = buf + buf_size; - c->code_word = bytestream_get_be16(&c->buffer); -} +extern const uint8_t ff_vp56_norm_shift[256]; +void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size); static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) { - int shift = ff_h264_norm_shift[c->high] - 1; + int shift = ff_vp56_norm_shift[c->high]; int bits = c->bits; unsigned int code_word = c->code_word; @@ -214,7 +207,7 @@ static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) #ifndef vp56_rac_get_prob #define vp56_rac_get_prob vp56_rac_get_prob -static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) +static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) { unsigned int code_word = vp56_rac_renorm(c); unsigned int low = 1 + (((c->high - 1) * prob) >> 8); @@ -246,7 +239,7 @@ static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int pro return 0; } -static inline int vp56_rac_get(VP56RangeCoder *c) +static av_always_inline int vp56_rac_get(VP56RangeCoder *c) { unsigned int code_word = vp56_rac_renorm(c); /* equiprobable */ @@ -265,12 +258,12 @@ static inline int vp56_rac_get(VP56RangeCoder *c) } // rounding is different than vp56_rac_get, is vp56_rac_get wrong? -static inline int vp8_rac_get(VP56RangeCoder *c) +static av_always_inline int vp8_rac_get(VP56RangeCoder *c) { return vp56_rac_get_prob(c, 128); } -static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) +static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits) { int value = 0; @@ -281,7 +274,7 @@ static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) return value; } -static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits) +static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits) { int value = 0; @@ -293,7 +286,7 @@ static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits) } // fixme: add 1 bit to all the calls to this? -static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits) +static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits) { int v; @@ -309,21 +302,22 @@ static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits) } // P(7) -static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) +static av_unused int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) { int v = vp56_rac_gets(c, 7) << 1; return v + !v; } -static inline int vp8_rac_get_nn(VP56RangeCoder *c) +static av_unused int vp8_rac_get_nn(VP56RangeCoder *c) { int v = vp8_rac_get_uint(c, 7) << 1; return v + !v; } -static inline int vp56_rac_get_tree(VP56RangeCoder *c, - const VP56Tree *tree, - const uint8_t *probs) +static av_always_inline +int vp56_rac_get_tree(VP56RangeCoder *c, + const VP56Tree *tree, + const uint8_t *probs) { while (tree->val > 0) { if (vp56_rac_get_prob(c, probs[tree->prob_idx])) @@ -339,8 +333,9 @@ static inline int vp56_rac_get_tree(VP56RangeCoder *c, * on a node other than the root node, needed for coeff decode where this is * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) */ -static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs, int i) +static av_always_inline +int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs, int i) { do { i = tree[i][vp56_rac_get_prob(c, probs[i])]; @@ -351,14 +346,15 @@ static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t ( // how probabilities are associated with decisions is different I think // well, the new scheme fits in the old but this way has one fewer branches per decision -static inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs) +static av_always_inline +int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs) { return vp8_rac_get_tree_with_offset(c, tree, probs, 0); } // DCTextra -static inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) +static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) { int v = 0; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56rac.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56rac.c new file mode 100644 index 000000000..752a42bc6 --- /dev/null +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56rac.c @@ -0,0 +1,47 @@ +/* + * VP5/6/8 decoder + * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "vp56.h" + +const uint8_t ff_vp56_norm_shift[256]= { + 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,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,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,1,1, + 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,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,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,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, +}; + +void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size) +{ + c->high = 255; + c->bits = -8; + c->buffer = buf; + c->end = buf + buf_size; + c->code_word = bytestream_get_be16(&c->buffer); +} diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp6.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp6.c index 4c2aec67a..de3be4084 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp6.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp6.c @@ -87,7 +87,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, res = 2; } - vp56_init_range_decoder(c, buf+6, buf_size-6); + ff_vp56_init_range_decoder(c, buf+6, buf_size-6); vp56_rac_gets(c, 2); parse_filter_info = s->filter_header; @@ -103,7 +103,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, buf += 2; buf_size -= 2; } - vp56_init_range_decoder(c, buf+1, buf_size-1); + ff_vp56_init_range_decoder(c, buf+1, buf_size-1); *golden_frame = vp56_rac_get(c); if (s->filter_header) { @@ -143,7 +143,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, s->parse_coeff = vp6_parse_coeff_huffman; init_get_bits(&s->gb, buf, buf_size<<3); } else { - vp56_init_range_decoder(&s->cc, buf, buf_size); + ff_vp56_init_range_decoder(&s->cc, buf, buf_size); s->ccp = &s->cc; } } else { diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c index 6524a7141..1cfea612b 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c @@ -22,6 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavcore/imgutils.h" #include "avcodec.h" #include "vp56.h" #include "vp8data.h" @@ -88,8 +89,8 @@ typedef struct { VP8FilterStrength *filter_strength; int mb_stride; - uint8_t *intra4x4_pred_mode; - uint8_t *intra4x4_pred_mode_base; + uint8_t *intra4x4_pred_mode_top; + uint8_t intra4x4_pred_mode_left[4]; uint8_t *segmentation_map; int b4_stride; @@ -117,6 +118,7 @@ typedef struct { */ DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4]; DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16]; + DECLARE_ALIGNED(16, DCTELEM, block_dc)[16]; uint8_t intra4x4_pred_mode_mb[16]; int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock @@ -194,7 +196,8 @@ typedef struct { uint8_t golden; uint8_t pred16x16[4]; uint8_t pred8x8c[3]; - uint8_t token[4][8][3][NUM_DCT_TOKENS-1]; + /* Padded to allow overreads */ + uint8_t token[4][17][3][NUM_DCT_TOKENS-1]; uint8_t mvc[2][19]; } prob[2]; } VP8Context; @@ -211,21 +214,18 @@ static void vp8_decode_flush(AVCodecContext *avctx) av_freep(&s->macroblocks_base); av_freep(&s->filter_strength); - av_freep(&s->intra4x4_pred_mode_base); + av_freep(&s->intra4x4_pred_mode_top); av_freep(&s->top_nnz); av_freep(&s->edge_emu_buffer); av_freep(&s->top_border); av_freep(&s->segmentation_map); s->macroblocks = NULL; - s->intra4x4_pred_mode = NULL; } static int update_dimensions(VP8Context *s, int width, int height) { - int i; - - if (avcodec_check_dimensions(s->avctx, width, height)) + if (av_check_image_size(width, height, 0, s->avctx)) return AVERROR_INVALIDDATA; vp8_decode_flush(s->avctx); @@ -242,21 +242,16 @@ static int update_dimensions(VP8Context *s, int width, int height) s->macroblocks_base = av_mallocz((s->mb_stride+s->mb_height*2+2)*sizeof(*s->macroblocks)); s->filter_strength = av_mallocz(s->mb_stride*sizeof(*s->filter_strength)); - s->intra4x4_pred_mode_base = av_mallocz(s->b4_stride*(4*s->mb_height+1)); + s->intra4x4_pred_mode_top = av_mallocz(s->b4_stride*4); s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz)); s->top_border = av_mallocz((s->mb_width+1)*sizeof(*s->top_border)); s->segmentation_map = av_mallocz(s->mb_stride*s->mb_height); - if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_base || + if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_top || !s->top_nnz || !s->top_border || !s->segmentation_map) return AVERROR(ENOMEM); s->macroblocks = s->macroblocks_base + 1; - s->intra4x4_pred_mode = s->intra4x4_pred_mode_base + 4 + s->b4_stride; - - memset(s->intra4x4_pred_mode_base, DC_PRED, s->b4_stride); - for (i = 0; i < 4*s->mb_height; i++) - s->intra4x4_pred_mode[i*s->b4_stride-1] = DC_PRED; return 0; } @@ -311,11 +306,11 @@ static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size) if (buf_size - size < 0) return -1; - vp56_init_range_decoder(&s->coeff_partition[i], buf, size); + ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, size); buf += size; buf_size -= size; } - vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size); + ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size); return 0; } @@ -395,7 +390,7 @@ static void update_refs(VP8Context *s) static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; - int header_size, hscale, vscale, i, j, k, l, ret; + int header_size, hscale, vscale, i, j, k, l, m, ret; int width = s->avctx->width; int height = s->avctx->height; @@ -435,7 +430,10 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) av_log_missing_feature(s->avctx, "Upscaling", 1); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; - memcpy(s->prob->token , vp8_token_default_probs , sizeof(s->prob->token)); + for (i = 0; i < 4; i++) + for (j = 0; j < 16; j++) + memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]], + sizeof(s->prob->token[i][j])); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c , vp8_pred8x8c_prob_inter , sizeof(s->prob->pred8x8c)); memcpy(s->prob->mvc , vp8_mv_default_prob , sizeof(s->prob->mvc)); @@ -448,7 +446,7 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) return ret; } - vp56_init_range_decoder(c, buf, header_size); + ff_vp56_init_range_decoder(c, buf, header_size); buf += header_size; buf_size -= header_size; @@ -495,8 +493,11 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) for (j = 0; j < 8; j++) for (k = 0; k < 3; k++) for (l = 0; l < NUM_DCT_TOKENS-1; l++) - if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) - s->prob->token[i][j][k][l] = vp8_rac_get_uint(c, 8); + if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) { + int prob = vp8_rac_get_uint(c, 8); + for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++) + s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob; + } if ((s->mbskip_enabled = vp8_rac_get(c))) s->prob->mbskip = vp8_rac_get_uint(c, 8); @@ -643,19 +644,32 @@ const uint8_t *get_submv_prob(uint32_t left, uint32_t top) static av_always_inline int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb) { - int part_idx = mb->partitioning = - vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob); - int n, num = vp8_mbsplit_count[part_idx]; + int part_idx; + int n, num; VP8Macroblock *top_mb = &mb[2]; VP8Macroblock *left_mb = &mb[-1]; const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning], *mbsplits_top = vp8_mbsplits[top_mb->partitioning], - *mbsplits_cur = vp8_mbsplits[part_idx], - *firstidx = vp8_mbfirstidx[part_idx]; + *mbsplits_cur, *firstidx; VP56mv *top_mv = top_mb->bmv; VP56mv *left_mv = left_mb->bmv; VP56mv *cur_mv = mb->bmv; + if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) { + if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1])) { + part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]); + } else { + part_idx = VP8_SPLITMVMODE_8x8; + } + } else { + part_idx = VP8_SPLITMVMODE_4x4; + } + + num = vp8_mbsplit_count[part_idx]; + mbsplits_cur = vp8_mbsplits[part_idx], + firstidx = vp8_mbfirstidx[part_idx]; + mb->partitioning = part_idx; + for (n = 0; n < num; n++) { int k = firstidx[n]; uint32_t left, above; @@ -672,20 +686,19 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb) submv_prob = get_submv_prob(left, above); - switch (vp8_rac_get_tree(c, vp8_submv_ref_tree, submv_prob)) { - case VP8_SUBMVMODE_NEW4X4: - mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]); - mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]); - break; - case VP8_SUBMVMODE_ZERO4X4: - AV_ZERO32(&mb->bmv[n]); - break; - case VP8_SUBMVMODE_LEFT4X4: + if (vp56_rac_get_prob_branchy(c, submv_prob[0])) { + if (vp56_rac_get_prob_branchy(c, submv_prob[1])) { + if (vp56_rac_get_prob_branchy(c, submv_prob[2])) { + mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]); + mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]); + } else { + AV_ZERO32(&mb->bmv[n]); + } + } else { + AV_WN32A(&mb->bmv[n], above); + } + } else { AV_WN32A(&mb->bmv[n], left); - break; - case VP8_SUBMVMODE_TOP4X4: - AV_WN32A(&mb->bmv[n], above); - break; } } @@ -693,31 +706,32 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb) } static av_always_inline -void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4, - int stride, int keyframe) +void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, + int mb_x, int keyframe) { - int x, y, t, l, i; - + uint8_t *intra4x4 = s->intra4x4_pred_mode_mb; if (keyframe) { - const uint8_t *ctx; + int x, y; + uint8_t* const top = s->intra4x4_pred_mode_top + 4 * mb_x; + uint8_t* const left = s->intra4x4_pred_mode_left; for (y = 0; y < 4; y++) { for (x = 0; x < 4; x++) { - t = intra4x4[x - stride]; - l = intra4x4[x - 1]; - ctx = vp8_pred4x4_prob_intra[t][l]; - intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx); + const uint8_t *ctx; + ctx = vp8_pred4x4_prob_intra[top[x]][left[y]]; + *intra4x4 = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx); + left[y] = top[x] = *intra4x4; + intra4x4++; } - intra4x4 += stride; } } else { + int i; for (i = 0; i < 16; i++) intra4x4[i] = vp8_rac_get_tree(c, vp8_pred4x4_tree, vp8_pred4x4_prob_inter); } } static av_always_inline -void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, - uint8_t *intra4x4, uint8_t *segment) +void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_t *segment) { VP56RangeCoder *c = &s->c; @@ -731,16 +745,18 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra, vp8_pred16x16_prob_intra); if (mb->mode == MODE_I4x4) { - decode_intra4x4_modes(c, intra4x4, s->b4_stride, 1); - } else - fill_rectangle(intra4x4, 4, 4, s->b4_stride, vp8_pred4x4_mode[mb->mode], 1); + decode_intra4x4_modes(s, c, mb_x, 1); + } else { + const uint32_t modes = vp8_pred4x4_mode[mb->mode] * 0x01010101u; + AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes); + AV_WN32A(s->intra4x4_pred_mode_left, modes); + } s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, vp8_pred8x8c_prob_intra); mb->ref_frame = VP56_FRAME_CURRENT; } else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) { VP56mv near[2], best; uint8_t cnt[4] = { 0 }; - uint8_t p[4]; // inter MB, 16.2 if (vp56_rac_get_prob_branchy(c, s->prob->last)) @@ -752,30 +768,30 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, // motion vectors, 16.3 find_near_mvs(s, mb, mb_x, mb_y, near, &best, cnt); - p[0] = vp8_mode_contexts[cnt[0]][0]; - p[1] = vp8_mode_contexts[cnt[1]][1]; - p[2] = vp8_mode_contexts[cnt[2]][2]; - p[3] = vp8_mode_contexts[cnt[3]][3]; - mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_mvinter, p); - switch (mb->mode) { - case VP8_MVMODE_SPLIT: - clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); - mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1]; - break; - case VP8_MVMODE_ZERO: + if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[0]][0])) { + if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[1]][1])) { + if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[2]][2])) { + if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[3]][3])) { + mb->mode = VP8_MVMODE_SPLIT; + clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); + mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1]; + } else { + mb->mode = VP8_MVMODE_NEW; + clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); + mb->mv.y += + read_mv_component(c, s->prob->mvc[0]); + mb->mv.x += + read_mv_component(c, s->prob->mvc[1]); + } + } else { + mb->mode = VP8_MVMODE_NEAR; + clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y); + } + } else { + mb->mode = VP8_MVMODE_NEAREST; + clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y); + } + } else { + mb->mode = VP8_MVMODE_ZERO; AV_ZERO32(&mb->mv); - break; - case VP8_MVMODE_NEAREST: - clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y); - break; - case VP8_MVMODE_NEAR: - clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y); - break; - case VP8_MVMODE_NEW: - clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); - mb->mv.y += + read_mv_component(c, s->prob->mvc[0]); - mb->mv.x += + read_mv_component(c, s->prob->mvc[1]); - break; } if (mb->mode != VP8_MVMODE_SPLIT) { mb->partitioning = VP8_SPLITMVMODE_NONE; @@ -786,7 +802,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16); if (mb->mode == MODE_I4x4) - decode_intra4x4_modes(c, intra4x4, 4, 0); + decode_intra4x4_modes(s, c, mb_x, 0); s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c); mb->ref_frame = VP56_FRAME_CURRENT; @@ -806,37 +822,30 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, * @return 0 if no coeffs were decoded * otherwise, the index of the last coeff decoded plus one */ -static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], - uint8_t probs[8][3][NUM_DCT_TOKENS-1], - int i, int zero_nhood, int16_t qmul[2]) +static int decode_block_coeffs_internal(VP56RangeCoder *c, DCTELEM block[16], + uint8_t probs[8][3][NUM_DCT_TOKENS-1], + int i, uint8_t *token_prob, int16_t qmul[2]) { - uint8_t *token_prob; - int nonzero = 0; - int coeff; - + goto skip_eob; do { - token_prob = probs[vp8_coeff_band[i]][zero_nhood]; - + int coeff; if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB - return nonzero; + return i; skip_eob: if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0 - zero_nhood = 0; - token_prob = probs[vp8_coeff_band[++i]][0]; - if (i < 16) - goto skip_eob; - return nonzero; // invalid input; blocks should end with EOB + if (++i == 16) + return i; // invalid input; blocks should end with EOB + token_prob = probs[i][0]; + goto skip_eob; } if (!vp56_rac_get_prob_branchy(c, token_prob[2])) { // DCT_1 coeff = 1; - zero_nhood = 1; + token_prob = probs[i+1][1]; } else { - zero_nhood = 2; - if (!vp56_rac_get_prob_branchy(c, token_prob[3])) { // DCT 2,3,4 - coeff = vp56_rac_get_prob(c, token_prob[4]); + coeff = vp56_rac_get_prob_branchy(c, token_prob[4]); if (coeff) coeff += vp56_rac_get_prob(c, token_prob[5]); coeff += 2; @@ -858,36 +867,49 @@ skip_eob: coeff += vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]); } } + token_prob = probs[i+1][2]; } - - // todo: full [16] qmat? load into register? block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i]; - nonzero = ++i; - } while (i < 16); + } while (++i < 16); + + return i; +} - return nonzero; +static av_always_inline +int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], + uint8_t probs[8][3][NUM_DCT_TOKENS-1], + int i, int zero_nhood, int16_t qmul[2]) +{ + uint8_t *token_prob = probs[i][zero_nhood]; + if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB + return 0; + return decode_block_coeffs_internal(c, block, probs, i, token_prob, qmul); } static av_always_inline void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9]) { - LOCAL_ALIGNED_16(DCTELEM, dc,[16]); int i, x, y, luma_start = 0, luma_ctx = 3; int nnz_pred, nnz, nnz_total = 0; int segment = s->segment; + int block_dc = 0; if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { - AV_ZERO128(dc); - AV_ZERO128(dc+8); nnz_pred = t_nnz[8] + l_nnz[8]; // decode DC values and do hadamard - nnz = decode_block_coeffs(c, dc, s->prob->token[1], 0, nnz_pred, + nnz = decode_block_coeffs(c, s->block_dc, s->prob->token[1], 0, nnz_pred, s->qmat[segment].luma_dc_qmul); l_nnz[8] = t_nnz[8] = !!nnz; - nnz_total += nnz; - s->vp8dsp.vp8_luma_dc_wht(s->block, dc); + if (nnz) { + nnz_total += nnz; + block_dc = 1; + if (nnz == 1) + s->vp8dsp.vp8_luma_dc_wht_dc(s->block, s->block_dc); + else + s->vp8dsp.vp8_luma_dc_wht(s->block, s->block_dc); + } luma_start = 1; luma_ctx = 0; } @@ -898,8 +920,8 @@ void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, nnz_pred = l_nnz[y] + t_nnz[x]; nnz = decode_block_coeffs(c, s->block[y][x], s->prob->token[luma_ctx], luma_start, nnz_pred, s->qmat[segment].luma_qmul); - // nnz+luma_start may be one more than the actual last index, but we don't care - s->non_zero_count_cache[y][x] = nnz + luma_start; + // nnz+block_dc may be one more than the actual last index, but we don't care + s->non_zero_count_cache[y][x] = nnz + block_dc; t_nnz[x] = l_nnz[y] = !!nnz; nnz_total += nnz; } @@ -982,7 +1004,7 @@ int check_intra_pred_mode(int mode, int mb_x, int mb_y) static av_always_inline void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, - uint8_t *intra4x4, int mb_x, int mb_y) + int mb_x, int mb_y) { int x, y, mode, nnz, tr; @@ -998,7 +1020,7 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, s->hpc.pred16x16[mode](dst[0], s->linesize); } else { uint8_t *ptr = dst[0]; - int stride = s->keyframe ? s->b4_stride : 4; + uint8_t *intra4x4 = s->intra4x4_pred_mode_mb; // all blocks on the right edge of the macroblock use bottom edge // the top macroblock for their topright edge @@ -1033,7 +1055,7 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, } ptr += 4*s->linesize; - intra4x4 += stride; + intra4x4 += 4; } } @@ -1134,8 +1156,8 @@ static av_always_inline void prefetch_motion(VP8Context *s, VP8Macroblock *mb, i /* Don't prefetch refs that haven't been used very often this frame. */ if (s->ref_count[ref-1] > (mb_xy >> 5)) { int x_off = mb_x << 4, y_off = mb_y << 4; - int mx = mb->mv.x + x_off + 8; - int my = mb->mv.y + y_off; + int mx = (mb->mv.x>>2) + x_off + 8; + int my = (mb->mv.y>>2) + y_off; uint8_t **src= s->framep[ref]->data; int off= mx + (my + (mb_x&3)*4)*s->linesize + 64; s->dsp.prefetch(src[0]+off, s->linesize, 4); @@ -1520,11 +1542,12 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, // top edge of 127 for intra prediction memset(s->top_border, 127, (s->mb_width+1)*sizeof(*s->top_border)); memset(s->ref_count, 0, sizeof(s->ref_count)); + if (s->keyframe) + memset(s->intra4x4_pred_mode_top, DC_PRED, s->b4_stride*4); for (mb_y = 0; mb_y < s->mb_height; mb_y++) { VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)]; VP8Macroblock *mb = s->macroblocks + (s->mb_height - mb_y - 1)*2; - uint8_t *intra4x4 = s->intra4x4_pred_mode + 4*mb_y*s->b4_stride; uint8_t *segment_map = s->segmentation_map + mb_y*s->mb_stride; int mb_xy = mb_y * s->mb_stride; uint8_t *dst[3] = { @@ -1534,6 +1557,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, }; memset(s->left_nnz, 0, sizeof(s->left_nnz)); + AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101); // left edge of 129 for intra prediction if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) @@ -1544,14 +1568,13 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, memset(s->top_border, 129, sizeof(*s->top_border)); for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { - uint8_t *intra4x4_mb = s->keyframe ? intra4x4 + 4*mb_x : s->intra4x4_pred_mode_mb; uint8_t *segment_mb = segment_map+mb_x; /* Prefetch the current frame, 4 MBs ahead */ s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4); s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2); - decode_mb_mode(s, mb, mb_x, mb_y, intra4x4_mb, segment_mb); + decode_mb_mode(s, mb, mb_x, mb_y, segment_mb); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS); @@ -1559,7 +1582,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, decode_mb_coeffs(s, c, mb, s->top_nnz[mb_x], s->left_nnz); if (mb->mode <= MODE_I4x4) - intra_predict(s, dst, mb, intra4x4_mb, mb_x, mb_y); + intra_predict(s, dst, mb, mb_x, mb_y); else inter_predict(s, dst, mb, mb_x, mb_y); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h index 1bdac16be..a64b7d5b4 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h @@ -55,13 +55,6 @@ enum inter_mvmode { VP8_MVMODE_SPLIT }; -enum inter_submvmode { - VP8_SUBMVMODE_LEFT4X4, - VP8_SUBMVMODE_TOP4X4, - VP8_SUBMVMODE_ZERO4X4, - VP8_SUBMVMODE_NEW4X4 -}; - enum inter_splitmvmode { VP8_SPLITMVMODE_16x8 = 0, ///< 2 16x8 blocks (vertical) VP8_SPLITMVMODE_8x16, ///< 2 8x16 blocks (horizontal) @@ -111,13 +104,6 @@ static const int vp8_mode_contexts[6][4] = { { 234, 188, 128, 28 }, }; -static const int8_t vp8_pred16x16_tree_mvinter[4][2] = { - { -VP8_MVMODE_ZERO, 1 }, // '0' - { -VP8_MVMODE_NEAREST, 2 }, // '10' - { -VP8_MVMODE_NEAR, 3 }, // '110' - { -VP8_MVMODE_NEW, -VP8_MVMODE_SPLIT } // '1110', '1111' -}; - static const uint8_t vp8_mbsplits[5][16] = { { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, @@ -137,12 +123,6 @@ static const uint8_t vp8_mbfirstidx[4][16] = { 8, 9, 10, 11, 12, 13, 14, 15 } }; -static const int8_t vp8_mbsplit_tree[3][2] = { - { -VP8_SPLITMVMODE_4x4, 1 }, // '0' - 16 individual MVs - { -VP8_SPLITMVMODE_8x8, 2 }, // '10' - quarter-based MVs - { -VP8_SPLITMVMODE_16x8, // '110' - top/bottom MVs - -VP8_SPLITMVMODE_8x16 } // '111' - left/right MVs -}; static const uint8_t vp8_mbsplit_count[4] = { 2, 2, 4, 16 }; static const uint8_t vp8_mbsplit_prob[3] = { 110, 111, 150 }; @@ -154,12 +134,6 @@ static const uint8_t vp8_submv_prob[5][3] = { { 208, 1, 1 } }; -static const int8_t vp8_submv_ref_tree[3][2] = { - { -VP8_SUBMVMODE_LEFT4X4, 1 }, // '0' - { -VP8_SUBMVMODE_TOP4X4, 2 }, // '10' - { -VP8_SUBMVMODE_ZERO4X4, -VP8_SUBMVMODE_NEW4X4 } // '110', '111' -}; - static const uint8_t vp8_pred16x16_prob_intra[4] = { 145, 156, 163, 128 }; static const uint8_t vp8_pred16x16_prob_inter[4] = { 112, 86, 140, 37 }; @@ -327,6 +301,20 @@ static const uint8_t vp8_coeff_band[16] = 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7 }; +/* Inverse of vp8_coeff_band: mappings of bands to coefficient indexes. + * Each list is -1-terminated. */ +static const int8_t vp8_coeff_band_indexes[8][10] = +{ + {0, -1}, + {1, -1}, + {2, -1}, + {3, -1}, + {5, -1}, + {6, -1}, + {4, 7, 8, 9, 10, 11, 12, 13, 14, -1}, + {15, -1} +}; + static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 }; static const uint8_t vp8_dct_cat2_prob[] = { 165, 145, 0 }; static const uint8_t vp8_dct_cat3_prob[] = { 173, 148, 140, 0 }; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c index 0c61d9252..5c83b6df8 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c @@ -46,14 +46,30 @@ static void vp8_luma_dc_wht_c(DCTELEM block[4][4][16], DCTELEM dc[16]) t1 = dc[i*4+1] + dc[i*4+2]; t2 = dc[i*4+1] - dc[i*4+2]; t3 = dc[i*4+0] - dc[i*4+3] + 3; // rounding - - *block[i][0] = (t0 + t1) >> 3; - *block[i][1] = (t3 + t2) >> 3; - *block[i][2] = (t0 - t1) >> 3; - *block[i][3] = (t3 - t2) >> 3; + dc[i*4+0] = 0; + dc[i*4+1] = 0; + dc[i*4+2] = 0; + dc[i*4+3] = 0; + + block[i][0][0] = (t0 + t1) >> 3; + block[i][1][0] = (t3 + t2) >> 3; + block[i][2][0] = (t0 - t1) >> 3; + block[i][3][0] = (t3 - t2) >> 3; } } +static void vp8_luma_dc_wht_dc_c(DCTELEM block[4][4][16], DCTELEM dc[16]) +{ + int i, val = (dc[0] + 3) >> 3; + dc[0] = 0; + + for (i = 0; i < 4; i++) { + block[i][0][0] = val; + block[i][1][0] = val; + block[i][2][0] = val; + block[i][3][0] = val; + } +} #define MUL_20091(a) ((((a)*20091) >> 16) + (a)) #define MUL_35468(a) (((a)*35468) >> 16) @@ -476,6 +492,7 @@ VP8_BILINEAR(4) av_cold void ff_vp8dsp_init(VP8DSPContext *dsp) { dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c; + dsp->vp8_luma_dc_wht_dc = vp8_luma_dc_wht_dc_c; dsp->vp8_idct_add = vp8_idct_add_c; dsp->vp8_idct_dc_add = vp8_idct_dc_add_c; dsp->vp8_idct_dc_add4y = vp8_idct_dc_add4y_c; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h index 47b1a9077..ee5c7ec0f 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h @@ -31,6 +31,7 @@ typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, int dstStride, uint8_t *src typedef struct VP8DSPContext { void (*vp8_luma_dc_wht)(DCTELEM block[4][4][16], DCTELEM dc[16]); + void (*vp8_luma_dc_wht_dc)(DCTELEM block[4][4][16], DCTELEM dc[16]); void (*vp8_idct_add)(uint8_t *dst, DCTELEM block[16], int stride); void (*vp8_idct_dc_add)(uint8_t *dst, DCTELEM block[16], int stride); void (*vp8_idct_dc_add4y)(uint8_t *dst, DCTELEM block[4][16], int stride); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c index cd4e46219..4add01fe9 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c @@ -2725,9 +2725,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
#endif
- if (CONFIG_CAVS_DECODER)
- ff_cavsdsp_init_mmx2(c, avctx);
-
if (CONFIG_VC1_DECODER)
ff_vc1dsp_init_mmx(c, avctx);
@@ -2788,9 +2785,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_3dnow;
c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_3dnow;
-
- if (CONFIG_CAVS_DECODER)
- ff_cavsdsp_init_3dnow(c, avctx);
}
@@ -2963,6 +2957,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c) c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_mmxext;
#endif
if( mm_flags&FF_MM_SSE2 ){
+ c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_sse2;
+ c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_sse2;
#if ARCH_X86_64 || !defined(__ICC) || __ICC > 1110
c->h264_v_loop_filter_luma = ff_x264_deblock_v_luma_sse2;
c->h264_h_loop_filter_luma = ff_x264_deblock_h_luma_sse2;
@@ -2975,6 +2971,10 @@ void ff_h264dsp_init_x86(H264DSPContext *c) c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
#endif
}
+ if ( mm_flags&FF_MM_SSSE3 ){
+ c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
+ c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_ssse3;
+ }
}
#endif
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h index 13067dffc..33dafed1f 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h @@ -162,8 +162,6 @@ 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); void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); -void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx); -void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx); void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_weight_sse2.asm b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_weight_sse2.asm new file mode 100644 index 000000000..8667f0690 --- /dev/null +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_weight_sse2.asm @@ -0,0 +1,170 @@ +;***************************************************************************** +;* SSE2-optimized weighted prediction code +;***************************************************************************** +;* Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt +;* Copyright (C) 2010 Eli Friedman <eli.friedman@gmail.com> +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" + +SECTION .text +INIT_XMM + +;----------------------------------------------------------------------------- +; biweight pred: +; +; void h264_biweight_16x16_sse2(uint8_t *dst, uint8_t *src, int stride, +; int log2_denom, int weightd, int weights, +; int offset); +;----------------------------------------------------------------------------- + +%macro BIWEIGHT_SSE2_SETUP 0 + add r6, 1 + or r6, 1 + add r3, 1 + movd m3, r4 + movd m4, r5 + movd m5, r6 + movd m6, r3 + pslld m5, m6 + psrld m5, 1 + pshuflw m3, m3, 0 + pshuflw m4, m4, 0 + pshuflw m5, m5, 0 + punpcklqdq m3, m3 + punpcklqdq m4, m4 + punpcklqdq m5, m5 + pxor m7, m7 +%endmacro + +%macro BIWEIGHT_SSE2_STEPA 3 + movh m%1, [r0+%3] + movh m%2, [r1+%3] + punpcklbw m%1, m7 + punpcklbw m%2, m7 + pmullw m%1, m3 + pmullw m%2, m4 + paddsw m%1, m%2 +%endmacro + +%macro BIWEIGHT_SSE2_STEPB 0 + paddsw m0, m5 + paddsw m1, m5 + psraw m0, m6 + psraw m1, m6 + packuswb m0, m1 +%endmacro + +cglobal h264_biweight_16x16_sse2, 7, 7, 8 + BIWEIGHT_SSE2_SETUP + mov r3, 16 + +.nextrow + BIWEIGHT_SSE2_STEPA 0, 1, 0 + BIWEIGHT_SSE2_STEPA 1, 2, 8 + BIWEIGHT_SSE2_STEPB + mova [r0], m0 + add r0, r2 + add r1, r2 + dec r3 + jnz .nextrow + REP_RET + +cglobal h264_biweight_8x8_sse2, 7, 7, 8 + BIWEIGHT_SSE2_SETUP + mov r3, 4 + lea r4, [r2*2] + +.nextrow + BIWEIGHT_SSE2_STEPA 0, 1, 0 + BIWEIGHT_SSE2_STEPA 1, 2, r2 + BIWEIGHT_SSE2_STEPB + movh [r0], m0 + movhps [r0+r2], m0 + add r0, r4 + add r1, r4 + dec r3 + jnz .nextrow + REP_RET + +%macro BIWEIGHT_SSSE3_SETUP 0 + add r6, 1 + or r6, 1 + add r3, 1 + movd m4, r4 + movd m0, r5 + movd m5, r6 + movd m6, r3 + pslld m5, m6 + psrld m5, 1 + punpcklbw m4, m0 + pshuflw m4, m4, 0 + pshuflw m5, m5, 0 + punpcklqdq m4, m4 + punpcklqdq m5, m5 +%endmacro + +%macro BIWEIGHT_SSSE3_OP 0 + pmaddubsw m0, m4 + pmaddubsw m2, m4 + paddsw m0, m5 + paddsw m2, m5 + psraw m0, m6 + psraw m2, m6 + packuswb m0, m2 +%endmacro + +cglobal h264_biweight_16x16_ssse3, 7, 7, 8 + BIWEIGHT_SSSE3_SETUP + mov r3, 16 + +.nextrow + movh m0, [r0] + movh m2, [r0+8] + movh m3, [r1+8] + punpcklbw m0, [r1] + punpcklbw m2, m3 + BIWEIGHT_SSSE3_OP + mova [r0], m0 + add r0, r2 + add r1, r2 + dec r3 + jnz .nextrow + REP_RET + +cglobal h264_biweight_8x8_ssse3, 7, 7, 8 + BIWEIGHT_SSSE3_SETUP + mov r3, 4 + lea r4, [r2*2] + +.nextrow + movh m0, [r0] + movh m1, [r1] + movh m2, [r0+r2] + movh m3, [r1+r2] + punpcklbw m0, m1 + punpcklbw m2, m3 + BIWEIGHT_SSSE3_OP + movh [r0], m0 + movhps [r0+r2], m0 + add r0, r4 + add r1, r4 + dec r3 + jnz .nextrow + REP_RET diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264dsp_mmx.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264dsp_mmx.c index 4120887af..1dd5874ab 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264dsp_mmx.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264dsp_mmx.c @@ -2323,6 +2323,22 @@ H264_WEIGHT( 4, 8) H264_WEIGHT( 4, 4)
H264_WEIGHT( 4, 2)
+void ff_h264_biweight_8x8_sse2(uint8_t *dst, uint8_t *src, int stride,
+ int log2_denom, int weightd, int weights,
+ int offset);
+
+void ff_h264_biweight_16x16_sse2(uint8_t *dst, uint8_t *src, int stride,
+ int log2_denom, int weightd, int weights,
+ int offset);
+
+void ff_h264_biweight_8x8_ssse3(uint8_t *dst, uint8_t *src, int stride,
+ int log2_denom, int weightd, int weights,
+ int offset);
+
+void ff_h264_biweight_16x16_ssse3(uint8_t *dst, uint8_t *src, int stride,
+ int log2_denom, int weightd, int weights,
+ int offset);
+
void ff_pred16x16_vertical_mmx (uint8_t *src, int stride);
void ff_pred16x16_vertical_sse (uint8_t *src, int stride);
void ff_pred16x16_horizontal_mmx (uint8_t *src, int stride);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h index 95f96e365..ae3bc3dc7 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h @@ -1,54 +1,54 @@ -/**
- * VP5 and VP6 compatible video decoder (arith decoder)
- *
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
- * Copyright (C) 2010 Eli Friedman
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_X86_VP56_ARITH_H
-#define AVCODEC_X86_VP56_ARITH_H
-
-#if HAVE_FAST_CMOV
-#define vp56_rac_get_prob vp56_rac_get_prob
-static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
-{
- unsigned int code_word = vp56_rac_renorm(c);
- unsigned int high = c->high;
- unsigned int low = 1 + (((high - 1) * prob) >> 8);
- unsigned int low_shift = low << 8;
- int bit = 0;
-
- __asm__(
- "subl %4, %1 \n\t"
- "subl %3, %2 \n\t"
- "leal (%2, %3), %3 \n\t"
- "setae %b0 \n\t"
- "cmovb %4, %1 \n\t"
- "cmovb %3, %2 \n\t"
- : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift)
- : "r"(low)
- );
-
- c->high = high;
- c->code_word = code_word;
- return bit;
-}
-#endif
-
-#endif /* AVCODEC_X86_VP56_ARITH_H */
+/** + * VP5 and VP6 compatible video decoder (arith decoder) + * + * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> + * Copyright (C) 2010 Eli Friedman + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_X86_VP56_ARITH_H +#define AVCODEC_X86_VP56_ARITH_H + +#if HAVE_FAST_CMOV +#define vp56_rac_get_prob vp56_rac_get_prob +static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) +{ + unsigned int code_word = vp56_rac_renorm(c); + unsigned int high = c->high; + unsigned int low = 1 + (((high - 1) * prob) >> 8); + unsigned int low_shift = low << 8; + int bit = 0; + + __asm__( + "subl %4, %1 \n\t" + "subl %3, %2 \n\t" + "leal (%2, %3), %3 \n\t" + "setae %b0 \n\t" + "cmovb %4, %1 \n\t" + "cmovb %3, %2 \n\t" + : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift) + : "r"(low) + ); + + c->high = high; + c->code_word = code_word; + return bit; +} +#endif + +#endif /* AVCODEC_X86_VP56_ARITH_H */ diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c index dd7dc696e..40fd0e4e3 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c @@ -224,6 +224,7 @@ extern void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, DCTELEM block[4][16], int str extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, DCTELEM block[4][16], int stride); extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, DCTELEM block[2][16], int stride); extern void ff_vp8_luma_dc_wht_mmx(DCTELEM block[4][4][16], DCTELEM dc[16]); +extern void ff_vp8_luma_dc_wht_sse(DCTELEM block[4][4][16], DCTELEM dc[16]); extern void ff_vp8_idct_add_mmx(uint8_t *dst, DCTELEM block[16], int stride); extern void ff_vp8_idct_add_sse(uint8_t *dst, DCTELEM block[16], int stride); @@ -337,6 +338,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) if (mm_flags & FF_MM_SSE) { c->vp8_idct_add = ff_vp8_idct_add_sse; + c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_sse; c->put_vp8_epel_pixels_tab[0][0][0] = c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse; } diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm index 4f430d80c..6999e87b6 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm @@ -1186,12 +1186,23 @@ VP8_IDCT_ADD sse SWAP %1, %4, %3 %endmacro -INIT_MMX -cglobal vp8_luma_dc_wht_mmx, 2,3 +%macro VP8_DC_WHT 1 +cglobal vp8_luma_dc_wht_%1, 2,3 movq m0, [r1] movq m1, [r1+8] movq m2, [r1+16] movq m3, [r1+24] +%ifidn %1, sse + xorps xmm0, xmm0 + movaps [r1+ 0], xmm0 + movaps [r1+16], xmm0 +%else + pxor m4, m4 + movq [r1+ 0], m4 + movq [r1+ 8], m4 + movq [r1+16], m4 + movq [r1+24], m4 +%endif HADAMARD4_1D 0, 1, 2, 3 TRANSPOSE4x4W 0, 1, 2, 3, 4 paddw m0, [pw_3] @@ -1203,6 +1214,11 @@ cglobal vp8_luma_dc_wht_mmx, 2,3 SCATTER_WHT 0, 1, 0 SCATTER_WHT 2, 3, 2 RET +%endmacro + +INIT_MMX +VP8_DC_WHT mmx +VP8_DC_WHT sse ;----------------------------------------------------------------------------- ; void vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim); |