1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  audio_frame_queue: Clean up ff_af_queue_log_state debug function
  dwt: Remove unused code.
  cavs: convert cavsdata.h to a .c file
  cavs: Move inline functions only used in one file out of the header
  cavs: Move data tables used in only one place to that file
  fate: Add a single symbol Ut Video decoder test
  vf_hqdn3d: x86 asm
  vf_hqdn3d: support 16bit colordepth
  avconv: prefer user-forced input framerate when choosing output framerate

Conflicts:
	ffmpeg.c
	libavcodec/audio_frame_queue.c
	libavcodec/dwt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-08-26 22:36:13 +02:00
commit 17106a7c90
16 changed files with 763 additions and 736 deletions

View File

@ -2137,6 +2137,8 @@ static int transcode_init(void)
if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (ost->filter && !ost->frame_rate.num) if (ost->filter && !ost->frame_rate.num)
ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter); ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter);
if (ist && !ost->frame_rate.num)
ost->frame_rate = ist->framerate;
if (ist && !ost->frame_rate.num) if (ist && !ost->frame_rate.num)
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1}; ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1};
// ost->frame_rate = ist->st->avg_frame_rate.num ? ist->st->avg_frame_rate : (AVRational){25, 1}; // ost->frame_rate = ist->st->avg_frame_rate.num ? ist->st->avg_frame_rate : (AVRational){25, 1};

View File

@ -133,7 +133,7 @@ OBJS-$(CONFIG_BMV_VIDEO_DECODER) += bmv.o
OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmv.o OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmv.o
OBJS-$(CONFIG_C93_DECODER) += c93.o OBJS-$(CONFIG_C93_DECODER) += c93.o
OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \ OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \
mpeg12data.o cavsdata.o mpeg12data.o
OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o
OBJS-$(CONFIG_CDXL_DECODER) += cdxl.o OBJS-$(CONFIG_CDXL_DECODER) += cdxl.o
OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o

View File

@ -80,11 +80,4 @@ int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f);
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,
int *duration); int *duration);
/**
* Log the current state of the queue.
*
* @param afq queue context
*/
void ff_af_queue_log_state(AudioFrameQueue *afq);
#endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */ #endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */

View File

@ -30,7 +30,36 @@
#include "golomb.h" #include "golomb.h"
#include "mathops.h" #include "mathops.h"
#include "cavs.h" #include "cavs.h"
#include "cavsdata.h"
static const uint8_t alpha_tab[64] = {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,
4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 20,
22, 24, 26, 28, 30, 33, 33, 35, 35, 36, 37, 37, 39, 39, 42, 44,
46, 48, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
};
static const uint8_t beta_tab[64] = {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,
6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27
};
static const uint8_t tc_tab[64] = {
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, 1, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9
};
/** mark block as unavailable, i.e. out of picture
or not yet decoded */
static const cavs_vector un_mv = { 0, 0, 1, NOT_AVAIL };
static const int8_t left_modifier_l[8] = { 0, -1, 6, -1, -1, 7, 6, 7 };
static const int8_t top_modifier_l[8] = { -1, 1, 5, -1, -1, 5, 7, 7 };
static const int8_t left_modifier_c[7] = { 5, -1, 2, -1, 6, 5, 6 };
static const int8_t top_modifier_c[7] = { 4, 1, -1, -1, 4, 6, 6 };
/***************************************************************************** /*****************************************************************************
* *
@ -298,6 +327,15 @@ static void intra_pred_lp_top(uint8_t *d,uint8_t *top,uint8_t *left,int stride)
#undef LOWPASS #undef LOWPASS
static inline void modify_pred(const int8_t *mod_table, int *mode)
{
*mode = mod_table[*mode];
if(*mode < 0) {
av_log(NULL, AV_LOG_ERROR, "Illegal intra prediction mode\n");
*mode = 0;
}
}
void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv) { void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv) {
/* save pred modes before they get modified */ /* save pred modes before they get modified */
h->pred_mode_Y[3] = h->pred_mode_Y[5]; h->pred_mode_Y[3] = h->pred_mode_Y[5];
@ -307,14 +345,14 @@ void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv) {
/* modify pred modes according to availability of neighbour samples */ /* modify pred modes according to availability of neighbour samples */
if(!(h->flags & A_AVAIL)) { if(!(h->flags & A_AVAIL)) {
modify_pred(ff_left_modifier_l, &h->pred_mode_Y[4] ); modify_pred(left_modifier_l, &h->pred_mode_Y[4]);
modify_pred(ff_left_modifier_l, &h->pred_mode_Y[7] ); modify_pred(left_modifier_l, &h->pred_mode_Y[7]);
modify_pred(ff_left_modifier_c, pred_mode_uv ); modify_pred(left_modifier_c, pred_mode_uv);
} }
if(!(h->flags & B_AVAIL)) { if(!(h->flags & B_AVAIL)) {
modify_pred(ff_top_modifier_l, &h->pred_mode_Y[4] ); modify_pred(top_modifier_l, &h->pred_mode_Y[4]);
modify_pred(ff_top_modifier_l, &h->pred_mode_Y[5] ); modify_pred(top_modifier_l, &h->pred_mode_Y[5]);
modify_pred(ff_top_modifier_c, pred_mode_uv ); modify_pred(top_modifier_c, pred_mode_uv);
} }
} }
@ -496,7 +534,7 @@ void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
((mvA->ref == NOT_AVAIL) || (mvB->ref == NOT_AVAIL) || ((mvA->ref == NOT_AVAIL) || (mvB->ref == NOT_AVAIL) ||
((mvA->x | mvA->y | mvA->ref) == 0) || ((mvA->x | mvA->y | mvA->ref) == 0) ||
((mvB->x | mvB->y | mvB->ref) == 0) )) { ((mvB->x | mvB->y | mvB->ref) == 0) )) {
mvP2 = &ff_cavs_un_mv; mvP2 = &un_mv;
/* if there is only one suitable candidate, take it */ /* if there is only one suitable candidate, take it */
} else if((mvA->ref >= 0) && (mvB->ref < 0) && (mvC->ref < 0)) { } else if((mvA->ref >= 0) && (mvB->ref < 0) && (mvC->ref < 0)) {
mvP2= mvA; mvP2= mvA;
@ -545,10 +583,10 @@ void ff_cavs_init_mb(AVSContext *h) {
h->pred_mode_Y[2] = h->top_pred_Y[h->mbx*2+1]; h->pred_mode_Y[2] = h->top_pred_Y[h->mbx*2+1];
/* clear top predictors if MB B is not available */ /* clear top predictors if MB B is not available */
if(!(h->flags & B_AVAIL)) { if(!(h->flags & B_AVAIL)) {
h->mv[MV_FWD_B2] = ff_cavs_un_mv; h->mv[MV_FWD_B2] = un_mv;
h->mv[MV_FWD_B3] = ff_cavs_un_mv; h->mv[MV_FWD_B3] = un_mv;
h->mv[MV_BWD_B2] = ff_cavs_un_mv; h->mv[MV_BWD_B2] = un_mv;
h->mv[MV_BWD_B3] = ff_cavs_un_mv; h->mv[MV_BWD_B3] = un_mv;
h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL; h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL;
h->flags &= ~(C_AVAIL|D_AVAIL); h->flags &= ~(C_AVAIL|D_AVAIL);
} else if(h->mbx) { } else if(h->mbx) {
@ -558,13 +596,13 @@ void ff_cavs_init_mb(AVSContext *h) {
h->flags &= ~C_AVAIL; h->flags &= ~C_AVAIL;
/* clear top-right predictors if MB C is not available */ /* clear top-right predictors if MB C is not available */
if(!(h->flags & C_AVAIL)) { if(!(h->flags & C_AVAIL)) {
h->mv[MV_FWD_C2] = ff_cavs_un_mv; h->mv[MV_FWD_C2] = un_mv;
h->mv[MV_BWD_C2] = ff_cavs_un_mv; h->mv[MV_BWD_C2] = un_mv;
} }
/* clear top-left predictors if MB D is not available */ /* clear top-left predictors if MB D is not available */
if(!(h->flags & D_AVAIL)) { if(!(h->flags & D_AVAIL)) {
h->mv[MV_FWD_D3] = ff_cavs_un_mv; h->mv[MV_FWD_D3] = un_mv;
h->mv[MV_BWD_D3] = ff_cavs_un_mv; h->mv[MV_BWD_D3] = un_mv;
} }
} }
@ -597,7 +635,7 @@ int ff_cavs_next_mb(AVSContext *h) {
h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL; h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
/* clear left mv predictors */ /* clear left mv predictors */
for(i=0;i<=20;i+=4) for(i=0;i<=20;i+=4)
h->mv[i] = ff_cavs_un_mv; h->mv[i] = un_mv;
h->mbx = 0; h->mbx = 0;
h->mby++; h->mby++;
/* re-calculate sample pointers */ /* re-calculate sample pointers */
@ -622,7 +660,7 @@ void ff_cavs_init_pic(AVSContext *h) {
/* clear some predictors */ /* clear some predictors */
for(i=0;i<=20;i+=4) for(i=0;i<=20;i+=4)
h->mv[i] = ff_cavs_un_mv; h->mv[i] = un_mv;
h->mv[MV_BWD_X0] = ff_cavs_dir_mv; h->mv[MV_BWD_X0] = ff_cavs_dir_mv;
set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
h->mv[MV_FWD_X0] = ff_cavs_dir_mv; h->mv[MV_FWD_X0] = ff_cavs_dir_mv;
@ -693,8 +731,8 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) {
h->intra_pred_c[ INTRA_C_LP_LEFT] = intra_pred_lp_left; h->intra_pred_c[ INTRA_C_LP_LEFT] = intra_pred_lp_left;
h->intra_pred_c[ INTRA_C_LP_TOP] = intra_pred_lp_top; h->intra_pred_c[ INTRA_C_LP_TOP] = intra_pred_lp_top;
h->intra_pred_c[ INTRA_C_DC_128] = intra_pred_dc_128; h->intra_pred_c[ INTRA_C_DC_128] = intra_pred_dc_128;
h->mv[ 7] = ff_cavs_un_mv; h->mv[ 7] = un_mv;
h->mv[19] = ff_cavs_un_mv; h->mv[19] = un_mv;
return 0; return 0;
} }

View File

@ -225,41 +225,10 @@ typedef struct {
DCTELEM *block; DCTELEM *block;
} AVSContext; } AVSContext;
extern const uint8_t ff_cavs_dequant_shift[64];
extern const uint16_t ff_cavs_dequant_mul[64];
extern const struct dec_2dvlc ff_cavs_intra_dec[7];
extern const struct dec_2dvlc ff_cavs_inter_dec[7];
extern const struct dec_2dvlc ff_cavs_chroma_dec[5];
extern const uint8_t ff_cavs_chroma_qp[64];
extern const uint8_t ff_cavs_scan3x3[4];
extern const uint8_t ff_cavs_partition_flags[30]; extern const uint8_t ff_cavs_partition_flags[30];
extern const int8_t ff_left_modifier_l[8];
extern const int8_t ff_top_modifier_l[8];
extern const int8_t ff_left_modifier_c[7];
extern const int8_t ff_top_modifier_c[7];
extern const cavs_vector ff_cavs_intra_mv; extern const cavs_vector ff_cavs_intra_mv;
extern const cavs_vector ff_cavs_un_mv;
extern const cavs_vector ff_cavs_dir_mv; extern const cavs_vector ff_cavs_dir_mv;
static inline void modify_pred(const int8_t *mod_table, int *mode)
{
*mode = mod_table[*mode];
if(*mode < 0) {
av_log(NULL, AV_LOG_ERROR, "Illegal intra prediction mode\n");
*mode = 0;
}
}
static inline void set_intra_mode_default(AVSContext *h) {
if(h->stream_revision > 0) {
h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = NOT_AVAIL;
} else {
h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP;
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = INTRA_L_LP;
}
}
static inline void set_mvs(cavs_vector *mv, enum cavs_block size) { static inline void set_mvs(cavs_vector *mv, enum cavs_block size) {
switch(size) { switch(size) {
case BLK_16X16: case BLK_16X16:
@ -274,35 +243,6 @@ static inline void set_mvs(cavs_vector *mv, enum cavs_block size) {
} }
} }
static inline void set_mv_intra(AVSContext *h) {
h->mv[MV_FWD_X0] = ff_cavs_intra_mv;
set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
h->mv[MV_BWD_X0] = ff_cavs_intra_mv;
set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
if(h->pic_type != AV_PICTURE_TYPE_B)
h->col_type_base[h->mbidx] = I_8X8;
}
static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
DCTELEM *dst, int mul, int shift, int coeff_num) {
int round = 1 << (shift - 1);
int pos = -1;
const uint8_t *scantab = h->scantable.permutated;
/* inverse scan and dequantization */
while(--coeff_num >= 0){
pos += run_buf[coeff_num];
if(pos > 63) {
av_log(h->s.avctx, AV_LOG_ERROR,
"position out of block bounds at pic %d MB(%d,%d)\n",
h->picture.poc, h->mbx, h->mby);
return -1;
}
dst[scantab[pos]] = (level_buf[coeff_num]*mul + round) >> shift;
}
return 0;
}
void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type); void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type);
void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left, void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left,
int block); int block);

