* Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
* Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
*
- * This library is free software; you can redistribute it and/or
+ * 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * 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 this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
int qp;
int qp_fixed;
int cbp;
+ ScanTable scantable;
/** intra prediction is done with un-deblocked samples
they are saved here before deblocking the MB */
uint8_t *top_border_y, *top_border_u, *top_border_v;
- uint8_t left_border_y[16], left_border_u[10], left_border_v[10];
+ uint8_t left_border_y[26], left_border_u[10], left_border_v[10];
+ uint8_t intern_border_y[26];
uint8_t topleft_border_y, topleft_border_u, topleft_border_v;
void (*intra_pred_l[8])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
int scale_den[2]; ///< for scaling neighbouring MVs
int got_keyframe;
+ DCTELEM *block;
} AVSContext;
/*****************************************************************************
*
****************************************************************************/
-static inline int get_bs_p(vector_t *mvP, vector_t *mvQ) {
+static inline int get_bs(vector_t *mvP, vector_t *mvQ, int b) {
if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA))
return 2;
- if(mvP->ref != mvQ->ref)
- return 1;
if( (abs(mvP->x - mvQ->x) >= 4) || (abs(mvP->y - mvQ->y) >= 4) )
return 1;
- return 0;
-}
-
-static inline int get_bs_b(vector_t *mvP, vector_t *mvQ) {
- if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA)) {
- return 2;
- } else {
- vector_t *mvPbw = mvP + MV_BWD_OFFS;
- vector_t *mvQbw = mvQ + MV_BWD_OFFS;
- if( (abs( mvP->x - mvQ->x) >= 4) ||
- (abs( mvP->y - mvQ->y) >= 4) ||
- (abs(mvPbw->x - mvQbw->x) >= 4) ||
- (abs(mvPbw->y - mvQbw->y) >= 4) )
+ if(b){
+ mvP += MV_BWD_OFFS;
+ mvQ += MV_BWD_OFFS;
+ if( (abs(mvP->x - mvQ->x) >= 4) || (abs(mvP->y - mvQ->y) >= 4) )
+ return 1;
+ }else{
+ if(mvP->ref != mvQ->ref)
return 1;
}
return 0;
memcpy(&h->top_border_u[h->mbx*10+1], h->cu + 7* h->c_stride,8);
memcpy(&h->top_border_v[h->mbx*10+1], h->cv + 7* h->c_stride,8);
for(i=0;i<8;i++) {
- h->left_border_y[i*2+0] = *(h->cy + 15 + (i*2+0)*h->l_stride);
- h->left_border_y[i*2+1] = *(h->cy + 15 + (i*2+1)*h->l_stride);
+ h->left_border_y[i*2+1] = *(h->cy + 15 + (i*2+0)*h->l_stride);
+ h->left_border_y[i*2+2] = *(h->cy + 15 + (i*2+1)*h->l_stride);
h->left_border_u[i+1] = *(h->cu + 7 + i*h->c_stride);
h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride);
}
if(!h->loop_filter_disable) {
- /* clear bs */
- *((uint64_t *)bs) = 0;
/* determine bs */
- switch(mb_type) {
- case I_8X8:
+ if(mb_type == I_8X8)
*((uint64_t *)bs) = 0x0202020202020202ULL;
- break;
- case P_8X8:
- case P_8X16:
- bs[2] = get_bs_p(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
- bs[3] = get_bs_p(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3]);
- case P_16X8:
- bs[6] = get_bs_p(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
- bs[7] = get_bs_p(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3]);
- case P_16X16:
- case P_SKIP:
- bs[0] = get_bs_p(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
- bs[1] = get_bs_p(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
- bs[4] = get_bs_p(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
- bs[5] = get_bs_p(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
- break;
- case B_SKIP:
- case B_DIRECT:
- case B_8X8:
- bs[2] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
- bs[3] = get_bs_b(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3]);
- bs[6] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
- bs[7] = get_bs_b(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3]);
- case B_FWD_16X16:
- case B_BWD_16X16:
- case B_SYM_16X16:
- bs[0] = get_bs_b(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
- bs[1] = get_bs_b(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
- bs[4] = get_bs_b(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
- bs[5] = get_bs_b(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
- break;
- default:
- if(mb_type & 1) { //16X8
- bs[6] = bs[7] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
- } else { //8X16
- bs[2] = bs[3] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
+ else{
+ *((uint64_t *)bs) = 0;
+ if(partition_flags[mb_type] & SPLITV){
+ bs[2] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1], mb_type > P_8X8);
+ bs[3] = get_bs(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3], mb_type > P_8X8);
+ }
+ if(partition_flags[mb_type] & SPLITH){
+ bs[6] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2], mb_type > P_8X8);
+ bs[7] = get_bs(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3], mb_type > P_8X8);
}
- bs[0] = get_bs_b(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
- bs[1] = get_bs_b(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
- bs[4] = get_bs_b(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
- bs[5] = get_bs_b(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
+ bs[0] = get_bs(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0], mb_type > P_8X8);
+ bs[1] = get_bs(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2], mb_type > P_8X8);
+ bs[4] = get_bs(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0], mb_type > P_8X8);
+ bs[5] = get_bs(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1], mb_type > P_8X8);
}
if( *((uint64_t *)bs) ) {
if(h->flags & A_AVAIL) {
****************************************************************************/
static inline void load_intra_pred_luma(AVSContext *h, uint8_t *top,
- uint8_t *left, int block) {
+ uint8_t **left, int block) {
int i;
switch(block) {
case 0:
- memcpy(&left[1],h->left_border_y,16);
- left[0] = left[1];
- left[17] = left[16];
+ *left = h->left_border_y;
+ h->left_border_y[0] = h->left_border_y[1];
+ memset(&h->left_border_y[17],h->left_border_y[16],9);
memcpy(&top[1],&h->top_border_y[h->mbx*16],16);
top[17] = top[16];
top[0] = top[1];
if((h->flags & A_AVAIL) && (h->flags & B_AVAIL))
- left[0] = top[0] = h->topleft_border_y;
+ h->left_border_y[0] = top[0] = h->topleft_border_y;
break;
case 1:
+ *left = h->intern_border_y;
for(i=0;i<8;i++)
- left[i+1] = *(h->cy + 7 + i*h->l_stride);
- memset(&left[9],left[8],9);
- left[0] = left[1];
+ h->intern_border_y[i+1] = *(h->cy + 7 + i*h->l_stride);
+ memset(&h->intern_border_y[9],h->intern_border_y[8],9);
+ h->intern_border_y[0] = h->intern_border_y[1];
memcpy(&top[1],&h->top_border_y[h->mbx*16+8],8);
if(h->flags & C_AVAIL)
memcpy(&top[9],&h->top_border_y[(h->mbx + 1)*16],8);
top[17] = top[16];
top[0] = top[1];
if(h->flags & B_AVAIL)
- left[0] = top[0] = h->top_border_y[h->mbx*16+7];
+ h->intern_border_y[0] = top[0] = h->top_border_y[h->mbx*16+7];
break;
case 2:
- memcpy(&left[1],&h->left_border_y[8],8);
- memset(&left[9],left[8],9);
+ *left = &h->left_border_y[8];
memcpy(&top[1],h->cy + 7*h->l_stride,16);
top[17] = top[16];
- left[0] = h->left_border_y[7];
top[0] = top[1];
if(h->flags & A_AVAIL)
- top[0] = left[0];
+ top[0] = h->left_border_y[8];
break;
case 3:
- for(i=0;i<9;i++)
- left[i] = *(h->cy + 7 + (i+7)*h->l_stride);
- memset(&left[9],left[8],9);
+ *left = &h->intern_border_y[8];
+ for(i=0;i<8;i++)
+ h->intern_border_y[i+9] = *(h->cy + 7 + (i+8)*h->l_stride);
+ memset(&h->intern_border_y[17],h->intern_border_y[16],9);
memcpy(&top[0],h->cy + 7 + 7*h->l_stride,9);
memset(&top[9],top[8],9);
break;
static void intra_pred_vert(uint8_t *d,uint8_t *top,uint8_t *left,int stride) {
int y;
- uint64_t a = *((uint64_t *)(&top[1]));
+ uint64_t a = unaligned64(&top[1]);
for(y=0;y<8;y++) {
*((uint64_t *)(d+y*stride)) = a;
}
}
}
-static void inter_pred(AVSContext *h) {
- /* always do 8x8 blocks TODO: are larger blocks worth it? */
- mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0,
+static void inter_pred(AVSContext *h, enum mb_t mb_type) {
+ if(partition_flags[mb_type] == 0){ // 16x16
+ mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
+ h->s.dsp.put_cavs_qpel_pixels_tab[0],
+ h->s.dsp.put_h264_chroma_pixels_tab[0],
+ h->s.dsp.avg_cavs_qpel_pixels_tab[0],
+ h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]);
+ }else{
+ mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0,
h->s.dsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
h->s.dsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X0]);
- mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 0,
+ mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 0,
h->s.dsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
h->s.dsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X1]);
- mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 4,
+ mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 4,
h->s.dsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
h->s.dsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X2]);
- mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 4,
+ mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 4,
h->s.dsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
h->s.dsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]);
+ }
/* set intra prediction modes to default values */
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;
vector_t *mvA = &h->mv[nP-1];
vector_t *mvB = &h->mv[nP-4];
vector_t *mvC = &h->mv[nC];
- int mvAref = mvA->ref;
- int mvBref = mvB->ref;
- int mvCref;
+ const vector_t *mvP2 = NULL;
mvP->ref = ref;
mvP->dist = h->dist[mvP->ref];
if(mvC->ref == NOT_AVAIL)
mvC = &h->mv[nP-5]; // set to top-left (mvD)
- mvCref = mvC->ref;
- if(mode == MV_PRED_PSKIP) {
- if((mvAref == NOT_AVAIL) || (mvBref == NOT_AVAIL) ||
+ if((mode == MV_PRED_PSKIP) &&
+ ((mvA->ref == NOT_AVAIL) || (mvB->ref == NOT_AVAIL) ||
((mvA->x | mvA->y | mvA->ref) == 0) ||
- ((mvB->x | mvB->y | mvB->ref) == 0) ) {
- mvP->x = mvP->y = 0;
- set_mvs(mvP,size);
- return;
- }
- }
+ ((mvB->x | mvB->y | mvB->ref) == 0) )) {
+ mvP2 = &un_mv;
/* if there is only one suitable candidate, take it */
- if((mvAref >= 0) && (mvBref < 0) && (mvCref < 0)) {
- mvP->x = mvA->x;
- mvP->y = mvA->y;
- } else if((mvAref < 0) && (mvBref >= 0) && (mvCref < 0)) {
- mvP->x = mvB->x;
- mvP->y = mvB->y;
- } else if((mvAref < 0) && (mvBref < 0) && (mvCref >= 0)) {
- mvP->x = mvC->x;
- mvP->y = mvC->y;
- } else {
- switch(mode) {
- case MV_PRED_LEFT:
- if(mvAref == mvP->ref) {
- mvP->x = mvA->x;
- mvP->y = mvA->y;
- } else
- mv_pred_median(h, mvP, mvA, mvB, mvC);
- break;
- case MV_PRED_TOP:
- if(mvBref == mvP->ref) {
- mvP->x = mvB->x;
- mvP->y = mvB->y;
- } else
- mv_pred_median(h, mvP, mvA, mvB, mvC);
- break;
- case MV_PRED_TOPRIGHT:
- if(mvCref == mvP->ref) {
- mvP->x = mvC->x;
- mvP->y = mvC->y;
- } else
- mv_pred_median(h, mvP, mvA, mvB, mvC);
- break;
- default:
- mv_pred_median(h, mvP, mvA, mvB, mvC);
- break;
- }
+ } else if((mvA->ref >= 0) && (mvB->ref < 0) && (mvC->ref < 0)) {
+ mvP2= mvA;
+ } else if((mvA->ref < 0) && (mvB->ref >= 0) && (mvC->ref < 0)) {
+ mvP2= mvB;
+ } else if((mvA->ref < 0) && (mvB->ref < 0) && (mvC->ref >= 0)) {
+ mvP2= mvC;
+ } else if(mode == MV_PRED_LEFT && mvA->ref == ref){
+ mvP2= mvA;
+ } else if(mode == MV_PRED_TOP && mvB->ref == ref){
+ mvP2= mvB;
+ } else if(mode == MV_PRED_TOPRIGHT && mvC->ref == ref){
+ mvP2= mvC;
}
+ if(mvP2){
+ mvP->x = mvP2->x;
+ mvP->y = mvP2->y;
+ }else
+ mv_pred_median(h, mvP, mvA, mvB, mvC);
+
if(mode < MV_PRED_PSKIP) {
mvP->x += get_se_golomb(&h->s.gb);
mvP->y += get_se_golomb(&h->s.gb);
int dqm = dequant_mul[qp];
int dqs = dequant_shift[qp];
int dqa = 1 << (dqs - 1);
- const uint8_t *scantab = ff_zigzag_direct;
- DCTELEM block[64];
+ const uint8_t *scantab = h->scantable.permutated;
+ DCTELEM *block = h->block;
- memset(block,0,64*sizeof(DCTELEM));
for(i=0;i<65;i++) {
level_code = get_ue_code(gb,r->golomb_order);
if(level_code >= ESCAPE_CODE) {
- run = (level_code - ESCAPE_CODE) >> 1;
+ run = ((level_code - ESCAPE_CODE) >> 1) + 1;
esc_code = get_ue_code(gb,esc_golomb_order);
level = esc_code + (run > r->max_run ? 1 : r->level_add[run]);
while(level > r->inc_limit)
mask = -(level_code & 1);
level = (level^mask) - mask;
} else {
- if(level_code < 0)
- return -1;
level = r->rltab[level_code][0];
if(!level) //end of block signal
break;
}
/* inverse scan and dequantization */
while(--i >= 0){
- pos += 1 + run_buf[i];
+ pos += run_buf[i];
if(pos > 63) {
av_log(h->s.avctx, AV_LOG_ERROR,
"position out of block bounds at pic %d MB(%d,%d)\n",
/* get quantizer */
if(h->cbp && !h->qp_fixed)
- h->qp += get_se_golomb(&h->s.gb);
+ h->qp = (h->qp + get_se_golomb(&h->s.gb)) & 63;
for(block=0;block<4;block++)
if(h->cbp & (1<<block))
decode_residual_block(h,&h->s.gb,inter_2dvlc,0,h->qp,
return 1;
}
-static int decode_mb_i(AVSContext *h) {
+static int decode_mb_i(AVSContext *h, int cbp_code) {
GetBitContext *gb = &h->s.gb;
int block, pred_mode_uv;
uint8_t top[18];
- uint8_t left[18];
+ uint8_t *left = NULL;
uint8_t *d;
init_mb(h);
nA = h->pred_mode_Y[pos-1];
nB = h->pred_mode_Y[pos-3];
- if((nA == NOT_AVAIL) || (nB == NOT_AVAIL))
- predpred = 2;
- else
- predpred = FFMIN(nA,nB);
- if(get_bits1(gb))
- h->pred_mode_Y[pos] = predpred;
- else {
- h->pred_mode_Y[pos] = get_bits(gb,2);
- if(h->pred_mode_Y[pos] >= predpred)
- h->pred_mode_Y[pos]++;
+ predpred = FFMIN(nA,nB);
+ if(predpred == NOT_AVAIL) // if either is not available
+ predpred = INTRA_L_LP;
+ if(!get_bits1(gb)){
+ int rem_mode= get_bits(gb, 2);
+ predpred = rem_mode + (rem_mode >= predpred);
}
+ h->pred_mode_Y[pos] = predpred;
}
pred_mode_uv = get_ue_golomb(gb);
if(pred_mode_uv > 6) {
av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n");
- pred_mode_uv = 0;
+ return -1;
}
/* save pred modes before they get modified */
}
/* get coded block pattern */
- if(h->pic_type == FF_I_TYPE){
- int cbp= get_ue_golomb(gb);
- if(cbp > 63){
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra cbp\n");
- return -1;
- }
- h->cbp = cbp_tab[cbp][0];
+ if(h->pic_type == FF_I_TYPE)
+ cbp_code = get_ue_golomb(gb);
+ if(cbp_code > 63){
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra cbp\n");
+ return -1;
}
+ h->cbp = cbp_tab[cbp_code][0];
if(h->cbp && !h->qp_fixed)
- h->qp += get_se_golomb(gb); //qp_delta
+ h->qp = (h->qp + get_se_golomb(gb)) & 63; //qp_delta
/* luma intra prediction interleaved with residual decode/transform/add */
for(block=0;block<4;block++) {
d = h->cy + h->luma_scan[block];
- load_intra_pred_luma(h, top, left, block);
+ load_intra_pred_luma(h, top, &left, block);
h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]
(d, top, left, h->l_stride);
if(h->cbp & (1<<block))
mv_pred(h, MV_FWD_X2, MV_FWD_X1, MV_PRED_MEDIAN, BLK_8X8, ref[2]);
mv_pred(h, MV_FWD_X3, MV_FWD_X0, MV_PRED_MEDIAN, BLK_8X8, ref[3]);
}
- inter_pred(h);
+ inter_pred(h, mb_type);
store_mvs(h);
if(mb_type != P_SKIP)
decode_residual_inter(h);
break;
default:
assert((mb_type > B_SYM_16X16) && (mb_type < B_8X8));
- flags = b_partition_flags[(mb_type-1)>>1];
+ flags = partition_flags[mb_type];
if(mb_type & 1) { /* 16x8 macroblock types */
if(flags & FWD0)
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1);
- if(flags & SYM0) {
- mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1);
+ if(flags & SYM0)
mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X8);
- }
if(flags & FWD1)
mv_pred(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1);
- if(flags & SYM1) {
- mv_pred(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1);
- mv_pred_sym(h, &h->mv[9], BLK_16X8);
- }
+ if(flags & SYM1)
+ mv_pred_sym(h, &h->mv[MV_FWD_X2], BLK_16X8);
if(flags & BWD0)
mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP, BLK_16X8, 0);
if(flags & BWD1)
} else { /* 8x16 macroblock types */
if(flags & FWD0)
mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1);
- if(flags & SYM0) {
- mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1);
+ if(flags & SYM0)
mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_8X16);
- }
if(flags & FWD1)
mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 1);
- if(flags & SYM1) {
- mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 1);
- mv_pred_sym(h, &h->mv[6], BLK_8X16);
- }
+ if(flags & SYM1)
+ mv_pred_sym(h, &h->mv[MV_FWD_X1], BLK_8X16);
if(flags & BWD0)
mv_pred(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0);
if(flags & BWD1)
mv_pred(h, MV_BWD_X1, MV_BWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 0);
}
}
- inter_pred(h);
+ inter_pred(h, mb_type);
if(mb_type != B_SKIP)
decode_residual_inter(h);
filter_mb(h,mb_type);
enum mb_t mb_type;
if (!s->context_initialized) {
+ s->avctx->idct_algo = FF_IDCT_CAVS;
if (MPV_common_init(s) < 0)
return -1;
+ ff_init_scantable(s->dsp.idct_permutation,&h->scantable,ff_zigzag_direct);
}
get_bits(&s->gb,16);//bbv_dwlay
if(h->stc == PIC_PB_START_CODE) {
h->pic_type = get_bits(&s->gb,2) + FF_I_TYPE;
+ if(h->pic_type > FF_B_TYPE) {
+ av_log(s->avctx, AV_LOG_ERROR, "illegal picture type\n");
+ return -1;
+ }
/* make sure we have the reference frames we need */
if(!h->DPB[0].data[0] ||
(!h->DPB[1].data[0] && h->pic_type == FF_B_TYPE))
check_for_slice(h);
if(h->pic_type == FF_I_TYPE) {
do {
- decode_mb_i(h);
+ decode_mb_i(h, 0);
} while(next_mb(h));
} else if(h->pic_type == FF_P_TYPE) {
do {
} else
mb_type = get_ue_golomb(&s->gb) + P_SKIP;
if(mb_type > P_8X8) {
- h->cbp = cbp_tab[mb_type - P_8X8 - 1][0];
- decode_mb_i(h);
+ decode_mb_i(h, mb_type - P_8X8 - 1);
} else
decode_mb_p(h,mb_type);
} while(next_mb(h));
mb_type = get_ue_golomb(&s->gb) + B_DIRECT;
} else
mb_type = get_ue_golomb(&s->gb) + B_SKIP;
- init_mb(h);
if(mb_type > B_8X8) {
- h->cbp = cbp_tab[mb_type - B_8X8 - 1][0];
- decode_mb_i(h);
+ decode_mb_i(h, mb_type - B_8X8 - 1);
} else
decode_mb_b(h,mb_type);
} while(next_mb(h));
/* alloc space for co-located MVs and types */
h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(vector_t));
h->col_type_base = av_malloc(h->mb_width*h->mb_height);
+ h->block = av_mallocz(64*sizeof(DCTELEM));
}
static int decode_seq_header(AVSContext *h) {
av_free(h->top_border_v);
av_free(h->col_mv);
av_free(h->col_type_base);
+ av_free(h->block);
return 0;
}