62
libavcodec/cavsdata.c Normal file
View File

@ -0,0 +1,62 @@
/*
* Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
* Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
*
* 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 "cavs.h"
const uint8_t ff_cavs_partition_flags[30] = {
0, //I_8X8
0, //P_SKIP
0, //P_16X16
SPLITH, //P_16X8
SPLITV, //P_8X16
SPLITH|SPLITV, //P_8X8
SPLITH|SPLITV, //B_SKIP
SPLITH|SPLITV, //B_DIRECT
0, //B_FWD_16X16
0, //B_BWD_16X16
0, //B_SYM_16X16
FWD0|FWD1 |SPLITH,
FWD0|FWD1 |SPLITV,
BWD0|BWD1 |SPLITH,
BWD0|BWD1 |SPLITV,
FWD0|BWD1 |SPLITH,
FWD0|BWD1 |SPLITV,
BWD0|FWD1 |SPLITH,
BWD0|FWD1 |SPLITV,
FWD0|FWD1 |SYM1|SPLITH,
FWD0|FWD1 |SYM1 |SPLITV,
BWD0|FWD1 |SYM1|SPLITH,
BWD0|FWD1 |SYM1 |SPLITV,
FWD0|FWD1|SYM0 |SPLITH,
FWD0|FWD1|SYM0 |SPLITV,
FWD0|BWD1|SYM0 |SPLITH,
FWD0|BWD1|SYM0 |SPLITV,
FWD0|FWD1|SYM0|SYM1|SPLITH,
FWD0|FWD1|SYM0|SYM1 |SPLITV,
SPLITH|SPLITV, //B_8X8 = 29
};
/** mark block as "no prediction from this direction"
e.g. forward motion vector in BWD partition */
const cavs_vector ff_cavs_dir_mv = {0,0,1,REF_DIR};
/** mark block as using intra prediction */
const cavs_vector ff_cavs_intra_mv = {0,0,1,REF_INTRA};

View File

@ -57,41 +57,6 @@ const uint8_t ff_cavs_partition_flags[30] = {
SPLITH|SPLITV, //B_8X8 = 29 SPLITH|SPLITV, //B_8X8 = 29
}; };
const uint8_t ff_cavs_scan3x3[4] = {4,5,7,8};
const uint8_t ff_cavs_chroma_qp[64] = {
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,
32,33,34,35,36,37,38,39,40,41,42,42,43,43,44,44,
45,45,46,46,47,47,48,48,48,49,49,49,50,50,50,51
};
const uint8_t ff_cavs_dequant_shift[64] = {
14,14,14,14,14,14,14,14,
13,13,13,13,13,13,13,13,
13,12,12,12,12,12,12,12,
11,11,11,11,11,11,11,11,
11,10,10,10,10,10,10,10,
10, 9, 9, 9, 9, 9, 9, 9,
9, 8, 8, 8, 8, 8, 8, 8,
7, 7, 7, 7, 7, 7, 7, 7
};
const uint16_t ff_cavs_dequant_mul[64] = {
32768,36061,38968,42495,46341,50535,55437,60424,
32932,35734,38968,42495,46177,50535,55109,59933,
65535,35734,38968,42577,46341,50617,55027,60097,
32809,35734,38968,42454,46382,50576,55109,60056,
65535,35734,38968,42495,46320,50515,55109,60076,
65535,35744,38968,42495,46341,50535,55099,60087,
65535,35734,38973,42500,46341,50535,55109,60097,
32771,35734,38965,42497,46341,50535,55109,60099
};
/** mark block as unavailable, i.e. out of picture
or not yet decoded */
const cavs_vector ff_cavs_un_mv = {0,0,1,NOT_AVAIL};
/** mark block as "no prediction from this direction" /** mark block as "no prediction from this direction"
e.g. forward motion vector in BWD partition */ e.g. forward motion vector in BWD partition */
const cavs_vector ff_cavs_dir_mv = {0,0,1,REF_DIR}; const cavs_vector ff_cavs_dir_mv = {0,0,1,REF_DIR};
@ -99,407 +64,4 @@ const cavs_vector ff_cavs_dir_mv = {0,0,1,REF_DIR};
/** mark block as using intra prediction */ /** mark block as using intra prediction */
const cavs_vector ff_cavs_intra_mv = {0,0,1,REF_INTRA}; const cavs_vector ff_cavs_intra_mv = {0,0,1,REF_INTRA};
#define EOB 0,0,0
const struct dec_2dvlc ff_cavs_intra_dec[7] = {
{
{ //level / run / table_inc
{ 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
{ 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
{ 1, 7, 1},{ -1, 7, 1},{ 1, 8, 1},{ -1, 8, 1},{ 1, 9, 1},{ -1, 9, 1},
{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},{ 2, 1, 2},{ -2, 1, 2},
{ 1,12, 1},{ -1,12, 1},{ 1,13, 1},{ -1,13, 1},{ 1,14, 1},{ -1,14, 1},
{ 1,15, 1},{ -1,15, 1},{ 2, 2, 2},{ -2, 2, 2},{ 1,16, 1},{ -1,16, 1},
{ 1,17, 1},{ -1,17, 1},{ 3, 1, 3},{ -3, 1, 3},{ 1,18, 1},{ -1,18, 1},
{ 1,19, 1},{ -1,19, 1},{ 2, 3, 2},{ -2, 3, 2},{ 1,20, 1},{ -1,20, 1},
{ 1,21, 1},{ -1,21, 1},{ 2, 4, 2},{ -2, 4, 2},{ 1,22, 1},{ -1,22, 1},
{ 2, 5, 2},{ -2, 5, 2},{ 1,23, 1},{ -1,23, 1},{ EOB }
},
//level_add
{ 0, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2,-1,-1,-1},
2, //golomb_order
0, //inc_limit
23, //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 1},{ -2, 1, 1},
{ 1, 3, 0},{ -1, 3, 0},{ EOB },{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},
{ -1, 5, 0},{ 1, 6, 0},{ -1, 6, 0},{ 3, 1, 2},{ -3, 1, 2},{ 2, 2, 1},
{ -2, 2, 1},{ 1, 7, 0},{ -1, 7, 0},{ 1, 8, 0},{ -1, 8, 0},{ 1, 9, 0},
{ -1, 9, 0},{ 2, 3, 1},{ -2, 3, 1},{ 4, 1, 2},{ -4, 1, 2},{ 1,10, 0},
{ -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 2, 4, 1},{ -2, 4, 1},{ 3, 2, 2},
{ -3, 2, 2},{ 1,12, 0},{ -1,12, 0},{ 2, 5, 1},{ -2, 5, 1},{ 5, 1, 3},
{ -5, 1, 3},{ 1,13, 0},{ -1,13, 0},{ 2, 6, 1},{ -2, 6, 1},{ 1,14, 0},
{ -1,14, 0},{ 2, 7, 1},{ -2, 7, 1},{ 2, 8, 1},{ -2, 8, 1},{ 3, 3, 2},
{ -3, 3, 2},{ 6, 1, 3},{ -6, 1, 3},{ 1,15, 0},{ -1,15, 0}
},
//level_add
{ 0, 7, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
1, //inc_limit
15, //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},{ -1, 2, 0},
{ 3, 1, 1},{ -3, 1, 1},{ EOB },{ 1, 3, 0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, 0},{ 7, 2, 0},{ -7, 2, 0},{ 17, 1, 2},{-17, 1, 2}
},
//level_add
{ 0,18, 8, 4, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
7, //inc_limit
5, //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 9, 1, 0},
{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 11, 1, 1},
{-11, 1, 1},{ 12, 1, 1},{-12, 1, 1},{ 13, 1, 1},{-13, 1, 1},{ 2, 2, 0},
{ -2, 2, 0},{ 14, 1, 1},{-14, 1, 1},{ 15, 1, 1},{-15, 1, 1},{ 3, 2, 0},
{ -3, 2, 0},{ 16, 1, 1},{-16, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 17, 1, 1},
{-17, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 18, 1, 1},{-18, 1, 1},{ 5, 2, 0},
{ -5, 2, 0},{ 19, 1, 1},{-19, 1, 1},{ 20, 1, 1},{-20, 1, 1},{ 6, 2, 0},
{ -6, 2, 0},{ 21, 1, 1},{-21, 1, 1},{ 2, 3, 0},{ -2, 3, 0}
},
//level_add
{ 0,22, 7, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
10, //inc_limit
3, //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 9, 1, 0},
{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},{-11, 1, 0},{ 12, 1, 0},
{-12, 1, 0},{ 13, 1, 0},{-13, 1, 0},{ 14, 1, 0},{-14, 1, 0},{ 15, 1, 0},
{-15, 1, 0},{ 16, 1, 0},{-16, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 17, 1, 0},
{-17, 1, 0},{ 18, 1, 0},{-18, 1, 0},{ 19, 1, 0},{-19, 1, 0},{ 20, 1, 0},
{-20, 1, 0},{ 21, 1, 0},{-21, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 22, 1, 0},
{-22, 1, 0},{ 23, 1, 0},{-23, 1, 0},{ 24, 1, 0},{-24, 1, 0},{ 25, 1, 0},
{-25, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 26, 1, 0},{-26, 1, 0}
},
//level_add
{ 0,27, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
INT_MAX, //inc_limit
2, //max_run
}
};
const struct dec_2dvlc ff_cavs_inter_dec[7] = {
{
{ //level / run
{ 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
{ 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
{ 1, 7, 1},{ -1, 7, 1},{ 1, 8, 1},{ -1, 8, 1},{ 1, 9, 1},{ -1, 9, 1},
{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},{ 1,12, 1},{ -1,12, 1},
{ 1,13, 1},{ -1,13, 1},{ 2, 1, 2},{ -2, 1, 2},{ 1,14, 1},{ -1,14, 1},
{ 1,15, 1},{ -1,15, 1},{ 1,16, 1},{ -1,16, 1},{ 1,17, 1},{ -1,17, 1},
{ 1,18, 1},{ -1,18, 1},{ 1,19, 1},{ -1,19, 1},{ 3, 1, 3},{ -3, 1, 3},
{ 1,20, 1},{ -1,20, 1},{ 1,21, 1},{ -1,21, 1},{ 2, 2, 2},{ -2, 2, 2},
{ 1,22, 1},{ -1,22, 1},{ 1,23, 1},{ -1,23, 1},{ 1,24, 1},{ -1,24, 1},
{ 1,25, 1},{ -1,25, 1},{ 1,26, 1},{ -1,26, 1},{ EOB }
},
//level_add
{ 0, 4, 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},
3, //golomb_order
0, //inc_limit
26 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 1, 2, 0},{ -1, 2, 0},{ 1, 3, 0},
{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},{ -1, 5, 0},{ 1, 6, 0},
{ -1, 6, 0},{ 2, 1, 1},{ -2, 1, 1},{ 1, 7, 0},{ -1, 7, 0},{ 1, 8, 0},
{ -1, 8, 0},{ 1, 9, 0},{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 2, 2, 1},
{ -2, 2, 1},{ 1,11, 0},{ -1,11, 0},{ 1,12, 0},{ -1,12, 0},{ 3, 1, 2},
{ -3, 1, 2},{ 1,13, 0},{ -1,13, 0},{ 1,14, 0},{ -1,14, 0},{ 2, 3, 1},
{ -2, 3, 1},{ 1,15, 0},{ -1,15, 0},{ 2, 4, 1},{ -2, 4, 1},{ 1,16, 0},
{ -1,16, 0},{ 2, 5, 1},{ -2, 5, 1},{ 1,17, 0},{ -1,17, 0},{ 4, 1, 3},
{ -4, 1, 3},{ 2, 6, 1},{ -2, 6, 1},{ 1,18, 0},{ -1,18, 0},{ 1,19, 0},
{ -1,19, 0},{ 2, 7, 1},{ -2, 7, 1},{ 3, 2, 2},{ -3, 2, 2}
},
//level_add
{ 0, 5, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
1, //inc_limit
19 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 0},
{ -2, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 3, 1, 1},
{ -3, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 1, 6, 0},
{ -1, 6, 0},{ 1, 7, 0},{ -1, 7, 0},{ 2, 3, 0},{ -2, 3, 0},{ 4, 1, 2},
{ -4, 1, 2},{ 1, 8, 0},{ -1, 8, 0},{ 3, 2, 1},{ -3, 2, 1},{ 2, 4, 0},
{ -2, 4, 0},{ 1, 9, 0},{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 5, 1, 2},
{ -5, 1, 2},{ 2, 5, 0},{ -2, 5, 0},{ 1,11, 0},{ -1,11, 0},{ 2, 6, 0},
{ -2, 6, 0},{ 1,12, 0},{ -1,12, 0},{ 3, 3, 1},{ -3, 3, 1},{ 6, 1, 2},
{ -6, 1, 2},{ 4, 2, 2},{ -4, 2, 2},{ 1,13, 0},{ -1,13, 0},{ 2, 7, 0},
{ -2, 7, 0},{ 3, 4, 1},{ -3, 4, 1},{ 1,14, 0},{ -1,14, 0}
},
//level_add
{ 0, 7, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
2, //inc_limit
14 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},
{ -1, 2, 0},{ 3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 -3, 3, 0},{ 16, 1, 1},
{-16, 1, 1},{ 2, 4, 0},{ -2, 4, 0},{ 7, 2, 0},{ -7, 2, 0}
},
//level_add
{ 0,17, 8, 4, 3, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
9, //inc_limit
5 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 8, 1, 0},
{ -8, 1, 0},{ 9, 1, 0},{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},
{-11, 1, 0},{ 12, 1, 0},{-12, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 13, 1, 0},
{-13, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 14, 1, 0},{-14, 1, 0},{ 15, 1, 0},
{-15, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 16, 1, 0},{-16, 1, 0},{ 17, 1, 0},
{-17, 1, 0},{ 18, 1, 0},{-18, 1, 0},{ 4, 2, 0},{ -4, 2, 0},{ 19, 1, 0},
{-19, 1, 0},{ 20, 1, 0},{-20, 1, 0},{ 2, 3, 0},{ -2, 3, 0},{ 1, 4, 0},
{ -1, 4, 0},{ 5, 2, 0},{ -5, 2, 0},{ 21, 1, 0},{-21, 1, 0}
},
//level_add
{ 0,22, 6, 3, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
INT_MAX, //inc_limit
4 //max_run
}
};
const struct dec_2dvlc ff_cavs_chroma_dec[5] = {
{
{ //level / run
{ 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
{ 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
{ 1, 7, 1},{ -1, 7, 1},{ 2, 1, 2},{ -2, 1, 2},{ 1, 8, 1},{ -1, 8, 1},
{ 1, 9, 1},{ -1, 9, 1},{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},
{ 1,12, 1},{ -1,12, 1},{ 1,13, 1},{ -1,13, 1},{ 1,14, 1},{ -1,14, 1},
{ 1,15, 1},{ -1,15, 1},{ 3, 1, 3},{ -3, 1, 3},{ 1,16, 1},{ -1,16, 1},
{ 1,17, 1},{ -1,17, 1},{ 1,18, 1},{ -1,18, 1},{ 1,19, 1},{ -1,19, 1},
{ 1,20, 1},{ -1,20, 1},{ 1,21, 1},{ -1,21, 1},{ 1,22, 1},{ -1,22, 1},
{ 2, 2, 2},{ -2, 2, 2},{ 1,23, 1},{ -1,23, 1},{ 1,24, 1},{ -1,24, 1},
{ 1,25, 1},{ -1,25, 1},{ 4, 1, 3},{ -4, 1, 3},{ EOB }
},
//level_add
{ 0, 5, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2,-1},
2, //golomb_order
0, //inc_limit
25 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 1},
{ -2, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},
{ -1, 5, 0},{ 1, 6, 0},{ -1, 6, 0},{ 3, 1, 2},{ -3, 1, 2},{ 1, 7, 0},
{ -1, 7, 0},{ 1, 8, 0},{ -1, 8, 0},{ 2, 2, 1},{ -2, 2, 1},{ 1, 9, 0},
{ -1, 9, 0},{ 1,10, 0},{ -1,10,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10, 0},{ 1,11, 0},{ -1,11, 0},{ 9, 1, 2},
{ -9, 1, 2},{ 5, 2, 2},{ -5, 2, 2},{ 3, 4, 1},{ -3, 4, 1},
},
//level_add
{ 0,10, 6, 4, 4, 3, 3, 2, 2, 2, 2, 2,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
1, //golomb_order
2, //inc_limit
11 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 5, 1, 1},
{ -5, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 6, 1, 1},{ -6, 1, 1},{ 1, 3, 0},
{ -1, 3, 0},{ 7, 1, 1},{ -7, 1, 1},{ 3, 2, 0},{ -3, 2, 0},{ 8, 1, 1},
{ -8, 1, 1},{ 1, 4, 0},{ -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 9, 1, 1},
{ -9, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 10, 1, 1},
{-10, 1, 1},{ 3, 3, 0},{ -3, 3, 0},{ 5, 2, 1},{ -5, 2, 1},{ 2, 4, 0},
{ -2, 4, 0},{ 11, 1, 1},{-11, 1, 1},{ 1, 6, 0},{ -1, 6, 0},{ 12, 1, 1},
{-12, 1, 1},{ 1, 7, 0},{ -1, 7, 0},{ 6, 2, 1},{ -6, 2, 1},{ 13, 1, 1},
{-13, 1, 1},{ 2, 5, 0},{ -2, 5, 0},{ 1, 8, 0},{ -1, 8, 0},
},
//level_add
{ 0,14, 7, 4, 3, 3, 2, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
1, //golomb_order
4, //inc_limit
8 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 1, 2, 0},
{ -1, 2, 0},{ 9, 1, 0},{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},
{-11, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 12, 1, 0},{-12, 1, 0},{ 13, 1, 0},
{-13, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 14, 1, 0},{-14, 1, 0},{ 1, 3, 0},
{ -1, 3, 0},{ 15, 1, 0},{-15, 1, 0},{ 4, 2, 0},{ -4, 2, 0},{ 16, 1, 0},
{-16, 1, 0},{ 17, 1, 0},{-17, 1, 0},{ 5, 2, 0},{ -5, 2, 0},{ 1, 4, 0},
{ -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 18, 1, 0},{-18, 1, 0},{ 6, 2, 0},
{ -6, 2, 0},{ 19, 1, 0},{-19, 1, 0},{ 1, 5, 0},{ -1, 5, 0},
},
//level_add
{ 0,20, 7, 3, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
0, //golomb_order
INT_MAX, //inc_limit
5, //max_run
}
};
#undef EOB
static const uint8_t alpha_tab[64] = {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,
4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 20,
22, 24, 26, 28, 30, 33, 33, 35, 35, 36, 37, 37, 39, 39, 42, 44,
46, 48, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
};
static const uint8_t beta_tab[64] = {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,
6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27
};
static const uint8_t tc_tab[64] = {
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, 1, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9
};
const int8_t ff_left_modifier_l[8] = { 0, -1, 6, -1, -1, 7, 6, 7 };
const int8_t ff_top_modifier_l[8] = { -1, 1, 5, -1, -1, 5, 7, 7 };
const int8_t ff_left_modifier_c[7] = { 5, -1, 2, -1, 6, 5, 6 };
const int8_t ff_top_modifier_c[7] = { 4, 1, -1, -1, 4, 6, 6 };
#endif /* AVCODEC_CAVSDATA_H */ #endif /* AVCODEC_CAVSDATA_H */

View File

@ -47,6 +47,414 @@ static const uint8_t cbp_tab[64][2] = {
{34,50},{50,56},{52,25},{54,22},{41,54},{56,57},{38,41},{57,38} {34,50},{50,56},{52,25},{54,22},{41,54},{56,57},{38,41},{57,38}
}; };
static const uint8_t scan3x3[4] = { 4, 5, 7, 8 };
static const uint8_t cavs_chroma_qp[64] = {
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,
32,33,34,35,36,37,38,39,40,41,42,42,43,43,44,44,
45,45,46,46,47,47,48,48,48,49,49,49,50,50,50,51
};
static const uint8_t dequant_shift[64] = {
14,14,14,14,14,14,14,14,
13,13,13,13,13,13,13,13,
13,12,12,12,12,12,12,12,
11,11,11,11,11,11,11,11,
11,10,10,10,10,10,10,10,
10, 9, 9, 9, 9, 9, 9, 9,
9, 8, 8, 8, 8, 8, 8, 8,
7, 7, 7, 7, 7, 7, 7, 7
};
static const uint16_t dequant_mul[64] = {
32768,36061,38968,42495,46341,50535,55437,60424,
32932,35734,38968,42495,46177,50535,55109,59933,
65535,35734,38968,42577,46341,50617,55027,60097,
32809,35734,38968,42454,46382,50576,55109,60056,
65535,35734,38968,42495,46320,50515,55109,60076,
65535,35744,38968,42495,46341,50535,55099,60087,
65535,35734,38973,42500,46341,50535,55109,60097,
32771,35734,38965,42497,46341,50535,55109,60099
};
#define EOB 0,0,0
static const struct dec_2dvlc intra_dec[7] = {
{
{ //level / run / table_inc
{ 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
{ 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
{ 1, 7, 1},{ -1, 7, 1},{ 1, 8, 1},{ -1, 8, 1},{ 1, 9, 1},{ -1, 9, 1},
{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},{ 2, 1, 2},{ -2, 1, 2},
{ 1,12, 1},{ -1,12, 1},{ 1,13, 1},{ -1,13, 1},{ 1,14, 1},{ -1,14, 1},
{ 1,15, 1},{ -1,15, 1},{ 2, 2, 2},{ -2, 2, 2},{ 1,16, 1},{ -1,16, 1},
{ 1,17, 1},{ -1,17, 1},{ 3, 1, 3},{ -3, 1, 3},{ 1,18, 1},{ -1,18, 1},
{ 1,19, 1},{ -1,19, 1},{ 2, 3, 2},{ -2, 3, 2},{ 1,20, 1},{ -1,20, 1},
{ 1,21, 1},{ -1,21, 1},{ 2, 4, 2},{ -2, 4, 2},{ 1,22, 1},{ -1,22, 1},
{ 2, 5, 2},{ -2, 5, 2},{ 1,23, 1},{ -1,23, 1},{ EOB }
},
//level_add
{ 0, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2,-1,-1,-1},
2, //golomb_order
0, //inc_limit
23, //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 1},{ -2, 1, 1},
{ 1, 3, 0},{ -1, 3, 0},{ EOB },{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},
{ -1, 5, 0},{ 1, 6, 0},{ -1, 6, 0},{ 3, 1, 2},{ -3, 1, 2},{ 2, 2, 1},
{ -2, 2, 1},{ 1, 7, 0},{ -1, 7, 0},{ 1, 8, 0},{ -1, 8, 0},{ 1, 9, 0},
{ -1, 9, 0},{ 2, 3, 1},{ -2, 3, 1},{ 4, 1, 2},{ -4, 1, 2},{ 1,10, 0},
{ -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 2, 4, 1},{ -2, 4, 1},{ 3, 2, 2},
{ -3, 2, 2},{ 1,12, 0},{ -1,12, 0},{ 2, 5, 1},{ -2, 5, 1},{ 5, 1, 3},
{ -5, 1, 3},{ 1,13, 0},{ -1,13, 0},{ 2, 6, 1},{ -2, 6, 1},{ 1,14, 0},
{ -1,14, 0},{ 2, 7, 1},{ -2, 7, 1},{ 2, 8, 1},{ -2, 8, 1},{ 3, 3, 2},
{ -3, 3, 2},{ 6, 1, 3},{ -6, 1, 3},{ 1,15, 0},{ -1,15, 0}
},
//level_add
{ 0, 7, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
1, //inc_limit
15, //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},{ -1, 2, 0},
{ 3, 1, 1},{ -3, 1, 1},{ EOB },{ 1, 3, 0},{ -1, 3, 0},{ 2, 2, 0},
{ -2, 2, 0},{ 4, 1, 1},{ -4, 1, 1},{ 1, 4, 0},{ -1, 4, 0},{ 5, 1, 2},
{ -5, 1,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},{ 3, 3, 0},
{ -3, 3, 0},{ 1, 6, 0},{ -1, 6, 0},{ 11, 1, 3},{-11, 1, 3},{ 6, 2, 1},
{ -6, 2, 1},{ 1, 7, 0},{ -1, 7, 0},{ 2, 5, 0},{ -2, 5, 0},{ 3, 4, 0},
{ -3, 4, 0},{ 12, 1, 3},{-12, 1, 3},{ 4, 3, 0},{ -4, 3, 0}
},
//level_add
{ 0,13, 7, 5, 4, 3, 2, 2,-1,-1,-1 -1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
4, //inc_limit
7, //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},{ -3, 1, 0},
{ EOB },{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 1},
{ -8, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 9, 1, 1},{ -9, 1, 1},{ 10, 1, 1},
{-10, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 3, 2, 0},{ -3, 2, 0},{ 11, 1, 2},
{-11, 1, 2},{ 4, 2, 0},{ -4, 2, 0},{ 12, 1, 2},{-12, 1, 2},{ 13, 1, 2},
{-13, 1, 2},{ 5, 2, 0},{ -5, 2, 0},{ 1, 4, 0},{ -1, 4, 0},{ 2, 3, 0},
{ -2, 3, 0},{ 14, 1, 2},{-14, 1, 2},{ 6, 2, 0},{ -6, 2, 0},{ 15, 1, 2},
{-15, 1, 2},{ 16, 1, 2},{-16, 1, 2},{ 3, 3, 0},{ -3, 3, 0},{ 1, 5, 0},
{ -1, 5, 0},{ 7, 2, 0},{ -7, 2, 0},{ 17, 1, 2},{-17, 1, 2}
},
//level_add
{ 0,18, 8, 4, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
7, //inc_limit
5, //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 9, 1, 0},
{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 11, 1, 1},
{-11, 1, 1},{ 12, 1, 1},{-12, 1, 1},{ 13, 1, 1},{-13, 1, 1},{ 2, 2, 0},
{ -2, 2, 0},{ 14, 1, 1},{-14, 1, 1},{ 15, 1, 1},{-15, 1, 1},{ 3, 2, 0},
{ -3, 2, 0},{ 16, 1, 1},{-16, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 17, 1, 1},
{-17, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 18, 1, 1},{-18, 1, 1},{ 5, 2, 0},
{ -5, 2, 0},{ 19, 1, 1},{-19, 1, 1},{ 20, 1, 1},{-20, 1, 1},{ 6, 2, 0},
{ -6, 2, 0},{ 21, 1, 1},{-21, 1, 1},{ 2, 3, 0},{ -2, 3, 0}
},
//level_add
{ 0,22, 7, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
10, //inc_limit
3, //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 9, 1, 0},
{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},{-11, 1, 0},{ 12, 1, 0},
{-12, 1, 0},{ 13, 1, 0},{-13, 1, 0},{ 14, 1, 0},{-14, 1, 0},{ 15, 1, 0},
{-15, 1, 0},{ 16, 1, 0},{-16, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 17, 1, 0},
{-17, 1, 0},{ 18, 1, 0},{-18, 1, 0},{ 19, 1, 0},{-19, 1, 0},{ 20, 1, 0},
{-20, 1, 0},{ 21, 1, 0},{-21, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 22, 1, 0},
{-22, 1, 0},{ 23, 1, 0},{-23, 1, 0},{ 24, 1, 0},{-24, 1, 0},{ 25, 1, 0},
{-25, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 26, 1, 0},{-26, 1, 0}
},
//level_add
{ 0,27, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
INT_MAX, //inc_limit
2, //max_run
}
};
static const struct dec_2dvlc inter_dec[7] = {
{
{ //level / run
{ 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
{ 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
{ 1, 7, 1},{ -1, 7, 1},{ 1, 8, 1},{ -1, 8, 1},{ 1, 9, 1},{ -1, 9, 1},
{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},{ 1,12, 1},{ -1,12, 1},
{ 1,13, 1},{ -1,13, 1},{ 2, 1, 2},{ -2, 1, 2},{ 1,14, 1},{ -1,14, 1},
{ 1,15, 1},{ -1,15, 1},{ 1,16, 1},{ -1,16, 1},{ 1,17, 1},{ -1,17, 1},
{ 1,18, 1},{ -1,18, 1},{ 1,19, 1},{ -1,19, 1},{ 3, 1, 3},{ -3, 1, 3},
{ 1,20, 1},{ -1,20, 1},{ 1,21, 1},{ -1,21, 1},{ 2, 2, 2},{ -2, 2, 2},
{ 1,22, 1},{ -1,22, 1},{ 1,23, 1},{ -1,23, 1},{ 1,24, 1},{ -1,24, 1},
{ 1,25, 1},{ -1,25, 1},{ 1,26, 1},{ -1,26, 1},{ EOB }
},
//level_add
{ 0, 4, 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},
3, //golomb_order
0, //inc_limit
26 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 1, 2, 0},{ -1, 2, 0},{ 1, 3, 0},
{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},{ -1, 5, 0},{ 1, 6, 0},
{ -1, 6, 0},{ 2, 1, 1},{ -2, 1, 1},{ 1, 7, 0},{ -1, 7, 0},{ 1, 8, 0},
{ -1, 8, 0},{ 1, 9, 0},{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 2, 2, 1},
{ -2, 2, 1},{ 1,11, 0},{ -1,11, 0},{ 1,12, 0},{ -1,12, 0},{ 3, 1, 2},
{ -3, 1, 2},{ 1,13, 0},{ -1,13, 0},{ 1,14, 0},{ -1,14, 0},{ 2, 3, 1},
{ -2, 3, 1},{ 1,15, 0},{ -1,15, 0},{ 2, 4, 1},{ -2, 4, 1},{ 1,16, 0},
{ -1,16, 0},{ 2, 5, 1},{ -2, 5, 1},{ 1,17, 0},{ -1,17, 0},{ 4, 1, 3},
{ -4, 1, 3},{ 2, 6, 1},{ -2, 6, 1},{ 1,18, 0},{ -1,18, 0},{ 1,19, 0},
{ -1,19, 0},{ 2, 7, 1},{ -2, 7, 1},{ 3, 2, 2},{ -3, 2, 2}
},
//level_add
{ 0, 5, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
1, //inc_limit
19 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 0},
{ -2, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 3, 1, 1},
{ -3, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 1, 6, 0},
{ -1, 6, 0},{ 1, 7, 0},{ -1, 7, 0},{ 2, 3, 0},{ -2, 3, 0},{ 4, 1, 2},
{ -4, 1, 2},{ 1, 8, 0},{ -1, 8, 0},{ 3, 2, 1},{ -3, 2, 1},{ 2, 4, 0},
{ -2, 4, 0},{ 1, 9, 0},{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 5, 1, 2},
{ -5, 1, 2},{ 2, 5, 0},{ -2, 5, 0},{ 1,11, 0},{ -1,11, 0},{ 2, 6, 0},
{ -2, 6, 0},{ 1,12, 0},{ -1,12, 0},{ 3, 3, 1},{ -3, 3, 1},{ 6, 1, 2},
{ -6, 1, 2},{ 4, 2, 2},{ -4, 2, 2},{ 1,13, 0},{ -1,13, 0},{ 2, 7, 0},
{ -2, 7, 0},{ 3, 4, 1},{ -3, 4, 1},{ 1,14, 0},{ -1,14, 0}
},
//level_add
{ 0, 7, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
2, //inc_limit
14 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},
{ -1, 2, 0},{ 3, 1, 0},{ -3, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 2, 2, 0},
{ -2, 2, 0},{ 4, 1, 1},{ -4, 1, 1},{ 1, 4, 0},{ -1, 4, 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0},{ 1, 6, 0},{ -1, 6, 0},{ 10, 1, 2},
{-10, 1, 2},{ 3, 3, 0},{ -3, 3, 0},{ 11, 1, 2},{-11, 1, 2},{ 1, 7, 0},
{ -1, 7, 0},{ 6, 2, 0},{ -6, 2, 0},{ 3, 4, 0},{ -3, 4, 0},{ 2, 5, 0},
{ -2, 5, 0},{ 12, 1, 2},{-12, 1, 2},{ 4, 3, 0},{ -4, 3, 0}
},
//level_add
{ 0,13, 7, 5, 4, 3, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
6, //inc_limit
7 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 1, 2, 0},
{ -1, 2, 0},{ 6, 1, 0},{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},
{ -8, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 9, 1, 0},{ -9, 1, 0},{ 1, 3, 0},
{ -1, 3, 0},{ 10, 1, 1},{-10, 1, 1},{ 3, 2, 0},{ -3, 2, 0},{ 11, 1, 1},
{-11, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 12, 1, 1},{-12, 1, 1},{ 1, 4, 0},
{ -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 13, 1, 1},{-13, 1, 1},{ 5, 2, 0},
{ -5, 2, 0},{ 14, 1, 1},{-14, 1, 1},{ 6, 2, 0},{ -6, 2, 0},{ 1, 5, 0},
{ -1, 5, 0},{ 15, 1, 1},{-15, 1, 1},{ 3, 3, 0},{ -3, 3, 0},{ 16, 1, 1},
{-16, 1, 1},{ 2, 4, 0},{ -2, 4, 0},{ 7, 2, 0},{ -7, 2, 0}
},
//level_add
{ 0,17, 8, 4, 3, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
9, //inc_limit
5 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 8, 1, 0},
{ -8, 1, 0},{ 9, 1, 0},{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},
{-11, 1, 0},{ 12, 1, 0},{-12, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 13, 1, 0},
{-13, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 14, 1, 0},{-14, 1, 0},{ 15, 1, 0},
{-15, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 16, 1, 0},{-16, 1, 0},{ 17, 1, 0},
{-17, 1, 0},{ 18, 1, 0},{-18, 1, 0},{ 4, 2, 0},{ -4, 2, 0},{ 19, 1, 0},
{-19, 1, 0},{ 20, 1, 0},{-20, 1, 0},{ 2, 3, 0},{ -2, 3, 0},{ 1, 4, 0},
{ -1, 4, 0},{ 5, 2, 0},{ -5, 2, 0},{ 21, 1, 0},{-21, 1, 0}
},
//level_add
{ 0,22, 6, 3, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
2, //golomb_order
INT_MAX, //inc_limit
4 //max_run
}
};
static const struct dec_2dvlc chroma_dec[5] = {
{
{ //level / run
{ 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
{ 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
{ 1, 7, 1},{ -1, 7, 1},{ 2, 1, 2},{ -2, 1, 2},{ 1, 8, 1},{ -1, 8, 1},
{ 1, 9, 1},{ -1, 9, 1},{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},
{ 1,12, 1},{ -1,12, 1},{ 1,13, 1},{ -1,13, 1},{ 1,14, 1},{ -1,14, 1},
{ 1,15, 1},{ -1,15, 1},{ 3, 1, 3},{ -3, 1, 3},{ 1,16, 1},{ -1,16, 1},
{ 1,17, 1},{ -1,17, 1},{ 1,18, 1},{ -1,18, 1},{ 1,19, 1},{ -1,19, 1},
{ 1,20, 1},{ -1,20, 1},{ 1,21, 1},{ -1,21, 1},{ 1,22, 1},{ -1,22, 1},
{ 2, 2, 2},{ -2, 2, 2},{ 1,23, 1},{ -1,23, 1},{ 1,24, 1},{ -1,24, 1},
{ 1,25, 1},{ -1,25, 1},{ 4, 1, 3},{ -4, 1, 3},{ EOB }
},
//level_add
{ 0, 5, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2,-1},
2, //golomb_order
0, //inc_limit
25 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 1},
{ -2, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},
{ -1, 5, 0},{ 1, 6, 0},{ -1, 6, 0},{ 3, 1, 2},{ -3, 1, 2},{ 1, 7, 0},
{ -1, 7, 0},{ 1, 8, 0},{ -1, 8, 0},{ 2, 2, 1},{ -2, 2, 1},{ 1, 9, 0},
{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 4, 1, 2},
{ -4, 1, 2},{ 1,12, 0},{ -1,12, 0},{ 1,13, 0},{ -1,13, 0},{ 1,14, 0},
{ -1,14, 0},{ 2, 3, 1},{ -2, 3, 1},{ 1,15, 0},{ -1,15, 0},{ 2, 4, 1},
{ -2, 4, 1},{ 5, 1, 3},{ -5, 1, 3},{ 3, 2, 2},{ -3, 2, 2},{ 1,16, 0},
{ -1,16, 0},{ 1,17, 0},{ -1,17, 0},{ 1,18, 0},{ -1,18, 0},{ 2, 5, 1},
{ -2, 5, 1},{ 1,19, 0},{ -1,19, 0},{ 1,20, 0},{ -1,20, 0}
},
//level_add
{ 0, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2,-1,-1,-1,-1,-1,-1},
0, //golomb_order
1, //inc_limit
20 //max_run
},{
{ //level / run
{ 1, 1, 0},{ -1, 1, 0},{ EOB },{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},
{ -1, 2, 0},{ 3, 1, 1},{ -3, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 4, 1, 1},
{ -4, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 1, 4, 0},{ -1, 4, 0},{ 5, 1, 2},
{ -5, 1, 2},{ 1, 5, 0},{ -1, 5, 0},{ 3, 2, 1},{ -3, 2, 1},{ 2, 3, 0},
{ -2, 3, 0},{ 1, 6, 0},{ -1, 6, 0},{ 6, 1, 2},{ -6, 1, 2},{ 1, 7, 0},
{ -1, 7, 0},{ 2, 4, 0},{ -2, 4, 0},{ 7, 1, 2},{ -7, 1, 2},{ 1, 8, 0},
{ -1, 8, 0},{ 4, 2, 1},{ -4, 2, 1},{ 1, 9, 0},{ -1, 9, 0},{ 3, 3, 1},
{ -3, 3, 1},{ 2, 5, 0},{ -2, 5, 0},{ 2, 6, 0},{ -2, 6, 0},{ 8, 1, 2},
{ -8, 1, 2},{ 1,10, 0},{ -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 9, 1, 2},
{ -9, 1, 2},{ 5, 2, 2},{ -5, 2, 2},{ 3, 4, 1},{ -3, 4, 1},
},
//level_add
{ 0,10, 6, 4, 4, 3, 3, 2, 2, 2, 2, 2,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
1, //golomb_order
2, //inc_limit
11 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 5, 1, 1},
{ -5, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 6, 1, 1},{ -6, 1, 1},{ 1, 3, 0},
{ -1, 3, 0},{ 7, 1, 1},{ -7, 1, 1},{ 3, 2, 0},{ -3, 2, 0},{ 8, 1, 1},
{ -8, 1, 1},{ 1, 4, 0},{ -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 9, 1, 1},
{ -9, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 10, 1, 1},
{-10, 1, 1},{ 3, 3, 0},{ -3, 3, 0},{ 5, 2, 1},{ -5, 2, 1},{ 2, 4, 0},
{ -2, 4, 0},{ 11, 1, 1},{-11, 1, 1},{ 1, 6, 0},{ -1, 6, 0},{ 12, 1, 1},
{-12, 1, 1},{ 1, 7, 0},{ -1, 7, 0},{ 6, 2, 1},{ -6, 2, 1},{ 13, 1, 1},
{-13, 1, 1},{ 2, 5, 0},{ -2, 5, 0},{ 1, 8, 0},{ -1, 8, 0},
},
//level_add
{ 0,14, 7, 4, 3, 3, 2, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
1, //golomb_order
4, //inc_limit
8 //max_run
},{
{ //level / run
{ EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
{ -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 1, 2, 0},
{ -1, 2, 0},{ 9, 1, 0},{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},
{-11, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 12, 1, 0},{-12, 1, 0},{ 13, 1, 0},
{-13, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 14, 1, 0},{-14, 1, 0},{ 1, 3, 0},
{ -1, 3, 0},{ 15, 1, 0},{-15, 1, 0},{ 4, 2, 0},{ -4, 2, 0},{ 16, 1, 0},
{-16, 1, 0},{ 17, 1, 0},{-17, 1, 0},{ 5, 2, 0},{ -5, 2, 0},{ 1, 4, 0},
{ -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 18, 1, 0},{-18, 1, 0},{ 6, 2, 0},
{ -6, 2, 0},{ 19, 1, 0},{-19, 1, 0},{ 1, 5, 0},{ -1, 5, 0},
},
//level_add
{ 0,20, 7, 3, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
0, //golomb_order
INT_MAX, //inc_limit
5, //max_run
}
};
#undef EOB
/***************************************************************************** /*****************************************************************************
* *
* motion vector prediction * motion vector prediction
@ -104,6 +512,26 @@ static inline int get_ue_code(GetBitContext *gb, int order) {
return get_ue_golomb(gb); return get_ue_golomb(gb);
} }
static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
DCTELEM *dst, int mul, int shift, int coeff_num) {
int round = 1 << (shift - 1);
int pos = -1;
const uint8_t *scantab = h->scantable.permutated;
/* inverse scan and dequantization */
while(--coeff_num >= 0){
pos += run_buf[coeff_num];
if(pos > 63) {
av_log(h->s.avctx, AV_LOG_ERROR,
"position out of block bounds at pic %d MB(%d,%d)\n",
h->picture.poc, h->mbx, h->mby);
return -1;
}
dst[scantab[pos]] = (level_buf[coeff_num]*mul + round) >> shift;
}
return 0;
}
/** /**
* decode coefficients from one 8x8 block, dequantize, inverse transform * decode coefficients from one 8x8 block, dequantize, inverse transform
* and add them to sample block * and add them to sample block
@ -144,8 +572,8 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
level_buf[i] = level; level_buf[i] = level;
run_buf[i] = run; run_buf[i] = run;
} }
if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp], if (dequant(h, level_buf, run_buf, block, dequant_mul[qp],
ff_cavs_dequant_shift[qp], i)) dequant_shift[qp], i))
return -1; return -1;
h->cdsp.cavs_idct8_add(dst,block,stride); h->cdsp.cavs_idct8_add(dst,block,stride);
h->s.dsp.clear_block(block); h->s.dsp.clear_block(block);
@ -155,11 +583,11 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
static inline void decode_residual_chroma(AVSContext *h) { static inline void decode_residual_chroma(AVSContext *h) {
if(h->cbp & (1<<4)) if(h->cbp & (1<<4))
decode_residual_block(h,&h->s.gb,ff_cavs_chroma_dec,0, decode_residual_block(h, &h->s.gb, chroma_dec, 0,
ff_cavs_chroma_qp[h->qp],h->cu,h->c_stride); cavs_chroma_qp[h->qp], h->cu, h->c_stride);
if(h->cbp & (1<<5)) if(h->cbp & (1<<5))
decode_residual_block(h,&h->s.gb,ff_cavs_chroma_dec,0, decode_residual_block(h, &h->s.gb, chroma_dec, 0,
ff_cavs_chroma_qp[h->qp],h->cv,h->c_stride); cavs_chroma_qp[h->qp], h->cv, h->c_stride);
} }
static inline int decode_residual_inter(AVSContext *h) { static inline int decode_residual_inter(AVSContext *h) {
@ -178,7 +606,7 @@ static inline int decode_residual_inter(AVSContext *h) {
h->qp = (h->qp + get_se_golomb(&h->s.gb)) & 63; h->qp = (h->qp + get_se_golomb(&h->s.gb)) & 63;
for(block=0;block<4;block++) for(block=0;block<4;block++)
if(h->cbp & (1<<block)) if(h->cbp & (1<<block))
decode_residual_block(h,&h->s.gb,ff_cavs_inter_dec,0,h->qp, decode_residual_block(h, &h->s.gb, inter_dec, 0, h->qp,
h->cy + h->luma_scan[block], h->l_stride); h->cy + h->luma_scan[block], h->l_stride);
decode_residual_chroma(h); decode_residual_chroma(h);
@ -191,6 +619,15 @@ static inline int decode_residual_inter(AVSContext *h) {
* *
****************************************************************************/ ****************************************************************************/
static inline void set_mv_intra(AVSContext *h) {
h->mv[MV_FWD_X0] = ff_cavs_intra_mv;
set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
h->mv[MV_BWD_X0] = ff_cavs_intra_mv;
set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
if(h->pic_type != AV_PICTURE_TYPE_B)
h->col_type_base[h->mbidx] = I_8X8;
}
static int decode_mb_i(AVSContext *h, int cbp_code) { static int decode_mb_i(AVSContext *h, int cbp_code) {
GetBitContext *gb = &h->s.gb; GetBitContext *gb = &h->s.gb;
unsigned pred_mode_uv; unsigned pred_mode_uv;
@ -204,7 +641,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code) {
/* get intra prediction modes from stream */ /* get intra prediction modes from stream */
for(block=0;block<4;block++) { for(block=0;block<4;block++) {
int nA,nB,predpred; int nA,nB,predpred;
int pos = ff_cavs_scan3x3[block]; int pos = scan3x3[block];
nA = h->pred_mode_Y[pos-1]; nA = h->pred_mode_Y[pos-1];
nB = h->pred_mode_Y[pos-3]; nB = h->pred_mode_Y[pos-3];
@ -239,10 +676,10 @@ static int decode_mb_i(AVSContext *h, int cbp_code) {
for(block=0;block<4;block++) { for(block=0;block<4;block++) {
d = h->cy + h->luma_scan[block]; d = h->cy + h->luma_scan[block];
ff_cavs_load_intra_pred_luma(h, top, &left, block); ff_cavs_load_intra_pred_luma(h, top, &left, block);
h->intra_pred_l[h->pred_mode_Y[ff_cavs_scan3x3[block]]] h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]
(d, top, left, h->l_stride); (d, top, left, h->l_stride);
if(h->cbp & (1<<block)) if(h->cbp & (1<<block))
decode_residual_block(h,gb,ff_cavs_intra_dec,1,h->qp,d,h->l_stride); decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
} }
/* chroma intra prediction */ /* chroma intra prediction */
@ -258,6 +695,16 @@ static int decode_mb_i(AVSContext *h, int cbp_code) {
return 0; return 0;
} }
static inline void set_intra_mode_default(AVSContext *h) {
if(h->stream_revision > 0) {
h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = NOT_AVAIL;
} else {
h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP;
h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = INTRA_L_LP;
}
}
static void decode_mb_p(AVSContext *h, enum cavs_mb mb_type) { static void decode_mb_p(AVSContext *h, enum cavs_mb mb_type) {
GetBitContext *gb = &h->s.gb; GetBitContext *gb = &h->s.gb;
int ref[4]; int ref[4];

View File

@ -148,38 +148,6 @@ static av_always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref,
inverse); inverse);
} }
static av_always_inline void inv_lift(IDWTELEM *dst, IDWTELEM *src, IDWTELEM *ref,
int dst_step, int src_step, int ref_step,
int width, int mul, int add, int shift,
int highpass, int inverse)
{
const int mirror_left = !highpass;
const int mirror_right = (width & 1) ^ highpass;
const int w = (width >> 1) - 1 + (highpass & width);
int i;
#define LIFT(src, ref, inv) ((src) + ((inv) ? -(ref) : +(ref)))
if (mirror_left) {
dst[0] = LIFT(src[0], ((mul * 2 * ref[0] + add) >> shift), inverse);
dst += dst_step;
src += src_step;
}
for (i = 0; i < w; i++)
dst[i * dst_step] = LIFT(src[i * src_step],
((mul * (ref[i * ref_step] +
ref[(i + 1) * ref_step]) +
add) >> shift),
inverse);
if (mirror_right) {
dst[w * dst_step] = LIFT(src[w * src_step],
((mul * 2 * ref[w * ref_step] + add) >> shift),
inverse);
}
}
#ifndef liftS
static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref,
int dst_step, int src_step, int ref_step, int dst_step, int src_step, int ref_step,
int width, int mul, int add, int shift, int width, int mul, int add, int shift,
@ -213,40 +181,6 @@ static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref,
inverse); inverse);
} }
static av_always_inline void inv_liftS(IDWTELEM *dst, IDWTELEM *src,
IDWTELEM *ref, int dst_step,
int src_step, int ref_step,
int width, int mul, int add, int shift,
int highpass, int inverse)
{
const int mirror_left = !highpass;
const int mirror_right = (width & 1) ^ highpass;
const int w = (width >> 1) - 1 + (highpass & width);
int i;
av_assert1(shift == 4);
#define LIFTS(src, ref, inv) \
((inv) ? (src) + (((ref) + 4 * (src)) >> shift) \
: -((-16 * (src) + (ref) + add / \
4 + 1 + (5 << 25)) / (5 * 4) - (1 << 23)))
if (mirror_left) {
dst[0] = LIFTS(src[0], mul * 2 * ref[0] + add, inverse);
dst += dst_step;
src += src_step;
}
for (i = 0; i < w; i++)
dst[i * dst_step] = LIFTS(src[i * src_step],
mul * (ref[i * ref_step] +
ref[(i + 1) * ref_step]) + add,
inverse);
if (mirror_right)
dst[w * dst_step] = LIFTS(src[w * src_step],
mul * 2 * ref[w * ref_step] + add, inverse);
}
#endif /* ! liftS */
static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width) static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width)
{ {
const int width2 = width >> 1; const int width2 = width >> 1;
@ -259,41 +193,8 @@ static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width)
} }
if (width & 1) if (width & 1)
temp[x] = b[2 * x]; temp[x] = b[2 * x];
#if 0
{
int A1, A2, A3, A4;
A2 = temp[1];
A4 = temp[0];
A1 = temp[0 + width2];
A1 -= (A2 + A4) >> 1;
A4 += (A1 + 1) >> 1;
b[0 + width2] = A1;
b[0] = A4;
for (x = 1; x + 1 < width2; x += 2) {
A3 = temp[x + width2];
A4 = temp[x + 1];
A3 -= (A2 + A4) >> 1;
A2 += (A1 + A3 + 2) >> 2;
b[x + width2] = A3;
b[x] = A2;
A1 = temp[x + 1 + width2];
A2 = temp[x + 2];
A1 -= (A2 + A4) >> 1;
A4 += (A1 + A3 + 2) >> 2;
b[x + 1 + width2] = A1;
b[x + 1] = A4;
}
A3 = temp[width - 1];
A3 -= A2;
A2 += (A1 + A3 + 2) >> 2;
b[width - 1] = A3;
b[width2 - 1] = A2;
}
#else
lift(b + w2, temp + w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0); lift(b + w2, temp + w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0);
lift(b, temp, b + w2, 1, 1, 1, width, 1, 2, 2, 0, 0); lift(b, temp, b + w2, 1, 1, 1, width, 1, 2, 2, 0, 0);
#endif /* 0 */
} }
static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2,
@ -374,12 +275,8 @@ static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2,
int i; int i;
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
#ifdef liftS
b1[i] -= (W_BM * (b0[i] + b2[i]) + W_BO) >> W_BS;
#else
b1[i] = (16 * 4 * b1[i] - 4 * (b0[i] + b2[i]) + W_BO * 5 + (5 << 27)) / b1[i] = (16 * 4 * b1[i] - 4 * (b0[i] + b2[i]) + W_BO * 5 + (5 << 27)) /
(5 * 16) - (1 << 23); (5 * 16) - (1 << 23);
#endif
} }
static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2,
@ -583,15 +480,8 @@ static void av_unused spatial_compose53i(IDWTELEM *buffer, IDWTELEM *temp,
void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width)
{ {
const int w2 = (width + 1) >> 1; const int w2 = (width + 1) >> 1;
#if 0 //maybe more understadable but slower
inv_lift(temp, b, b + w2, 2, 1, 1, width, W_DM, W_DO, W_DS, 0, 1);
inv_lift(temp + 1, b + w2, temp, 2, 1, 2, width, W_CM, W_CO, W_CS, 1, 1);
inv_liftS(b, temp, temp + 1, 2, 2, 2, width, W_BM, W_BO, W_BS, 0, 1);
inv_lift(b + 1, temp + 1, b, 2, 2, 2, width, W_AM, W_AO, W_AS, 1, 0);
#else
int x; int x;
temp[0] = b[0] - ((3 * b[w2] + 2) >> 2); temp[0] = b[0] - ((3 * b[w2] + 2) >> 2);
for (x = 1; x < (width >> 1); x++) { for (x = 1; x < (width >> 1); x++) {
temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3); temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3);
@ -613,7 +503,6 @@ void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width)
b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1);
} else } else
b[x - 1] = temp[x - 1] + 3 * b[x - 2]; b[x - 1] = temp[x - 1] + 3 * b[x - 2];
#endif
} }
static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
@ -640,11 +529,7 @@ static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
int i; int i;
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
#ifdef liftS
b1[i] += (W_BM * (b0[i] + b2[i]) + W_BO) >> W_BS;
#else
b1[i] += (W_BM * (b0[i] + b2[i]) + 4 * b1[i] + W_BO) >> W_BS; b1[i] += (W_BM * (b0[i] + b2[i]) + 4 * b1[i] + W_BO) >> W_BS;
#endif
} }
static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
@ -665,11 +550,7 @@ void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS; b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS;
b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS; b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS;
#ifdef liftS
b2[i] += (W_BM * (b1[i] + b3[i]) + W_BO) >> W_BS;
#else
b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS; b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS;
#endif
b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS; b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS;
} }
} }

View File

@ -154,7 +154,6 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y);
#define DWT_53 1 #define DWT_53 1
#define liftS lift #define liftS lift
#if 1
#define W_AM 3 #define W_AM 3
#define W_AO 0 #define W_AO 0
#define W_AS 1 #define W_AS 1
@ -171,57 +170,6 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y);
#define W_DM 3 #define W_DM 3
#define W_DO 4 #define W_DO 4
#define W_DS 3 #define W_DS 3
#elif 0
#define W_AM 55
#define W_AO 16
#define W_AS 5
#define W_BM 3
#define W_BO 32
#define W_BS 6
#define W_CM 127
#define W_CO 64
#define W_CS 7
#define W_DM 7
#define W_DO 8
#define W_DS 4
#elif 0
#define W_AM 97
#define W_AO 32
#define W_AS 6
#define W_BM 63
#define W_BO 512
#define W_BS 10
#define W_CM 13
#define W_CO 8
#define W_CS 4
#define W_DM 15
#define W_DO 16
#define W_DS 5
#else
#define W_AM 203
#define W_AO 64
#define W_AS 7
#define W_BM 217
#define W_BO 2048
#define W_BS 12
#define W_CM 113
#define W_CO 64
#define W_CS 7
#define W_DM 227
#define W_DO 128
#define W_DS 9
#endif
#define slice_buffer_get_line(slice_buf, line_num) \ #define slice_buffer_get_line(slice_buf, line_num) \
((slice_buf)->line[line_num] ? (slice_buf)->line[line_num] \ ((slice_buf)->line[line_num] ? (slice_buf)->line[line_num] \

View File

@ -35,21 +35,30 @@
#include "video.h" #include "video.h"
typedef struct { typedef struct {
int16_t coefs[4][512*16]; int16_t *coefs[4];
uint16_t *line; uint16_t *line;
uint16_t *frame_prev[3]; uint16_t *frame_prev[3];
double strength[4];
int hsub, vsub; int hsub, vsub;
int depth; int depth;
void (*denoise_row[17])(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal);
} HQDN3DContext; } HQDN3DContext;
void ff_hqdn3d_row_8_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal);
void ff_hqdn3d_row_9_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal);
void ff_hqdn3d_row_10_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal);
void ff_hqdn3d_row_16_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal);
#define LUT_BITS (depth==16 ? 8 : 4)
#define RIGHTSHIFT(a,b) (((a)+(((1<<(b))-1)>>1))>>(b)) #define RIGHTSHIFT(a,b) (((a)+(((1<<(b))-1)>>1))>>(b))
#define LOAD(x) ((depth==8 ? src[x] : AV_RN16A(src+(x)*2)) << (16-depth)) #define LOAD(x) ((depth==8 ? src[x] : AV_RN16A(src+(x)*2)) << (16-depth))
#define STORE(x,val) (depth==8 ? dst[x] = RIGHTSHIFT(val, 16-depth)\ #define STORE(x,val) (depth==8 ? dst[x] = RIGHTSHIFT(val, 16-depth)\
: AV_WN16A(dst+(x)*2, RIGHTSHIFT(val, 16-depth))) : AV_WN16A(dst+(x)*2, RIGHTSHIFT(val, 16-depth)))
static inline uint32_t lowpass(int prev, int cur, int16_t *coef) av_always_inline
static inline uint32_t lowpass(int prev, int cur, int16_t *coef, int depth)
{ {
int d = (prev-cur)>>4; int d = (prev - cur) >> (8 - LUT_BITS);
return cur + coef[d]; return cur + coef[d];
} }
@ -62,11 +71,11 @@ static void denoise_temporal(uint8_t *src, uint8_t *dst,
long x, y; long x, y;
uint32_t tmp; uint32_t tmp;
temporal += 0x1000; temporal += 256 << LUT_BITS;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
frame_ant[x] = tmp = lowpass(frame_ant[x], LOAD(x), temporal); frame_ant[x] = tmp = lowpass(frame_ant[x], LOAD(x), temporal, depth);
STORE(x, tmp); STORE(x, tmp);
} }
src += sstride; src += sstride;
@ -76,7 +85,8 @@ static void denoise_temporal(uint8_t *src, uint8_t *dst,
} }
av_always_inline av_always_inline
static void denoise_spatial(uint8_t *src, uint8_t *dst, static void denoise_spatial(HQDN3DContext *hqdn3d,
uint8_t *src, uint8_t *dst,
uint16_t *line_ant, uint16_t *frame_ant, uint16_t *line_ant, uint16_t *frame_ant,
int w, int h, int sstride, int dstride, int w, int h, int sstride, int dstride,
int16_t *spatial, int16_t *temporal, int depth) int16_t *spatial, int16_t *temporal, int depth)
@ -85,15 +95,15 @@ static void denoise_spatial(uint8_t *src, uint8_t *dst,
uint32_t pixel_ant; uint32_t pixel_ant;
uint32_t tmp; uint32_t tmp;
spatial += 0x1000; spatial += 256 << LUT_BITS;
temporal += 0x1000; temporal += 256 << LUT_BITS;
/* First line has no top neighbor. Only left one for each tmp and /* First line has no top neighbor. Only left one for each tmp and
* last frame */ * last frame */
pixel_ant = LOAD(0); pixel_ant = LOAD(0);
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
line_ant[x] = tmp = pixel_ant = lowpass(pixel_ant, LOAD(x), spatial); line_ant[x] = tmp = pixel_ant = lowpass(pixel_ant, LOAD(x), spatial, depth);
frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal); frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
STORE(x, tmp); STORE(x, tmp);
} }
@ -101,25 +111,32 @@ static void denoise_spatial(uint8_t *src, uint8_t *dst,
src += sstride; src += sstride;
dst += dstride; dst += dstride;
frame_ant += w; frame_ant += w;
if (hqdn3d->denoise_row[depth]) {
hqdn3d->denoise_row[depth](src, dst, line_ant, frame_ant, w, spatial, temporal);
continue;
}
pixel_ant = LOAD(0); pixel_ant = LOAD(0);
for (x = 0; x < w-1; x++) { for (x = 0; x < w-1; x++) {
line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial); line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial, depth);
pixel_ant = lowpass(pixel_ant, LOAD(x+1), spatial); pixel_ant = lowpass(pixel_ant, LOAD(x+1), spatial, depth);
frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal); frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
STORE(x, tmp); STORE(x, tmp);
} }
line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial); line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial, depth);
frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal); frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
STORE(x, tmp); STORE(x, tmp);
} }
} }
av_always_inline av_always_inline
static void denoise_depth(uint8_t *src, uint8_t *dst, static void denoise_depth(HQDN3DContext *hqdn3d,
uint8_t *src, uint8_t *dst,
uint16_t *line_ant, uint16_t **frame_ant_ptr, uint16_t *line_ant, uint16_t **frame_ant_ptr,
int w, int h, int sstride, int dstride, int w, int h, int sstride, int dstride,
int16_t *spatial, int16_t *temporal, int depth) int16_t *spatial, int16_t *temporal, int depth)
{ {
// FIXME: For 16bit depth, frame_ant could be a pointer to the previous
// filtered frame rather than a separate buffer.
long x, y; long x, y;
uint16_t *frame_ant = *frame_ant_ptr; uint16_t *frame_ant = *frame_ant_ptr;
if (!frame_ant) { if (!frame_ant) {
@ -133,7 +150,7 @@ static void denoise_depth(uint8_t *src, uint8_t *dst,
} }
if (spatial[0]) if (spatial[0])
denoise_spatial(src, dst, line_ant, frame_ant, denoise_spatial(hqdn3d, src, dst, line_ant, frame_ant,
w, h, sstride, dstride, spatial, temporal, depth); w, h, sstride, dstride, spatial, temporal, depth);
else else
denoise_temporal(src, dst, frame_ant, denoise_temporal(src, dst, frame_ant,
@ -145,24 +162,28 @@ static void denoise_depth(uint8_t *src, uint8_t *dst,
case 8: denoise_depth(__VA_ARGS__, 8); break;\ case 8: denoise_depth(__VA_ARGS__, 8); break;\
case 9: denoise_depth(__VA_ARGS__, 9); break;\ case 9: denoise_depth(__VA_ARGS__, 9); break;\
case 10: denoise_depth(__VA_ARGS__, 10); break;\ case 10: denoise_depth(__VA_ARGS__, 10); break;\
case 16: denoise_depth(__VA_ARGS__, 16); break;\
} }
static void precalc_coefs(int16_t *ct, double dist25) static int16_t *precalc_coefs(double dist25, int depth)
{ {
int i; int i;
double gamma, simil, C; double gamma, simil, C;
int16_t *ct = av_malloc((512<<LUT_BITS)*sizeof(int16_t));
if (!ct)
return NULL;
gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001); gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
for (i = -255*16; i <= 255*16; i++) { for (i = -255<<LUT_BITS; i <= 255<<LUT_BITS; i++) {
// lowpass() truncates (not rounds) the diff, so +15/32 for the midpoint of the bin. double f = ((i<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; // midpoint of the bin
double f = (i + 15.0/32.0) / 16.0;
simil = 1.0 - FFABS(f) / 255.0; simil = 1.0 - FFABS(f) / 255.0;
C = pow(simil, gamma) * 256.0 * f; C = pow(simil, gamma) * 256.0 * f;
ct[16*256+i] = lrint(C); ct[(256<<LUT_BITS)+i] = lrint(C);
} }
ct[0] = !!dist25; ct[0] = !!dist25;
return ct;
} }
#define PARAM1_DEFAULT 4.0 #define PARAM1_DEFAULT 4.0
@ -210,6 +231,11 @@ static int init(AVFilterContext *ctx, const char *args)
} }
} }
hqdn3d->strength[0] = lum_spac;
hqdn3d->strength[1] = lum_tmp;
hqdn3d->strength[2] = chrom_spac;
hqdn3d->strength[3] = chrom_tmp;
av_log(ctx, AV_LOG_VERBOSE, "ls:%lf cs:%lf lt:%lf ct:%lf\n", av_log(ctx, AV_LOG_VERBOSE, "ls:%lf cs:%lf lt:%lf ct:%lf\n",
lum_spac, chrom_spac, lum_tmp, chrom_tmp); lum_spac, chrom_spac, lum_tmp, chrom_tmp);
if (lum_spac < 0 || chrom_spac < 0 || isnan(chrom_tmp)) { if (lum_spac < 0 || chrom_spac < 0 || isnan(chrom_tmp)) {
@ -219,11 +245,6 @@ static int init(AVFilterContext *ctx, const char *args)
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
precalc_coefs(hqdn3d->coefs[0], lum_spac);
precalc_coefs(hqdn3d->coefs[1], lum_tmp);
precalc_coefs(hqdn3d->coefs[2], chrom_spac);
precalc_coefs(hqdn3d->coefs[3], chrom_tmp);
return 0; return 0;
} }
@ -231,6 +252,10 @@ static void uninit(AVFilterContext *ctx)
{ {
HQDN3DContext *hqdn3d = ctx->priv; HQDN3DContext *hqdn3d = ctx->priv;
av_freep(&hqdn3d->coefs[0]);
av_freep(&hqdn3d->coefs[1]);
av_freep(&hqdn3d->coefs[2]);
av_freep(&hqdn3d->coefs[3]);
av_freep(&hqdn3d->line); av_freep(&hqdn3d->line);
av_freep(&hqdn3d->frame_prev[0]); av_freep(&hqdn3d->frame_prev[0]);
av_freep(&hqdn3d->frame_prev[1]); av_freep(&hqdn3d->frame_prev[1]);
@ -256,6 +281,9 @@ static int query_formats(AVFilterContext *ctx)
AV_NE( PIX_FMT_YUV420P10BE, PIX_FMT_YUV420P10LE ), AV_NE( PIX_FMT_YUV420P10BE, PIX_FMT_YUV420P10LE ),
AV_NE( PIX_FMT_YUV422P10BE, PIX_FMT_YUV422P10LE ), AV_NE( PIX_FMT_YUV422P10BE, PIX_FMT_YUV422P10LE ),
AV_NE( PIX_FMT_YUV444P10BE, PIX_FMT_YUV444P10LE ), AV_NE( PIX_FMT_YUV444P10BE, PIX_FMT_YUV444P10LE ),
AV_NE( PIX_FMT_YUV420P16BE, PIX_FMT_YUV420P16LE ),
AV_NE( PIX_FMT_YUV422P16BE, PIX_FMT_YUV422P16LE ),
AV_NE( PIX_FMT_YUV444P16BE, PIX_FMT_YUV444P16LE ),
PIX_FMT_NONE PIX_FMT_NONE
}; };
@ -276,6 +304,19 @@ static int config_input(AVFilterLink *inlink)
if (!hqdn3d->line) if (!hqdn3d->line)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (int i=0; i<4; i++) {
hqdn3d->coefs[i] = precalc_coefs(hqdn3d->strength[i], hqdn3d->depth);
if (!hqdn3d->coefs[i])
return AVERROR(ENOMEM);
}
#if HAVE_YASM
hqdn3d->denoise_row[ 8] = ff_hqdn3d_row_8_x86;
hqdn3d->denoise_row[ 9] = ff_hqdn3d_row_9_x86;
hqdn3d->denoise_row[10] = ff_hqdn3d_row_10_x86;
hqdn3d->denoise_row[16] = ff_hqdn3d_row_16_x86;
#endif
return 0; return 0;
} }
@ -293,7 +334,7 @@ static int end_frame(AVFilterLink *inlink)
int ret, c; int ret, c;
for (c = 0; c < 3; c++) { for (c = 0; c < 3; c++) {
denoise(inpic->data[c], outpic->data[c], denoise(hqdn3d, inpic->data[c], outpic->data[c],
hqdn3d->line, &hqdn3d->frame_prev[c], hqdn3d->line, &hqdn3d->frame_prev[c],
inpic->video->w >> (!!c * hqdn3d->hsub), inpic->video->w >> (!!c * hqdn3d->hsub),
inpic->video->h >> (!!c * hqdn3d->vsub), inpic->video->h >> (!!c * hqdn3d->vsub),

View File

@ -1,2 +1,3 @@
MMX-OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif.o MMX-OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif.o
MMX-OBJS-$(CONFIG_GRADFUN_FILTER) += x86/gradfun.o MMX-OBJS-$(CONFIG_GRADFUN_FILTER) += x86/gradfun.o
YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/hqdn3d.o

106
libavfilter/x86/hqdn3d.asm Normal file
View File

@ -0,0 +1,106 @@
;******************************************************************************
;* Copyright (c) 2012 Loren Merritt
;*
;* 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 "x86inc.asm"
SECTION .text
%macro LOWPASS 3 ; prevsample, cursample, lut
sub %1q, %2q
%if lut_bits != 8
sar %1q, 8-lut_bits
%endif
movsx %1d, word [%3q+%1q*2]
add %1d, %2d
%endmacro
%macro LOAD 3 ; dstreg, x, bitdepth
%if %3 == 8
movzx %1, byte [srcq+%2]
%else
movzx %1, word [srcq+(%2)*2]
%endif
%if %3 != 16
shl %1, 16-%3
%endif
%endmacro
%macro HQDN3D_ROW 1 ; bitdepth
%if ARCH_X86_64
cglobal hqdn3d_row_%1_x86, 7,10,0, src, dst, lineant, frameant, width, spatial, temporal, pixelant, t0, t1
%else
cglobal hqdn3d_row_%1_x86, 7,7,0, src, dst, lineant, frameant, width, spatial, temporal
%endif
%assign bytedepth (%1+7)>>3
%assign lut_bits 4+4*(%1/16)
dec widthq
lea srcq, [srcq+widthq*bytedepth]
lea dstq, [dstq+widthq*bytedepth]
lea frameantq, [frameantq+widthq*2]
lea lineantq, [lineantq+widthq*2]
neg widthq
%define xq widthq
%if ARCH_X86_32
mov dstmp, dstq
mov srcmp, srcq
mov frameantmp, frameantq
mov lineantmp, lineantq
%define dstq r0
%define frameantq r0
%define lineantq r0
%define pixelantq r1
%define pixelantd r1d
DECLARE_REG_TMP 2,3
%endif
LOAD pixelantd, xq, %1
ALIGN 16
.loop:
movifnidn srcq, srcmp
LOAD t0d, xq+1, %1 ; skip on the last iteration to avoid overread
.loop2:
movifnidn lineantq, lineantmp
movzx t1d, word [lineantq+xq*2]
LOWPASS t1, pixelant, spatial
mov [lineantq+xq*2], t1w
LOWPASS pixelant, t0, spatial
movifnidn frameantq, frameantmp
movzx t0d, word [frameantq+xq*2]
LOWPASS t0, t1, temporal
mov [frameantq+xq*2], t0w
movifnidn dstq, dstmp
%if %1 != 16
add t0d, (1<<(15-%1))-1
shr t0d, 16-%1 ; could eliminate this by storing from t0h, but only with some contraints on register allocation
%endif
%if %1 == 8
mov [dstq+xq], t0b
%else
mov [dstq+xq*2], t0w
%endif
inc xq
jl .loop
je .loop2
REP_RET
%endmacro ; HQDN3D_ROW
HQDN3D_ROW 8
HQDN3D_ROW 9
HQDN3D_ROW 10
HQDN3D_ROW 16

View File

@ -159,6 +159,7 @@ CPUNOP amdnop
%define r%1w %2w %define r%1w %2w
%define r%1b %2b %define r%1b %2b
%define r%1h %2h %define r%1h %2h
%define %2q %2
%if %0 == 2 %if %0 == 2
%define r%1m %2d %define r%1m %2d
%define r%1mp %2 %define r%1mp %2

View File

@ -4,6 +4,9 @@ fate-utvideo_rgba_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgba_left.a
FATE_UTVIDEO += fate-utvideo_rgba_median FATE_UTVIDEO += fate-utvideo_rgba_median
fate-utvideo_rgba_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgba_median.avi fate-utvideo_rgba_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgba_median.avi
FATE_UTVIDEO += fate-utvideo_rgba_single_symbol
fate-utvideo_rgba_single_symbol: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgba_single_symbol.avi
FATE_UTVIDEO += fate-utvideo_rgb_left FATE_UTVIDEO += fate-utvideo_rgb_left
fate-utvideo_rgb_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgb_left.avi fate-utvideo_rgb_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgb_left.avi

View File

@ -0,0 +1,2 @@
#tb 0: 1/24
0, 0, 0, 1, 3145728, 0xac95c593