uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int src_x_offset, int src_y_offset,
qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op,
- int pixel_shift){
+ int pixel_shift, int chroma444){
MpegEncContext * const s = &h->s;
const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8;
int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8;
const int luma_xy= (mx&3) + ((my&3)<<2);
- uint8_t * src_y = pic->data[0] + ((mx>>2) << pixel_shift) + (my>>2)*h->mb_linesize;
+ int offset = ((mx>>2) << pixel_shift) + (my>>2)*h->mb_linesize;
+ uint8_t * src_y = pic->data[0] + offset;
uint8_t * src_cb, * src_cr;
int extra_width= h->emu_edge_width;
int extra_height= h->emu_edge_height;
qpix_op[luma_xy](dest_y + delta, src_y + delta, h->mb_linesize);
}
+ if(chroma444){
+ src_cb = pic->data[1] + offset;
+ if(emu){
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize,
+ 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
+ src_cb= s->edge_emu_buffer + (2 << pixel_shift) + 2*h->mb_linesize;
+ }
+ qpix_op[luma_xy](dest_cb, src_cb, h->mb_linesize); //FIXME try variable height perhaps?
+ if(!square){
+ qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize);
+ }
+
+ src_cr = pic->data[2] + offset;
+ if(emu){
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize,
+ 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
+ src_cr= s->edge_emu_buffer + (2 << pixel_shift) + 2*h->mb_linesize;
+ }
+ qpix_op[luma_xy](dest_cr, src_cr, h->mb_linesize); //FIXME try variable height perhaps?
+ if(!square){
+ qpix_op[luma_xy](dest_cr + delta, src_cr + delta, h->mb_linesize);
+ }
+ return;
+ }
+
if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return;
if(MB_FIELD){
int x_offset, int y_offset,
qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put,
qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg,
- int list0, int list1, int pixel_shift){
+ int list0, int list1, int pixel_shift, int chroma444){
MpegEncContext * const s = &h->s;
qpel_mc_func *qpix_op= qpix_put;
h264_chroma_mc_func chroma_op= chroma_put;
- dest_y += (2*x_offset << pixel_shift) + 2*y_offset*h-> mb_linesize;
- dest_cb += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
- dest_cr += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
+ dest_y += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize;
+ if(chroma444){
+ dest_cb += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize;
+ dest_cr += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize;
+ }else{
+ dest_cb += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
+ dest_cr += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
+ }
x_offset += 8*s->mb_x;
y_offset += 8*(s->mb_y >> MB_FIELD);
Picture *ref= &h->ref_list[0][ h->ref_cache[0][ scan8[n] ] ];
mc_dir_part(h, ref, n, square, chroma_height, delta, 0,
dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_op, chroma_op, pixel_shift);
+ qpix_op, chroma_op, pixel_shift, chroma444);
qpix_op= qpix_avg;
chroma_op= chroma_avg;
Picture *ref= &h->ref_list[1][ h->ref_cache[1][ scan8[n] ] ];
mc_dir_part(h, ref, n, square, chroma_height, delta, 1,
dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_op, chroma_op, pixel_shift);
+ qpix_op, chroma_op, pixel_shift, chroma444);
}
}
qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put,
h264_weight_func luma_weight_op, h264_weight_func chroma_weight_op,
h264_biweight_func luma_weight_avg, h264_biweight_func chroma_weight_avg,
- int list0, int list1, int pixel_shift){
+ int list0, int list1, int pixel_shift, int chroma444){
MpegEncContext * const s = &h->s;
- dest_y += (2*x_offset << pixel_shift) + 2*y_offset*h-> mb_linesize;
- dest_cb += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
- dest_cr += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
+ dest_y += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize;
+ if(chroma444){
+ chroma_weight_avg = luma_weight_avg;
+ chroma_weight_op = luma_weight_op;
+ dest_cb += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize;
+ dest_cr += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize;
+ }else{
+ dest_cb += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
+ dest_cr += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize;
+ }
x_offset += 8*s->mb_x;
y_offset += 8*(s->mb_y >> MB_FIELD);
/* don't optimize for luma-only case, since B-frames usually
* use implicit weights => chroma too. */
uint8_t *tmp_cb = s->obmc_scratchpad;
- uint8_t *tmp_cr = s->obmc_scratchpad + (8 << pixel_shift);
- uint8_t *tmp_y = s->obmc_scratchpad + 8*h->mb_uvlinesize;
+ uint8_t *tmp_cr = s->obmc_scratchpad + (16 << pixel_shift);
+ uint8_t *tmp_y = s->obmc_scratchpad + 16*h->mb_uvlinesize;
int refn0 = h->ref_cache[0][ scan8[n] ];
int refn1 = h->ref_cache[1][ scan8[n] ];
mc_dir_part(h, &h->ref_list[0][refn0], n, square, chroma_height, delta, 0,
dest_y, dest_cb, dest_cr,
- x_offset, y_offset, qpix_put, chroma_put, pixel_shift);
+ x_offset, y_offset, qpix_put, chroma_put, pixel_shift, chroma444);
mc_dir_part(h, &h->ref_list[1][refn1], n, square, chroma_height, delta, 1,
tmp_y, tmp_cb, tmp_cr,
- x_offset, y_offset, qpix_put, chroma_put, pixel_shift);
+ x_offset, y_offset, qpix_put, chroma_put, pixel_shift, chroma444);
if(h->use_weight == 2){
int weight0 = h->implicit_weight[refn0][refn1][s->mb_y&1];
Picture *ref= &h->ref_list[list][refn];
mc_dir_part(h, ref, n, square, chroma_height, delta, list,
dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_put, chroma_put, pixel_shift);
+ qpix_put, chroma_put, pixel_shift, chroma444);
luma_weight_op(dest_y, h->mb_linesize, h->luma_log2_weight_denom,
h->luma_weight[refn][list][0], h->luma_weight[refn][list][1]);
qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put,
qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg,
h264_weight_func *weight_op, h264_biweight_func *weight_avg,
- int list0, int list1, int pixel_shift){
+ int list0, int list1, int pixel_shift, int chroma444){
if((h->use_weight==2 && list0 && list1
&& (h->implicit_weight[ h->ref_cache[0][scan8[n]] ][ h->ref_cache[1][scan8[n]] ][h->s.mb_y&1] != 32))
|| h->use_weight==1)
mc_part_weighted(h, n, square, chroma_height, delta, dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put,
weight_op[0], weight_op[3], weight_avg[0],
- weight_avg[3], list0, list1, pixel_shift);
+ weight_avg[3], list0, list1, pixel_shift, chroma444);
else
mc_part_std(h, n, square, chroma_height, delta, dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put, qpix_avg,
- chroma_avg, list0, list1, pixel_shift);
+ chroma_avg, list0, list1, pixel_shift, chroma444);
}
-static inline void prefetch_motion(H264Context *h, int list, int pixel_shift){
+static inline void prefetch_motion(H264Context *h, int list, int pixel_shift, int chroma444){
/* fetch pixels for estimated mv 4 macroblocks ahead
* optimized for 64byte cache lines */
MpegEncContext * const s = &h->s;
uint8_t **src= h->ref_list[list][refn].data;
int off= (mx << pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize + (64 << pixel_shift);
s->dsp.prefetch(src[0]+off, s->linesize, 4);
- off= ((mx>>1) << pixel_shift) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + (64 << pixel_shift);
- s->dsp.prefetch(src[1]+off, src[2]-src[1], 2);
+ if(chroma444){
+ s->dsp.prefetch(src[1]+off, s->linesize, 4);
+ s->dsp.prefetch(src[2]+off, s->linesize, 4);
+ }else{
+ off= ((mx>>1) << pixel_shift) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + (64 << pixel_shift);
+ s->dsp.prefetch(src[1]+off, src[2]-src[1], 2);
+ }
}
}
qpel_mc_func (*qpix_put)[16], h264_chroma_mc_func (*chroma_put),
qpel_mc_func (*qpix_avg)[16], h264_chroma_mc_func (*chroma_avg),
h264_weight_func *weight_op, h264_biweight_func *weight_avg,
- int pixel_shift){
+ int pixel_shift, int chroma444){
MpegEncContext * const s = &h->s;
const int mb_xy= h->mb_xy;
const int mb_type= s->current_picture.mb_type[mb_xy];
if(HAVE_PTHREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
await_references(h);
- prefetch_motion(h, 0, pixel_shift);
+ prefetch_motion(h, 0, pixel_shift, chroma444);
if(IS_16X16(mb_type)){
mc_part(h, 0, 1, 8, 0, dest_y, dest_cb, dest_cr, 0, 0,
qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0],
weight_op, weight_avg,
IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}else if(IS_16X8(mb_type)){
mc_part(h, 0, 0, 4, 8 << pixel_shift, dest_y, dest_cb, dest_cr, 0, 0,
qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],
&weight_op[1], &weight_avg[1],
IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
mc_part(h, 8, 0, 4, 8 << pixel_shift, dest_y, dest_cb, dest_cr, 0, 4,
qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],
&weight_op[1], &weight_avg[1],
IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}else if(IS_8X16(mb_type)){
mc_part(h, 0, 0, 8, 8*h->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0,
qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
&weight_op[2], &weight_avg[2],
IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
mc_part(h, 4, 0, 8, 8*h->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0,
qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
&weight_op[2], &weight_avg[2],
IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}else{
int i;
qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
&weight_op[3], &weight_avg[3],
IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}else if(IS_SUB_8X4(sub_mb_type)){
mc_part(h, n , 0, 2, 4 << pixel_shift, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],
&weight_op[4], &weight_avg[4],
IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
mc_part(h, n+2, 0, 2, 4 << pixel_shift, dest_y, dest_cb, dest_cr, x_offset, y_offset+2,
qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],
&weight_op[4], &weight_avg[4],
IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}else if(IS_SUB_4X8(sub_mb_type)){
mc_part(h, n , 0, 4, 4*h->mb_linesize, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
&weight_op[5], &weight_avg[5],
IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
mc_part(h, n+1, 0, 4, 4*h->mb_linesize, dest_y, dest_cb, dest_cr, x_offset+2, y_offset,
qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
&weight_op[5], &weight_avg[5],
IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}else{
int j;
assert(IS_SUB_4X4(sub_mb_type));
qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
&weight_op[6], &weight_avg[6],
IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1),
- pixel_shift);
+ pixel_shift, chroma444);
}
}
}
}
- prefetch_motion(h, 1, pixel_shift);
+ prefetch_motion(h, 1, pixel_shift, chroma444);
}
#define hl_motion_fn(sh, bits) \
qpel_mc_func (*qpix_avg)[16], \
h264_chroma_mc_func (*chroma_avg), \
h264_weight_func *weight_op, \
- h264_biweight_func *weight_avg) \
+ h264_biweight_func *weight_avg, \
+ int chroma444) \
{ \
hl_motion(h, dest_y, dest_cb, dest_cr, qpix_put, chroma_put, \
- qpix_avg, chroma_avg, weight_op, weight_avg, sh); \
+ qpix_avg, chroma_avg, weight_op, weight_avg, sh, chroma444); \
}
hl_motion_fn(0, 8);
hl_motion_fn(1, 16);
}
static void init_dequant8_coeff_table(H264Context *h){
- int i,q,x;
+ int i,j,q,x;
const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
- h->dequant8_coeff[0] = h->dequant8_buffer[0];
- h->dequant8_coeff[1] = h->dequant8_buffer[1];
- for(i=0; i<2; i++ ){
- if(i && !memcmp(h->pps.scaling_matrix8[0], h->pps.scaling_matrix8[1], 64*sizeof(uint8_t))){
- h->dequant8_coeff[1] = h->dequant8_buffer[0];
- break;
+ for(i=0; i<6; i++ ){
+ h->dequant8_coeff[i] = h->dequant8_buffer[i];
+ for(j=0; j<i; j++){
+ if(!memcmp(h->pps.scaling_matrix8[j], h->pps.scaling_matrix8[i], 64*sizeof(uint8_t))){
+ h->dequant8_coeff[i] = h->dequant8_buffer[j];
+ break;
+ }
}
+ if(j<i)
+ continue;
for(q=0; q<max_qp+1; q++){
int shift = div6[q];
for(x=0; x<16; x++)
h->dequant4_coeff[i][0][x] = 1<<6;
if(h->pps.transform_8x8_mode)
- for(i=0; i<2; i++)
+ for(i=0; i<6; i++)
for(x=0; x<64; x++)
h->dequant8_coeff[i][0][x] = 1<<6;
}
FF_ALLOCZ_OR_GOTO(h->s.avctx, h->intra4x4_pred_mode, row_mb_num * 8 * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->non_zero_count , big_mb_num * 32 * sizeof(uint8_t), fail)
+ FF_ALLOCZ_OR_GOTO(h->s.avctx, h->non_zero_count , big_mb_num * 48 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(h->s.avctx, h->slice_table_base , (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base), fail)
FF_ALLOCZ_OR_GOTO(h->s.avctx, h->cbp_table, big_mb_num * sizeof(uint16_t), fail)
* Allocate buffers which are not shared amongst multiple threads.
*/
static int context_init(H264Context *h){
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t)*2, fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t)*2, fail)
+ FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[0], h->s.mb_width * 16*3 * sizeof(uint8_t)*2, fail)
+ FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[1], h->s.mb_width * 16*3 * sizeof(uint8_t)*2, fail)
h->ref_cache[0][scan8[5 ]+1] = h->ref_cache[0][scan8[7 ]+1] = h->ref_cache[0][scan8[13]+1] =
h->ref_cache[1][scan8[5 ]+1] = h->ref_cache[1][scan8[7 ]+1] = h->ref_cache[1][scan8[13]+1] = PART_NOT_AVAILABLE;
// frame_start may not be called for the next thread (if it's decoding a bottom field)
// so this has to be allocated here
- h->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize);
+ h->s.obmc_scratchpad = av_malloc(16*6*s->linesize);
s->dsp.clear_blocks(h->mb);
+ s->dsp.clear_blocks(h->mb+(24*16<<h->pixel_shift));
}
//extradata/NAL handling
for(i=0; i<6; i++)
h->dequant4_coeff[i] = h->dequant4_buffer[0] + (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
- for(i=0; i<2; i++)
+ for(i=0; i<6; i++)
h->dequant8_coeff[i] = h->dequant8_buffer[0] + (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
h->dequant_coeff_pps = h1->dequant_coeff_pps;
for(i=0; i<16; i++){
h->block_offset[i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 4*s->linesize*((scan8[i] - scan8[0])>>3);
- h->block_offset[24+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->linesize*((scan8[i] - scan8[0])>>3);
+ h->block_offset[48+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->linesize*((scan8[i] - scan8[0])>>3);
}
- for(i=0; i<4; i++){
+ for(i=0; i<16; i++){
h->block_offset[16+i]=
- h->block_offset[20+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3);
- h->block_offset[24+16+i]=
- h->block_offset[24+20+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->uvlinesize*((scan8[i] - scan8[0])>>3);
+ h->block_offset[32+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3);
+ h->block_offset[48+16+i]=
+ h->block_offset[48+32+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->uvlinesize*((scan8[i] - scan8[0])>>3);
}
/* can't be in alloc_tables because linesize isn't known there.
* FIXME: redo bipred weight to not require extra buffer? */
for(i = 0; i < thread_count; i++)
if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
- h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize);
+ h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*6*s->linesize);
/* some macroblocks can be accessed before they're available in case of lost slices, mbaff or threading*/
memset(h->slice_table, -1, (s->mb_height*s->mb_stride-1) * sizeof(*h->slice_table));
ff_thread_finish_setup(s->avctx);
}
-static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int simple){
+static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int chroma444, int simple){
MpegEncContext * const s = &h->s;
uint8_t *top_border;
int top_idx = 1;
if (pixel_shift)
AV_COPY128(top_border+16, src_y+15*linesize+16);
if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if (pixel_shift) {
- AV_COPY128(top_border+32, src_cb+7*uvlinesize);
- AV_COPY128(top_border+48, src_cr+7*uvlinesize);
+ if(chroma444){
+ if (pixel_shift){
+ AV_COPY128(top_border+32, src_cb + 15*uvlinesize);
+ AV_COPY128(top_border+48, src_cb + 15*uvlinesize+16);
+ AV_COPY128(top_border+64, src_cr + 15*uvlinesize);
+ AV_COPY128(top_border+80, src_cr + 15*uvlinesize+16);
+ } else {
+ AV_COPY128(top_border+16, src_cb + 15*uvlinesize);
+ AV_COPY128(top_border+32, src_cr + 15*uvlinesize);
+ }
} else {
- AV_COPY64(top_border+16, src_cb+7*uvlinesize);
- AV_COPY64(top_border+24, src_cr+7*uvlinesize);
+ if (pixel_shift) {
+ AV_COPY128(top_border+32, src_cb+7*uvlinesize);
+ AV_COPY128(top_border+48, src_cr+7*uvlinesize);
+ } else {
+ AV_COPY64(top_border+16, src_cb+7*uvlinesize);
+ AV_COPY64(top_border+24, src_cr+7*uvlinesize);
+ }
}
}
}
AV_COPY128(top_border+16, src_y+16*linesize+16);
if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if (pixel_shift) {
- AV_COPY128(top_border+32, src_cb+8*uvlinesize);
- AV_COPY128(top_border+48, src_cr+8*uvlinesize);
+ if(chroma444){
+ if (pixel_shift){
+ AV_COPY128(top_border+32, src_cb + 16*linesize);
+ AV_COPY128(top_border+48, src_cb + 16*linesize+16);
+ AV_COPY128(top_border+64, src_cr + 16*linesize);
+ AV_COPY128(top_border+80, src_cr + 16*linesize+16);
+ } else {
+ AV_COPY128(top_border+16, src_cb + 16*linesize);
+ AV_COPY128(top_border+32, src_cr + 16*linesize);
+ }
} else {
- AV_COPY64(top_border+16, src_cb+8*uvlinesize);
- AV_COPY64(top_border+24, src_cr+8*uvlinesize);
+ if (pixel_shift) {
+ AV_COPY128(top_border+32, src_cb+8*uvlinesize);
+ AV_COPY128(top_border+48, src_cr+8*uvlinesize);
+ } else {
+ AV_COPY64(top_border+16, src_cb+8*uvlinesize);
+ AV_COPY64(top_border+24, src_cr+8*uvlinesize);
+ }
}
}
}
static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
uint8_t *src_cb, uint8_t *src_cr,
int linesize, int uvlinesize,
- int xchg, int simple, int pixel_shift){
+ int xchg, int chroma444,
+ int simple, int pixel_shift){
MpegEncContext * const s = &h->s;
int deblock_topleft;
int deblock_top;
}
}
if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if(deblock_top){
+ if(chroma444){
if(deblock_topleft){
- XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
- XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
+ XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
+ XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
+ }
+ XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
+ XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
+ XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
+ XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
+ if(s->mb_x+1 < s->mb_width){
+ XCHG(h->top_borders[top_idx][s->mb_x+1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
+ XCHG(h->top_borders[top_idx][s->mb_x+1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
+ }
+ } else {
+ if(deblock_top){
+ if(deblock_topleft){
+ XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
+ XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
+ }
+ XCHG(top_border + (16 << pixel_shift), src_cb+1+pixel_shift, 1);
+ XCHG(top_border + (24 << pixel_shift), src_cr+1+pixel_shift, 1);
}
- XCHG(top_border + (16 << pixel_shift), src_cb+1+pixel_shift, 1);
- XCHG(top_border + (24 << pixel_shift), src_cr+1+pixel_shift, 1);
}
}
}
AV_WN16A(mb + index, value);
}
+static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass,
+ int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
+{
+ MpegEncContext * const s = &h->s;
+ void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
+ void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
+ int i;
+ int qscale = p == 0 ? s->qscale : h->chroma_qp[p-1];
+ block_offset += 16*p;
+ if(IS_INTRA4x4(mb_type)){
+ if(simple || !s->encoding){
+ if(IS_8x8DCT(mb_type)){
+ if(transform_bypass){
+ idct_dc_add =
+ idct_add = s->dsp.add_pixels8;
+ }else{
+ idct_dc_add = h->h264dsp.h264_idct8_dc_add;
+ idct_add = h->h264dsp.h264_idct8_add;
+ }
+ for(i=0; i<16; i+=4){
+ uint8_t * const ptr= dest_y + block_offset[i];
+ const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
+ if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
+ h->hpc.pred8x8l_add[dir](ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
+ }else{
+ const int nnz = h->non_zero_count_cache[ scan8[i+p*16] ];
+ h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
+ (h->topright_samples_available<<i)&0x4000, linesize);
+ if(nnz){
+ if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16+p*256))
+ idct_dc_add(ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
+ else
+ idct_add (ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
+ }
+ }
+ }
+ }else{
+ if(transform_bypass){
+ idct_dc_add =
+ idct_add = s->dsp.add_pixels4;
+ }else{
+ idct_dc_add = h->h264dsp.h264_idct_dc_add;
+ idct_add = h->h264dsp.h264_idct_add;
+ }
+ for(i=0; i<16; i++){
+ uint8_t * const ptr= dest_y + block_offset[i];
+ const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
+
+ if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
+ h->hpc.pred4x4_add[dir](ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
+ }else{
+ uint8_t *topright;
+ int nnz, tr;
+ uint64_t tr_high;
+ if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){
+ const int topright_avail= (h->topright_samples_available<<i)&0x8000;
+ assert(mb_y || linesize <= block_offset[i]);
+ if(!topright_avail){
+ if (pixel_shift) {
+ tr_high= ((uint16_t*)ptr)[3 - linesize/2]*0x0001000100010001ULL;
+ topright= (uint8_t*) &tr_high;
+ } else {
+ tr= ptr[3 - linesize]*0x01010101;
+ topright= (uint8_t*) &tr;
+ }
+ }else
+ topright= ptr + (4 << pixel_shift) - linesize;
+ }else
+ topright= NULL;
+
+ h->hpc.pred4x4[ dir ](ptr, topright, linesize);
+ nnz = h->non_zero_count_cache[ scan8[i+p*16] ];
+ if(nnz){
+ if(is_h264){
+ if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16+p*256))
+ idct_dc_add(ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
+ else
+ idct_add (ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
+ }else
+ ff_svq3_add_idct_c(ptr, h->mb + i*16+p*256, linesize, qscale, 0);
+ }
+ }
+ }
+ }
+ }
+ }else{
+ h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
+ if(is_h264){
+ if(h->non_zero_count_cache[ scan8[LUMA_DC_BLOCK_INDEX+p] ]){
+ if(!transform_bypass)
+ h->h264dsp.h264_luma_dc_dequant_idct(h->mb+(p*256 << pixel_shift), h->mb_luma_dc[p], h->dequant4_coeff[p][qscale][0]);
+ else{
+ static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16,
+ 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16};
+ for(i = 0; i < 16; i++)
+ dctcoef_set(h->mb+p*256, pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc[p], pixel_shift, i));
+ }
+ }
+ }else
+ ff_svq3_luma_dc_dequant_idct_c(h->mb+p*256, h->mb_luma_dc[p], qscale);
+ }
+}
+
+static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass,
+ int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
+{
+ MpegEncContext * const s = &h->s;
+ void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
+ int i;
+ block_offset += 16*p;
+ if(!IS_INTRA4x4(mb_type)){
+ if(is_h264){
+ if(IS_INTRA16x16(mb_type)){
+ if(transform_bypass){
+ if(h->sps.profile_idc==244 && (h->intra16x16_pred_mode==VERT_PRED8x8 || h->intra16x16_pred_mode==HOR_PRED8x8)){
+ h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb + (p*256 << pixel_shift), linesize);
+ }else{
+ for(i=0; i<16; i++){
+ if(h->non_zero_count_cache[ scan8[i+p*16] ] || dctcoef_get(h->mb, pixel_shift, i*16))
+ s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16+p*256 << pixel_shift), linesize);
+ }
+ }
+ }else{
+ h->h264dsp.h264_idct_add16intra(dest_y, block_offset, h->mb + (p*256 << pixel_shift), linesize, h->non_zero_count_cache+p*5*8);
+ }
+ }else if(h->cbp&15){
+ if(transform_bypass){
+ const int di = IS_8x8DCT(mb_type) ? 4 : 1;
+ idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;
+ for(i=0; i<16; i+=di){
+ if(h->non_zero_count_cache[ scan8[i+p*16] ]){
+ idct_add(dest_y + block_offset[i], h->mb + (i*16+p*256 << pixel_shift), linesize);
+ }
+ }
+ }else{
+ if(IS_8x8DCT(mb_type)){
+ h->h264dsp.h264_idct8_add4(dest_y, block_offset, h->mb + (p*256 << pixel_shift), linesize, h->non_zero_count_cache+p*5*8);
+ }else{
+ h->h264dsp.h264_idct_add16(dest_y, block_offset, h->mb + (p*256 << pixel_shift), linesize, h->non_zero_count_cache+p*5*8);
+ }
+ }
+ }
+ }else{
+ for(i=0; i<16; i++){
+ if(h->non_zero_count_cache[ scan8[i+p*16] ] || h->mb[i*16+p*256]){ //FIXME benchmark weird rule, & below
+ uint8_t * const ptr= dest_y + block_offset[i];
+ ff_svq3_add_idct_c(ptr, h->mb + i*16 + p*256, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0);
+ }
+ }
+ }
+ }
+}
+
static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, int pixel_shift){
MpegEncContext * const s = &h->s;
const int mb_x= s->mb_x;
const int mb_type= s->current_picture.mb_type[mb_xy];
uint8_t *dest_y, *dest_cb, *dest_cr;
int linesize, uvlinesize /*dct_offset*/;
- int i;
+ int i, j;
int *block_offset = &h->block_offset[0];
const int transform_bypass = !simple && (s->qscale == 0 && h->sps.transform_bypass);
/* is_h264 should always be true if SVQ3 is disabled. */
const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264;
void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
- void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16;
dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
if (!simple && MB_FIELD) {
linesize = h->mb_linesize = s->linesize * 2;
uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;
- block_offset = &h->block_offset[24];
+ block_offset = &h->block_offset[48];
if(mb_y&1){ //FIXME move out of this function?
dest_y -= s->linesize*15;
dest_cb-= s->uvlinesize*7;
} else {
if(IS_INTRA(mb_type)){
if(h->deblocking_filter)
- xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple, pixel_shift);
+ xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, 0, simple, pixel_shift);
if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize);
h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize);
}
- if(IS_INTRA4x4(mb_type)){
- if(simple || !s->encoding){
- if(IS_8x8DCT(mb_type)){
- if(transform_bypass){
- idct_dc_add =
- idct_add = s->dsp.add_pixels8;
- }else{
- idct_dc_add = h->h264dsp.h264_idct8_dc_add;
- idct_add = h->h264dsp.h264_idct8_add;
- }
- for(i=0; i<16; i+=4){
- uint8_t * const ptr= dest_y + block_offset[i];
- const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
- if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
- h->hpc.pred8x8l_add[dir](ptr, h->mb + (i*16 << pixel_shift), linesize);
- }else{
- const int nnz = h->non_zero_count_cache[ scan8[i] ];
- h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
- (h->topright_samples_available<<i)&0x4000, linesize);
- if(nnz){
- if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16))
- idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize);
- else
- idct_add (ptr, h->mb + (i*16 << pixel_shift), linesize);
- }
- }
- }
- }else{
- if(transform_bypass){
- idct_dc_add =
- idct_add = s->dsp.add_pixels4;
- }else{
- idct_dc_add = h->h264dsp.h264_idct_dc_add;
- idct_add = h->h264dsp.h264_idct_add;
- }
- for(i=0; i<16; i++){
- uint8_t * const ptr= dest_y + block_offset[i];
- const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
-
- if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
- h->hpc.pred4x4_add[dir](ptr, h->mb + (i*16 << pixel_shift), linesize);
- }else{
- uint8_t *topright;
- int nnz, tr;
- uint64_t tr_high;
- if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){
- const int topright_avail= (h->topright_samples_available<<i)&0x8000;
- assert(mb_y || linesize <= block_offset[i]);
- if(!topright_avail){
- if (pixel_shift) {
- tr_high= ((uint16_t*)ptr)[3 - linesize/2]*0x0001000100010001ULL;
- topright= (uint8_t*) &tr_high;
- } else {
- tr= ptr[3 - linesize]*0x01010101;
- topright= (uint8_t*) &tr;
- }
- }else
- topright= ptr + (4 << pixel_shift) - linesize;
- }else
- topright= NULL;
-
- h->hpc.pred4x4[ dir ](ptr, topright, linesize);
- nnz = h->non_zero_count_cache[ scan8[i] ];
- if(nnz){
- if(is_h264){
- if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16))
- idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize);
- else
- idct_add (ptr, h->mb + (i*16 << pixel_shift), linesize);
- }else
- ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0);
- }
- }
- }
- }
- }
- }else{
- h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
- if(is_h264){
- if(h->non_zero_count_cache[ scan8[LUMA_DC_BLOCK_INDEX] ]){
- if(!transform_bypass)
- h->h264dsp.h264_luma_dc_dequant_idct(h->mb, h->mb_luma_dc, h->dequant4_coeff[0][s->qscale][0]);
- else{
- static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16,
- 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16};
- for(i = 0; i < 16; i++)
- dctcoef_set(h->mb, pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc, pixel_shift, i));
- }
- }
- }else
- ff_svq3_luma_dc_dequant_idct_c(h->mb, h->mb_luma_dc, s->qscale);
- }
+ hl_decode_mb_predict_luma(h, mb_type, is_h264, simple, transform_bypass, pixel_shift, block_offset, linesize, dest_y, 0);
+
if(h->deblocking_filter)
- xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, simple, pixel_shift);
+ xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, simple, pixel_shift);
}else if(is_h264){
if (pixel_shift) {
hl_motion_16(h, dest_y, dest_cb, dest_cr,
s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
- h->h264dsp.biweight_h264_pixels_tab);
+ h->h264dsp.biweight_h264_pixels_tab, 0);
} else
hl_motion_8(h, dest_y, dest_cb, dest_cr,
s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
- h->h264dsp.biweight_h264_pixels_tab);
+ h->h264dsp.biweight_h264_pixels_tab, 0);
}
-
- if(!IS_INTRA4x4(mb_type)){
- if(is_h264){
- if(IS_INTRA16x16(mb_type)){
- if(transform_bypass){
- if(h->sps.profile_idc==244 && (h->intra16x16_pred_mode==VERT_PRED8x8 || h->intra16x16_pred_mode==HOR_PRED8x8)){
- h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize);
- }else{
- for(i=0; i<16; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
- s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16 << pixel_shift), linesize);
- }
- }
- }else{
- h->h264dsp.h264_idct_add16intra(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);
- }
- }else if(h->cbp&15){
- if(transform_bypass){
- const int di = IS_8x8DCT(mb_type) ? 4 : 1;
- idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;
- for(i=0; i<16; i+=di){
- if(h->non_zero_count_cache[ scan8[i] ]){
- idct_add(dest_y + block_offset[i], h->mb + (i*16 << pixel_shift), linesize);
- }
- }
- }else{
- if(IS_8x8DCT(mb_type)){
- h->h264dsp.h264_idct8_add4(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);
- }else{
- h->h264dsp.h264_idct_add16(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);
- }
- }
- }
- }else{
- for(i=0; i<16; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below
- uint8_t * const ptr= dest_y + block_offset[i];
- ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0);
- }
- }
- }
- }
+ hl_decode_mb_idct_luma(h, mb_type, is_h264, simple, transform_bypass, pixel_shift, block_offset, linesize, dest_y, 0);
if((simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) && (h->cbp&0x30)){
uint8_t *dest[2] = {dest_cb, dest_cr};
if(transform_bypass){
if(IS_INTRA(mb_type) && h->sps.profile_idc==244 && (h->chroma_pred_mode==VERT_PRED8x8 || h->chroma_pred_mode==HOR_PRED8x8)){
- h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + (16*16 << pixel_shift), uvlinesize);
- h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + (20*16 << pixel_shift), uvlinesize);
+ h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + (16*16*1 << pixel_shift), uvlinesize);
+ h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 32, h->mb + (16*16*2 << pixel_shift), uvlinesize);
}else{
idct_add = s->dsp.add_pixels4;
- for(i=16; i<16+8; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
- idct_add (dest[(i&4)>>2] + block_offset[i], h->mb + (i*16 << pixel_shift), uvlinesize);
+ for(j=1; j<3; j++){
+ for(i=j*16; i<j*16+4; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
+ idct_add (dest[j-1] + block_offset[i], h->mb + (i*16 << pixel_shift), uvlinesize);
+ }
}
}
}else{
if(is_h264){
if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ])
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16 << pixel_shift) , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
+ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16*1 << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ])
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + ((16*16+4*16) << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
+ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16*2 << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
h->h264dsp.h264_idct_add8(dest, block_offset,
h->mb, uvlinesize,
h->non_zero_count_cache);
}else{
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
- for(i=16; i<16+8; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
- uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i];
- ff_svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[0][s->qscale + 12] - 12, 2);
+ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16*1, h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
+ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16*2, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
+ for(j=1; j<3; j++){
+ for(i=j*16; i<j*16+4; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
+ uint8_t * const ptr= dest[j-1] + block_offset[i];
+ ff_svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[0][s->qscale + 12] - 12, 2);
+ }
}
}
}
}
}
if(h->cbp || IS_INTRA(mb_type))
+ {
s->dsp.clear_blocks(h->mb);
+ s->dsp.clear_blocks(h->mb+(24*16<<pixel_shift));
+ }
+}
+
+static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simple, int pixel_shift){
+ MpegEncContext * const s = &h->s;
+ const int mb_x= s->mb_x;
+ const int mb_y= s->mb_y;
+ const int mb_xy= h->mb_xy;
+ const int mb_type= s->current_picture.mb_type[mb_xy];
+ uint8_t *dest[3];
+ int linesize;
+ int i, j, p;
+ int *block_offset = &h->block_offset[0];
+ const int transform_bypass = !simple && (s->qscale == 0 && h->sps.transform_bypass);
+
+ for (p = 0; p < 3; p++)
+ {
+ dest[p] = s->current_picture.data[p] + ((mb_x << pixel_shift) + mb_y * s->linesize) * 16;
+ s->dsp.prefetch(dest[p] + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4);
+ }
+
+ h->list_counts[mb_xy]= h->list_count;
+
+ if (!simple && MB_FIELD) {
+ linesize = h->mb_linesize = h->mb_uvlinesize = s->linesize * 2;
+ block_offset = &h->block_offset[48];
+ if(mb_y&1) //FIXME move out of this function?
+ for (p = 0; p < 3; p++)
+ dest[p] -= s->linesize*15;
+ if(FRAME_MBAFF) {
+ int list;
+ for(list=0; list<h->list_count; list++){
+ if(!USES_LIST(mb_type, list))
+ continue;
+ if(IS_16X16(mb_type)){
+ int8_t *ref = &h->ref_cache[list][scan8[0]];
+ fill_rectangle(ref, 4, 4, 8, (16+*ref)^(s->mb_y&1), 1);
+ }else{
+ for(i=0; i<16; i+=4){
+ int ref = h->ref_cache[list][scan8[i]];
+ if(ref >= 0)
+ fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2, 8, (16+ref)^(s->mb_y&1), 1);
+ }
+ }
+ }
+ }
+ } else {
+ linesize = h->mb_linesize = h->mb_uvlinesize = s->linesize;
+ }
+
+ if (!simple && IS_INTRA_PCM(mb_type)) {
+ if (pixel_shift) {
+ const int bit_depth = h->sps.bit_depth_luma;
+ GetBitContext gb;
+ init_get_bits(&gb, (uint8_t*)h->mb, 768*bit_depth);
+
+ for (p = 0; p < 3; p++) {
+ for (i = 0; i < 16; i++) {
+ uint16_t *tmp = (uint16_t*)(dest[p] + i*linesize);
+ for (j = 0; j < 16; j++)
+ tmp[j] = get_bits(&gb, bit_depth);
+ }
+ }
+ } else {
+ for (p = 0; p < 3; p++) {
+ for (i = 0; i < 16; i++) {
+ memcpy(dest[p] + i*linesize, h->mb + p*128 + i*8, 16);
+ }
+ }
+ }
+ } else {
+ if(IS_INTRA(mb_type)){
+ if(h->deblocking_filter)
+ xchg_mb_border(h, dest[0], dest[1], dest[2], linesize, linesize, 1, 1, simple, pixel_shift);
+
+ for (p = 0; p < 3; p++)
+ hl_decode_mb_predict_luma(h, mb_type, 1, simple, transform_bypass, pixel_shift, block_offset, linesize, dest[p], p);
+
+ if(h->deblocking_filter)
+ xchg_mb_border(h, dest[0], dest[1], dest[2], linesize, linesize, 0, 1, simple, pixel_shift);
+ }else{
+ if (pixel_shift) {
+ hl_motion_16(h, dest[0], dest[1], dest[2],
+ s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
+ s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
+ h->h264dsp.weight_h264_pixels_tab,
+ h->h264dsp.biweight_h264_pixels_tab, 1);
+ } else
+ hl_motion_8(h, dest[0], dest[1], dest[2],
+ s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
+ s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
+ h->h264dsp.weight_h264_pixels_tab,
+ h->h264dsp.biweight_h264_pixels_tab, 1);
+ }
+
+ for (p = 0; p < 3; p++)
+ hl_decode_mb_idct_luma(h, mb_type, 1, simple, transform_bypass, pixel_shift, block_offset, linesize, dest[p], p);
+ }
+ if(h->cbp || IS_INTRA(mb_type))
+ {
+ s->dsp.clear_blocks(h->mb);
+ s->dsp.clear_blocks(h->mb+(24*16<<pixel_shift));
+ }
}
/**
hl_decode_mb_internal(h, 0, h->pixel_shift);
}
+static void av_noinline hl_decode_mb_444_complex(H264Context *h){
+ hl_decode_mb_444_internal(h, 0, h->pixel_shift);
+}
+
+static void av_noinline hl_decode_mb_444_simple(H264Context *h){
+ hl_decode_mb_444_internal(h, 1, 0);
+}
+
void ff_h264_hl_decode_mb(H264Context *h){
MpegEncContext * const s = &h->s;
const int mb_xy= h->mb_xy;
const int mb_type= s->current_picture.mb_type[mb_xy];
int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;
- if (is_complex) {
+ if (CHROMA444) {
+ if(is_complex || h->pixel_shift)
+ hl_decode_mb_444_complex(h);
+ else
+ hl_decode_mb_444_simple(h);
+ } else if (is_complex) {
hl_decode_mb_complex(h);
} else if (h->pixel_shift) {
hl_decode_mb_simple_16(h);
h->use_weight= 0;
h->use_weight_chroma= 0;
h->luma_log2_weight_denom= get_ue_golomb(&s->gb);
- if(CHROMA)
+ if(h->sps.chroma_format_idc)
h->chroma_log2_weight_denom= get_ue_golomb(&s->gb);
luma_def = 1<<h->luma_log2_weight_denom;
chroma_def = 1<<h->chroma_log2_weight_denom;
h->luma_weight[i][list][1]= 0;
}
- if(CHROMA){
+ if(h->sps.chroma_format_idc){
chroma_weight_flag= get_bits1(&s->gb);
if(chroma_weight_flag){
int j;
h->b_stride= s->mb_width*4;
- s->width = 16*s->mb_width - 2*FFMIN(h->sps.crop_right, 7);
+ s->width = 16*s->mb_width - (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1);
if(h->sps.frame_mbs_only_flag)
- s->height= 16*s->mb_height - 2*FFMIN(h->sps.crop_bottom, 7);
+ s->height= 16*s->mb_height - (2>>CHROMA444)*FFMIN(h->sps.crop_bottom, (8<<CHROMA444)-1);
else
- s->height= 16*s->mb_height - 4*FFMIN(h->sps.crop_bottom, 7);
+ s->height= 16*s->mb_height - (4>>CHROMA444)*FFMIN(h->sps.crop_bottom, (8<<CHROMA444)-1);
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height
switch (h->sps.bit_depth_luma) {
case 9 :
- s->avctx->pix_fmt = PIX_FMT_YUV420P9;
+ s->avctx->pix_fmt = CHROMA444 ? PIX_FMT_YUV444P9 : PIX_FMT_YUV420P9;
break;
case 10 :
- s->avctx->pix_fmt = PIX_FMT_YUV420P10;
+ s->avctx->pix_fmt = CHROMA444 ? PIX_FMT_YUV444P10 : PIX_FMT_YUV420P10;
break;
default:
- s->avctx->pix_fmt = s->avctx->get_format(s->avctx,
- s->avctx->codec->pix_fmts ?
- s->avctx->codec->pix_fmts :
- s->avctx->color_range == AVCOL_RANGE_JPEG ?
- hwaccel_pixfmt_list_h264_jpeg_420 :
- ff_hwaccel_pixfmt_list_420);
+ if (CHROMA444){
+ s->avctx->pix_fmt = s->avctx->color_range == AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P;
+ }else{
+ s->avctx->pix_fmt = s->avctx->get_format(s->avctx,
+ s->avctx->codec->pix_fmts ?
+ s->avctx->codec->pix_fmts :
+ s->avctx->color_range == AVCOL_RANGE_JPEG ?
+ hwaccel_pixfmt_list_h264_jpeg_420 :
+ ff_hwaccel_pixfmt_list_420);
+ }
}
s->avctx->hwaccel = ff_find_hwaccel(s->avctx->codec->id, s->avctx->pix_fmt);
if(IS_INTRA(mb_type))
return 0;
- AV_COPY64(&h->non_zero_count_cache[0+8*1], &h->non_zero_count[mb_xy][ 0]);
- AV_COPY64(&h->non_zero_count_cache[0+8*2], &h->non_zero_count[mb_xy][ 8]);
- AV_COPY32(&h->non_zero_count_cache[0+8*5], &h->non_zero_count[mb_xy][16]);
- AV_COPY32(&h->non_zero_count_cache[4+8*3], &h->non_zero_count[mb_xy][20]);
- AV_COPY64(&h->non_zero_count_cache[0+8*4], &h->non_zero_count[mb_xy][24]);
+ AV_COPY32(&h->non_zero_count_cache[4+8* 1], &h->non_zero_count[mb_xy][ 0]);
+ AV_COPY32(&h->non_zero_count_cache[4+8* 2], &h->non_zero_count[mb_xy][ 4]);
+ AV_COPY32(&h->non_zero_count_cache[4+8* 3], &h->non_zero_count[mb_xy][ 8]);
+ AV_COPY32(&h->non_zero_count_cache[4+8* 4], &h->non_zero_count[mb_xy][12]);
h->cbp= h->cbp_table[mb_xy];
*/
//FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec)
if(top_type){
- AV_COPY32(&h->non_zero_count_cache[4+8*0], &h->non_zero_count[top_xy][4+3*8]);
+ AV_COPY32(&h->non_zero_count_cache[4+8*0], &h->non_zero_count[top_xy][3*4]);
}
if(left_type[0]){
- h->non_zero_count_cache[3+8*1]= h->non_zero_count[left_xy[0]][7+0*8];
- h->non_zero_count_cache[3+8*2]= h->non_zero_count[left_xy[0]][7+1*8];
- h->non_zero_count_cache[3+8*3]= h->non_zero_count[left_xy[0]][7+2*8];
- h->non_zero_count_cache[3+8*4]= h->non_zero_count[left_xy[0]][7+3*8];
+ h->non_zero_count_cache[3+8*1]= h->non_zero_count[left_xy[0]][3+0*4];
+ h->non_zero_count_cache[3+8*2]= h->non_zero_count[left_xy[0]][3+1*4];
+ h->non_zero_count_cache[3+8*3]= h->non_zero_count[left_xy[0]][3+2*4];
+ h->non_zero_count_cache[3+8*4]= h->non_zero_count[left_xy[0]][3+3*4];
}
// CAVLC 8x8dct requires NNZ values for residual decoding that differ from what the loop filter needs
if(!CABAC && h->pps.transform_8x8_mode){
if(IS_8x8DCT(top_type)){
h->non_zero_count_cache[4+8*0]=
- h->non_zero_count_cache[5+8*0]= h->cbp_table[top_xy] & 4;
+ h->non_zero_count_cache[5+8*0]= (h->cbp_table[top_xy] & 0x4000) >> 12;
h->non_zero_count_cache[6+8*0]=
- h->non_zero_count_cache[7+8*0]= h->cbp_table[top_xy] & 8;
+ h->non_zero_count_cache[7+8*0]= (h->cbp_table[top_xy] & 0x8000) >> 12;
}
if(IS_8x8DCT(left_type[0])){
h->non_zero_count_cache[3+8*1]=
- h->non_zero_count_cache[3+8*2]= h->cbp_table[left_xy[0]]&2; //FIXME check MBAFF
+ h->non_zero_count_cache[3+8*2]= (h->cbp_table[left_xy[0]]&0x2000) >> 12; //FIXME check MBAFF
}
if(IS_8x8DCT(left_type[1])){
h->non_zero_count_cache[3+8*3]=
- h->non_zero_count_cache[3+8*4]= h->cbp_table[left_xy[1]]&8; //FIXME check MBAFF
+ h->non_zero_count_cache[3+8*4]= (h->cbp_table[left_xy[1]]&0x8000) >> 12; //FIXME check MBAFF
}
if(IS_8x8DCT(mb_type)){
h->non_zero_count_cache[scan8[0 ]]= h->non_zero_count_cache[scan8[1 ]]=
- h->non_zero_count_cache[scan8[2 ]]= h->non_zero_count_cache[scan8[3 ]]= h->cbp & 1;
+ h->non_zero_count_cache[scan8[2 ]]= h->non_zero_count_cache[scan8[3 ]]= (h->cbp & 0x1000) >> 12;
h->non_zero_count_cache[scan8[0+ 4]]= h->non_zero_count_cache[scan8[1+ 4]]=
- h->non_zero_count_cache[scan8[2+ 4]]= h->non_zero_count_cache[scan8[3+ 4]]= h->cbp & 2;
+ h->non_zero_count_cache[scan8[2+ 4]]= h->non_zero_count_cache[scan8[3+ 4]]= (h->cbp & 0x2000) >> 12;
h->non_zero_count_cache[scan8[0+ 8]]= h->non_zero_count_cache[scan8[1+ 8]]=
- h->non_zero_count_cache[scan8[2+ 8]]= h->non_zero_count_cache[scan8[3+ 8]]= h->cbp & 4;
+ h->non_zero_count_cache[scan8[2+ 8]]= h->non_zero_count_cache[scan8[3+ 8]]= (h->cbp & 0x4000) >> 12;
h->non_zero_count_cache[scan8[0+12]]= h->non_zero_count_cache[scan8[1+12]]=
- h->non_zero_count_cache[scan8[2+12]]= h->non_zero_count_cache[scan8[3+12]]= h->cbp & 8;
+ h->non_zero_count_cache[scan8[2+12]]= h->non_zero_count_cache[scan8[3+12]]= (h->cbp & 0x8000) >> 12;
}
}
s->mb_x= mb_x;
s->mb_y= mb_y;
dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16;
- dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
- dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
+ dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
+ dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
//FIXME simplify above
if (MB_FIELD) {
linesize = h->mb_linesize = s->linesize;
uvlinesize = h->mb_uvlinesize = s->uvlinesize;
}
- backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0);
+ backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, CHROMA444, 0);
if(fill_filter_caches(h, mb_type))
continue;
h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.qscale_table[mb_xy]);
/* Cabac pre state table */
-static const int8_t cabac_context_init_I[460][2] =
+static const int8_t cabac_context_init_I[1024][2] =
{
/* 0 - 10 */
{ 20, -15 }, { 2, 54 }, { 3, 74 }, { 20, -15 },
{ -10, 73 }, { -10, 70 }, { -10, 69 }, { -5, 66 },
{ -9, 64 }, { -5, 58 }, { 2, 59 }, { 21, -10 },
{ 24, -11 }, { 28, -8 }, { 28, -1 }, { 29, 3 },
- { 29, 9 }, { 35, 20 }, { 29, 36 }, { 14, 67 }
+ { 29, 9 }, { 35, 20 }, { 29, 36 }, { 14, 67 },
+
+ /* 460 -> 1024 */
+ { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
+ { -12, 63 }, { -2, 68 }, { -15, 84 }, { -13, 104 },
+ { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
+ { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
+ { -12, 63 }, { -2, 68 }, { -15, 84 }, { -13, 104 },
+ { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
+ { -7, 93 }, { -11, 87 }, { -3, 77 }, { -5, 71 },
+ { -4, 63 }, { -4, 68 }, { -12, 84 }, { -7, 62 },
+ { -7, 65 }, { 8, 61 }, { 5, 56 }, { -2, 66 },
+ { 1, 64 }, { 0, 61 }, { -2, 78 }, { 1, 50 },
+ { 7, 52 }, { 10, 35 }, { 0, 44 }, { 11, 38 },
+ { 1, 45 }, { 0, 46 }, { 5, 44 }, { 31, 17 },
+ { 1, 51 }, { 7, 50 }, { 28, 19 }, { 16, 33 },
+ { 14, 62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
+ { -13, 91 }, { -12, 94 }, { -10, 88 }, { -16, 84 },
+ { -10, 86 }, { -7, 83 }, { -13, 87 }, { -19, 94 },
+ { 1, 70 }, { 0, 72 }, { -5, 74 }, { 18, 59 },
+ { -7, 93 }, { -11, 87 }, { -3, 77 }, { -5, 71 },
+ { -4, 63 }, { -4, 68 }, { -12, 84 }, { -7, 62 },
+ { -7, 65 }, { 8, 61 }, { 5, 56 }, { -2, 66 },
+ { 1, 64 }, { 0, 61 }, { -2, 78 }, { 1, 50 },
+ { 7, 52 }, { 10, 35 }, { 0, 44 }, { 11, 38 },
+ { 1, 45 }, { 0, 46 }, { 5, 44 }, { 31, 17 },
+ { 1, 51 }, { 7, 50 }, { 28, 19 }, { 16, 33 },
+ { 14, 62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
+ { -13, 91 }, { -12, 94 }, { -10, 88 }, { -16, 84 },
+ { -10, 86 }, { -7, 83 }, { -13, 87 }, { -19, 94 },
+ { 1, 70 }, { 0, 72 }, { -5, 74 }, { 18, 59 },
+ { 24, 0 }, { 15, 9 }, { 8, 25 }, { 13, 18 },
+ { 15, 9 }, { 13, 19 }, { 10, 37 }, { 12, 18 },
+ { 6, 29 }, { 20, 33 }, { 15, 30 }, { 4, 45 },
+ { 1, 58 }, { 0, 62 }, { 7, 61 }, { 12, 38 },
+ { 11, 45 }, { 15, 39 }, { 11, 42 }, { 13, 44 },
+ { 16, 45 }, { 12, 41 }, { 10, 49 }, { 30, 34 },
+ { 18, 42 }, { 10, 55 }, { 17, 51 }, { 17, 46 },
+ { 0, 89 }, { 26, -19 }, { 22, -17 }, { 26, -17 },
+ { 30, -25 }, { 28, -20 }, { 33, -23 }, { 37, -27 },
+ { 33, -23 }, { 40, -28 }, { 38, -17 }, { 33, -11 },
+ { 40, -15 }, { 41, -6 }, { 38, 1 }, { 41, 17 },
+ { 24, 0 }, { 15, 9 }, { 8, 25 }, { 13, 18 },
+ { 15, 9 }, { 13, 19 }, { 10, 37 }, { 12, 18 },
+ { 6, 29 }, { 20, 33 }, { 15, 30 }, { 4, 45 },
+ { 1, 58 }, { 0, 62 }, { 7, 61 }, { 12, 38 },
+ { 11, 45 }, { 15, 39 }, { 11, 42 }, { 13, 44 },
+ { 16, 45 }, { 12, 41 }, { 10, 49 }, { 30, 34 },
+ { 18, 42 }, { 10, 55 }, { 17, 51 }, { 17, 46 },
+ { 0, 89 }, { 26, -19 }, { 22, -17 }, { 26, -17 },
+ { 30, -25 }, { 28, -20 }, { 33, -23 }, { 37, -27 },
+ { 33, -23 }, { 40, -28 }, { 38, -17 }, { 33, -11 },
+ { 40, -15 }, { 41, -6 }, { 38, 1 }, { 41, 17 },
+ { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11, 85 },
+ { -15, 92 }, { -14, 89 }, { -26, 71 }, { -15, 81 },
+ { -14, 80 }, { 0, 68 }, { -14, 70 }, { -24, 56 },
+ { -23, 68 }, { -24, 50 }, { -11, 74 }, { -14, 106 },
+ { -13, 97 }, { -15, 90 }, { -12, 90 }, { -18, 88 },
+ { -10, 73 }, { -9, 79 }, { -14, 86 }, { -10, 73 },
+ { -10, 70 }, { -10, 69 }, { -5, 66 }, { -9, 64 },
+ { -5, 58 }, { 2, 59 }, { 23, -13 }, { 26, -13 },
+ { 40, -15 }, { 49, -14 }, { 44, 3 }, { 45, 6 },
+ { 44, 34 }, { 33, 54 }, { 19, 82 }, { 21, -10 },
+ { 24, -11 }, { 28, -8 }, { 28, -1 }, { 29, 3 },
+ { 29, 9 }, { 35, 20 }, { 29, 36 }, { 14, 67 },
+ { -3, 75 }, { -1, 23 }, { 1, 34 }, { 1, 43 },
+ { 0, 54 }, { -2, 55 }, { 0, 61 }, { 1, 64 },
+ { 0, 68 }, { -9, 92 }, { -17, 120 }, { -20, 112 },
+ { -18, 114 }, { -11, 85 }, { -15, 92 }, { -14, 89 },
+ { -26, 71 }, { -15, 81 }, { -14, 80 }, { 0, 68 },
+ { -14, 70 }, { -24, 56 }, { -23, 68 }, { -24, 50 },
+ { -11, 74 }, { -14, 106 }, { -13, 97 }, { -15, 90 },
+ { -12, 90 }, { -18, 88 }, { -10, 73 }, { -9, 79 },
+ { -14, 86 }, { -10, 73 }, { -10, 70 }, { -10, 69 },
+ { -5, 66 }, { -9, 64 }, { -5, 58 }, { 2, 59 },
+ { 23, -13 }, { 26, -13 }, { 40, -15 }, { 49, -14 },
+ { 44, 3 }, { 45, 6 }, { 44, 34 }, { 33, 54 },
+ { 19, 82 }, { 21, -10 }, { 24, -11 }, { 28, -8 },
+ { 28, -1 }, { 29, 3 }, { 29, 9 }, { 35, 20 },
+ { 29, 36 }, { 14, 67 }, { -3, 75 }, { -1, 23 },
+ { 1, 34 }, { 1, 43 }, { 0, 54 }, { -2, 55 },
+ { 0, 61 }, { 1, 64 }, { 0, 68 }, { -9, 92 },
+ { -6, 93 }, { -6, 84 }, { -8, 79 }, { 0, 66 },
+ { -1, 71 }, { 0, 62 }, { -2, 60 }, { -2, 59 },
+ { -5, 75 }, { -3, 62 }, { -4, 58 }, { -9, 66 },
+ { -1, 79 }, { 0, 71 }, { 3, 68 }, { 10, 44 },
+ { -7, 62 }, { 15, 36 }, { 14, 40 }, { 16, 27 },
+ { 12, 29 }, { 1, 44 }, { 20, 36 }, { 18, 32 },
+ { 5, 42 }, { 1, 48 }, { 10, 62 }, { 17, 46 },
+ { 9, 64 }, { -12, 104 }, { -11, 97 }, { -16, 96 },
+ { -7, 88 }, { -8, 85 }, { -7, 85 }, { -9, 85 },
+ { -13, 88 }, { 4, 66 }, { -3, 77 }, { -3, 76 },
+ { -6, 76 }, { 10, 58 }, { -1, 76 }, { -1, 83 },
+ { -6, 93 }, { -6, 84 }, { -8, 79 }, { 0, 66 },
+ { -1, 71 }, { 0, 62 }, { -2, 60 }, { -2, 59 },
+ { -5, 75 }, { -3, 62 }, { -4, 58 }, { -9, 66 },
+ { -1, 79 }, { 0, 71 }, { 3, 68 }, { 10, 44 },
+ { -7, 62 }, { 15, 36 }, { 14, 40 }, { 16, 27 },
+ { 12, 29 }, { 1, 44 }, { 20, 36 }, { 18, 32 },
+ { 5, 42 }, { 1, 48 }, { 10, 62 }, { 17, 46 },
+ { 9, 64 }, { -12, 104 }, { -11, 97 }, { -16, 96 },
+ { -7, 88 }, { -8, 85 }, { -7, 85 }, { -9, 85 },
+ { -13, 88 }, { 4, 66 }, { -3, 77 }, { -3, 76 },
+ { -6, 76 }, { 10, 58 }, { -1, 76 }, { -1, 83 },
+ { 15, 6 }, { 6, 19 }, { 7, 16 }, { 12, 14 },
+ { 18, 13 }, { 13, 11 }, { 13, 15 }, { 15, 16 },
+ { 12, 23 }, { 13, 23 }, { 15, 20 }, { 14, 26 },
+ { 14, 44 }, { 17, 40 }, { 17, 47 }, { 24, 17 },
+ { 21, 21 }, { 25, 22 }, { 31, 27 }, { 22, 29 },
+ { 19, 35 }, { 14, 50 }, { 10, 57 }, { 7, 63 },
+ { -2, 77 }, { -4, 82 }, { -3, 94 }, { 9, 69 },
+ { -12, 109 }, { 36, -35 }, { 36, -34 }, { 32, -26 },
+ { 37, -30 }, { 44, -32 }, { 34, -18 }, { 34, -15 },
+ { 40, -15 }, { 33, -7 }, { 35, -5 }, { 33, 0 },
+ { 38, 2 }, { 33, 13 }, { 23, 35 }, { 13, 58 },
+ { 15, 6 }, { 6, 19 }, { 7, 16 }, { 12, 14 },
+ { 18, 13 }, { 13, 11 }, { 13, 15 }, { 15, 16 },
+ { 12, 23 }, { 13, 23 }, { 15, 20 }, { 14, 26 },
+ { 14, 44 }, { 17, 40 }, { 17, 47 }, { 24, 17 },
+ { 21, 21 }, { 25, 22 }, { 31, 27 }, { 22, 29 },
+ { 19, 35 }, { 14, 50 }, { 10, 57 }, { 7, 63 },
+ { -2, 77 }, { -4, 82 }, { -3, 94 }, { 9, 69 },
+ { -12, 109 }, { 36, -35 }, { 36, -34 }, { 32, -26 },
+ { 37, -30 }, { 44, -32 }, { 34, -18 }, { 34, -15 },
+ { 40, -15 }, { 33, -7 }, { 35, -5 }, { 33, 0 },
+ { 38, 2 }, { 33, 13 }, { 23, 35 }, { 13, 58 },
+ { -3, 71 }, { -6, 42 }, { -5, 50 }, { -3, 54 },
+ { -2, 62 }, { 0, 58 }, { 1, 63 }, { -2, 72 },
+ { -1, 74 }, { -9, 91 }, { -5, 67 }, { -5, 27 },
+ { -3, 39 }, { -2, 44 }, { 0, 46 }, { -16, 64 },
+ { -8, 68 }, { -10, 78 }, { -6, 77 }, { -10, 86 },
+ { -12, 92 }, { -15, 55 }, { -10, 60 }, { -6, 62 },
+ { -4, 65 }, { -12, 73 }, { -8, 76 }, { -7, 80 },
+ { -9, 88 }, { -17, 110 }, { -3, 71 }, { -6, 42 },
+ { -5, 50 }, { -3, 54 }, { -2, 62 }, { 0, 58 },
+ { 1, 63 }, { -2, 72 }, { -1, 74 }, { -9, 91 },
+ { -5, 67 }, { -5, 27 }, { -3, 39 }, { -2, 44 },
+ { 0, 46 }, { -16, 64 }, { -8, 68 }, { -10, 78 },
+ { -6, 77 }, { -10, 86 }, { -12, 92 }, { -15, 55 },
+ { -10, 60 }, { -6, 62 }, { -4, 65 }, { -12, 73 },
+ { -8, 76 }, { -7, 80 }, { -9, 88 }, { -17, 110 },
+ { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
+ { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
+ { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 }
};
-static const int8_t cabac_context_init_PB[3][460][2] =
+static const int8_t cabac_context_init_PB[3][1024][2] =
{
/* i_cabac_init_idc == 0 */
{
{ -14, 66 }, { 0, 59 }, { 2, 59 }, { 21, -13 },
{ 33, -14 }, { 39, -7 }, { 46, -2 }, { 51, 2 },
{ 60, 6 }, { 61, 17 }, { 55, 34 }, { 42, 62 },
+
+ /* 460 - 1024 */
+ { -7, 92 }, { -5, 89 }, { -7, 96 }, { -13, 108 },
+ { -3, 46 }, { -1, 65 }, { -1, 57 }, { -9, 93 },
+ { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
+ { -7, 92 }, { -5, 89 }, { -7, 96 }, { -13, 108 },
+ { -3, 46 }, { -1, 65 }, { -1, 57 }, { -9, 93 },
+ { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
+ { -2, 85 }, { -6, 78 }, { -1, 75 }, { -7, 77 },
+ { 2, 54 }, { 5, 50 }, { -3, 68 }, { 1, 50 },
+ { 6, 42 }, { -4, 81 }, { 1, 63 }, { -4, 70 },
+ { 0, 67 }, { 2, 57 }, { -2, 76 }, { 11, 35 },
+ { 4, 64 }, { 1, 61 }, { 11, 35 }, { 18, 25 },
+ { 12, 24 }, { 13, 29 }, { 13, 36 }, { -10, 93 },
+ { -7, 73 }, { -2, 73 }, { 13, 46 }, { 9, 49 },
+ { -7, 100 }, { 9, 53 }, { 2, 53 }, { 5, 53 },
+ { -2, 61 }, { 0, 56 }, { 0, 56 }, { -13, 63 },
+ { -5, 60 }, { -1, 62 }, { 4, 57 }, { -6, 69 },
+ { 4, 57 }, { 14, 39 }, { 4, 51 }, { 13, 68 },
+ { -2, 85 }, { -6, 78 }, { -1, 75 }, { -7, 77 },
+ { 2, 54 }, { 5, 50 }, { -3, 68 }, { 1, 50 },
+ { 6, 42 }, { -4, 81 }, { 1, 63 }, { -4, 70 },
+ { 0, 67 }, { 2, 57 }, { -2, 76 }, { 11, 35 },
+ { 4, 64 }, { 1, 61 }, { 11, 35 }, { 18, 25 },
+ { 12, 24 }, { 13, 29 }, { 13, 36 }, { -10, 93 },
+ { -7, 73 }, { -2, 73 }, { 13, 46 }, { 9, 49 },
+ { -7, 100 }, { 9, 53 }, { 2, 53 }, { 5, 53 },
+ { -2, 61 }, { 0, 56 }, { 0, 56 }, { -13, 63 },
+ { -5, 60 }, { -1, 62 }, { 4, 57 }, { -6, 69 },
+ { 4, 57 }, { 14, 39 }, { 4, 51 }, { 13, 68 },
+ { 11, 28 }, { 2, 40 }, { 3, 44 }, { 0, 49 },
+ { 0, 46 }, { 2, 44 }, { 2, 51 }, { 0, 47 },
+ { 4, 39 }, { 2, 62 }, { 6, 46 }, { 0, 54 },
+ { 3, 54 }, { 2, 58 }, { 4, 63 }, { 6, 51 },
+ { 6, 57 }, { 7, 53 }, { 6, 52 }, { 6, 55 },
+ { 11, 45 }, { 14, 36 }, { 8, 53 }, { -1, 82 },
+ { 7, 55 }, { -3, 78 }, { 15, 46 }, { 22, 31 },
+ { -1, 84 }, { 25, 7 }, { 30, -7 }, { 28, 3 },
+ { 28, 4 }, { 32, 0 }, { 34, -1 }, { 30, 6 },
+ { 30, 6 }, { 32, 9 }, { 31, 19 }, { 26, 27 },
+ { 26, 30 }, { 37, 20 }, { 28, 34 }, { 17, 70 },
+ { 11, 28 }, { 2, 40 }, { 3, 44 }, { 0, 49 },
+ { 0, 46 }, { 2, 44 }, { 2, 51 }, { 0, 47 },
+ { 4, 39 }, { 2, 62 }, { 6, 46 }, { 0, 54 },
+ { 3, 54 }, { 2, 58 }, { 4, 63 }, { 6, 51 },
+ { 6, 57 }, { 7, 53 }, { 6, 52 }, { 6, 55 },
+ { 11, 45 }, { 14, 36 }, { 8, 53 }, { -1, 82 },
+ { 7, 55 }, { -3, 78 }, { 15, 46 }, { 22, 31 },
+ { -1, 84 }, { 25, 7 }, { 30, -7 }, { 28, 3 },
+ { 28, 4 }, { 32, 0 }, { 34, -1 }, { 30, 6 },
+ { 30, 6 }, { 32, 9 }, { 31, 19 }, { 26, 27 },
+ { 26, 30 }, { 37, 20 }, { 28, 34 }, { 17, 70 },
+ { -4, 79 }, { -7, 71 }, { -5, 69 }, { -9, 70 },
+ { -8, 66 }, { -10, 68 }, { -19, 73 }, { -12, 69 },
+ { -16, 70 }, { -15, 67 }, { -20, 62 }, { -19, 70 },
+ { -16, 66 }, { -22, 65 }, { -20, 63 }, { -5, 85 },
+ { -6, 81 }, { -10, 77 }, { -7, 81 }, { -17, 80 },
+ { -18, 73 }, { -4, 74 }, { -10, 83 }, { -9, 71 },
+ { -9, 67 }, { -1, 61 }, { -8, 66 }, { -14, 66 },
+ { 0, 59 }, { 2, 59 }, { 9, -2 }, { 26, -9 },
+ { 33, -9 }, { 39, -7 }, { 41, -2 }, { 45, 3 },
+ { 49, 9 }, { 45, 27 }, { 36, 59 }, { 21, -13 },
+ { 33, -14 }, { 39, -7 }, { 46, -2 }, { 51, 2 },
+ { 60, 6 }, { 61, 17 }, { 55, 34 }, { 42, 62 },
+ { -6, 66 }, { -7, 35 }, { -7, 42 }, { -8, 45 },
+ { -5, 48 }, { -12, 56 }, { -6, 60 }, { -5, 62 },
+ { -8, 66 }, { -8, 76 }, { -4, 79 }, { -7, 71 },
+ { -5, 69 }, { -9, 70 }, { -8, 66 }, { -10, 68 },
+ { -19, 73 }, { -12, 69 }, { -16, 70 }, { -15, 67 },
+ { -20, 62 }, { -19, 70 }, { -16, 66 }, { -22, 65 },
+ { -20, 63 }, { -5, 85 }, { -6, 81 }, { -10, 77 },
+ { -7, 81 }, { -17, 80 }, { -18, 73 }, { -4, 74 },
+ { -10, 83 }, { -9, 71 }, { -9, 67 }, { -1, 61 },
+ { -8, 66 }, { -14, 66 }, { 0, 59 }, { 2, 59 },
+ { 9, -2 }, { 26, -9 }, { 33, -9 }, { 39, -7 },
+ { 41, -2 }, { 45, 3 }, { 49, 9 }, { 45, 27 },
+ { 36, 59 }, { 21, -13 }, { 33, -14 }, { 39, -7 },
+ { 46, -2 }, { 51, 2 }, { 60, 6 }, { 61, 17 },
+ { 55, 34 }, { 42, 62 }, { -6, 66 }, { -7, 35 },
+ { -7, 42 }, { -8, 45 }, { -5, 48 }, { -12, 56 },
+ { -6, 60 }, { -5, 62 }, { -8, 66 }, { -8, 76 },
+ { -13, 106 }, { -16, 106 }, { -10, 87 }, { -21, 114 },
+ { -18, 110 }, { -14, 98 }, { -22, 110 }, { -21, 106 },
+ { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
+ { -10, 96 }, { -12, 95 }, { -5, 91 }, { -9, 93 },
+ { -22, 94 }, { -5, 86 }, { 9, 67 }, { -4, 80 },
+ { -10, 85 }, { -1, 70 }, { 7, 60 }, { 9, 58 },
+ { 5, 61 }, { 12, 50 }, { 15, 50 }, { 18, 49 },
+ { 17, 54 }, { 10, 41 }, { 7, 46 }, { -1, 51 },
+ { 7, 49 }, { 8, 52 }, { 9, 41 }, { 6, 47 },
+ { 2, 55 }, { 13, 41 }, { 10, 44 }, { 6, 50 },
+ { 5, 53 }, { 13, 49 }, { 4, 63 }, { 6, 64 },
+ { -13, 106 }, { -16, 106 }, { -10, 87 }, { -21, 114 },
+ { -18, 110 }, { -14, 98 }, { -22, 110 }, { -21, 106 },
+ { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
+ { -10, 96 }, { -12, 95 }, { -5, 91 }, { -9, 93 },
+ { -22, 94 }, { -5, 86 }, { 9, 67 }, { -4, 80 },
+ { -10, 85 }, { -1, 70 }, { 7, 60 }, { 9, 58 },
+ { 5, 61 }, { 12, 50 }, { 15, 50 }, { 18, 49 },
+ { 17, 54 }, { 10, 41 }, { 7, 46 }, { -1, 51 },
+ { 7, 49 }, { 8, 52 }, { 9, 41 }, { 6, 47 },
+ { 2, 55 }, { 13, 41 }, { 10, 44 }, { 6, 50 },
+ { 5, 53 }, { 13, 49 }, { 4, 63 }, { 6, 64 },
+ { 14, 11 }, { 11, 14 }, { 9, 11 }, { 18, 11 },
+ { 21, 9 }, { 23, -2 }, { 32, -15 }, { 32, -15 },
+ { 34, -21 }, { 39, -23 }, { 42, -33 }, { 41, -31 },
+ { 46, -28 }, { 38, -12 }, { 21, 29 }, { 45, -24 },
+ { 53, -45 }, { 48, -26 }, { 65, -43 }, { 43, -19 },
+ { 39, -10 }, { 30, 9 }, { 18, 26 }, { 20, 27 },
+ { 0, 57 }, { -14, 82 }, { -5, 75 }, { -19, 97 },
+ { -35, 125 }, { 27, 0 }, { 28, 0 }, { 31, -4 },
+ { 27, 6 }, { 34, 8 }, { 30, 10 }, { 24, 22 },
+ { 33, 19 }, { 22, 32 }, { 26, 31 }, { 21, 41 },
+ { 26, 44 }, { 23, 47 }, { 16, 65 }, { 14, 71 },
+ { 14, 11 }, { 11, 14 }, { 9, 11 }, { 18, 11 },
+ { 21, 9 }, { 23, -2 }, { 32, -15 }, { 32, -15 },
+ { 34, -21 }, { 39, -23 }, { 42, -33 }, { 41, -31 },
+ { 46, -28 }, { 38, -12 }, { 21, 29 }, { 45, -24 },
+ { 53, -45 }, { 48, -26 }, { 65, -43 }, { 43, -19 },
+ { 39, -10 }, { 30, 9 }, { 18, 26 }, { 20, 27 },
+ { 0, 57 }, { -14, 82 }, { -5, 75 }, { -19, 97 },
+ { -35, 125 }, { 27, 0 }, { 28, 0 }, { 31, -4 },
+ { 27, 6 }, { 34, 8 }, { 30, 10 }, { 24, 22 },
+ { 33, 19 }, { 22, 32 }, { 26, 31 }, { 21, 41 },
+ { 26, 44 }, { 23, 47 }, { 16, 65 }, { 14, 71 },
+ { -6, 76 }, { -2, 44 }, { 0, 45 }, { 0, 52 },
+ { -3, 64 }, { -2, 59 }, { -4, 70 }, { -4, 75 },
+ { -8, 82 }, { -17, 102 }, { -9, 77 }, { 3, 24 },
+ { 0, 42 }, { 0, 48 }, { 0, 55 }, { -6, 59 },
+ { -7, 71 }, { -12, 83 }, { -11, 87 }, { -30, 119 },
+ { 1, 58 }, { -3, 29 }, { -1, 36 }, { 1, 38 },
+ { 2, 43 }, { -6, 55 }, { 0, 58 }, { 0, 64 },
+ { -3, 74 }, { -10, 90 }, { -6, 76 }, { -2, 44 },
+ { 0, 45 }, { 0, 52 }, { -3, 64 }, { -2, 59 },
+ { -4, 70 }, { -4, 75 }, { -8, 82 }, { -17, 102 },
+ { -9, 77 }, { 3, 24 }, { 0, 42 }, { 0, 48 },
+ { 0, 55 }, { -6, 59 }, { -7, 71 }, { -12, 83 },
+ { -11, 87 }, { -30, 119 }, { 1, 58 }, { -3, 29 },
+ { -1, 36 }, { 1, 38 }, { 2, 43 }, { -6, 55 },
+ { 0, 58 }, { 0, 64 }, { -3, 74 }, { -10, 90 },
+ { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
+ { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
+ { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 }
},
/* i_cabac_init_idc == 1 */
{ -9, 60 }, { 1, 54 }, { 2, 58 }, { 17, -10 },
{ 32, -13 }, { 42, -9 }, { 49, -5 }, { 53, 0 },
{ 64, 3 }, { 68, 10 }, { 66, 27 }, { 47, 57 },
+
+ /* 460 - 1024 */
+ { 0, 80 }, { -5, 89 }, { -7, 94 }, { -4, 92 },
+ { 0, 39 }, { 0, 65 }, { -15, 84 }, { -35, 127 },
+ { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
+ { 0, 80 }, { -5, 89 }, { -7, 94 }, { -4, 92 },
+ { 0, 39 }, { 0, 65 }, { -15, 84 }, { -35, 127 },
+ { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
+ { -13, 103 }, { -13, 91 }, { -9, 89 }, { -14, 92 },
+ { -8, 76 }, { -12, 87 }, { -23, 110 }, { -24, 105 },
+ { -10, 78 }, { -20, 112 }, { -17, 99 }, { -78, 127 },
+ { -70, 127 }, { -50, 127 }, { -46, 127 }, { -4, 66 },
+ { -5, 78 }, { -4, 71 }, { -8, 72 }, { 2, 59 },
+ { -1, 55 }, { -7, 70 }, { -6, 75 }, { -8, 89 },
+ { -34, 119 }, { -3, 75 }, { 32, 20 }, { 30, 22 },
+ { -44, 127 }, { 0, 54 }, { -5, 61 }, { 0, 58 },
+ { -1, 60 }, { -3, 61 }, { -8, 67 }, { -25, 84 },
+ { -14, 74 }, { -5, 65 }, { 5, 52 }, { 2, 57 },
+ { 0, 61 }, { -9, 69 }, { -11, 70 }, { 18, 55 },
+ { -13, 103 }, { -13, 91 }, { -9, 89 }, { -14, 92 },
+ { -8, 76 }, { -12, 87 }, { -23, 110 }, { -24, 105 },
+ { -10, 78 }, { -20, 112 }, { -17, 99 }, { -78, 127 },
+ { -70, 127 }, { -50, 127 }, { -46, 127 }, { -4, 66 },
+ { -5, 78 }, { -4, 71 }, { -8, 72 }, { 2, 59 },
+ { -1, 55 }, { -7, 70 }, { -6, 75 }, { -8, 89 },
+ { -34, 119 }, { -3, 75 }, { 32, 20 }, { 30, 22 },
+ { -44, 127 }, { 0, 54 }, { -5, 61 }, { 0, 58 },
+ { -1, 60 }, { -3, 61 }, { -8, 67 }, { -25, 84 },
+ { -14, 74 }, { -5, 65 }, { 5, 52 }, { 2, 57 },
+ { 0, 61 }, { -9, 69 }, { -11, 70 }, { 18, 55 },
+ { 4, 45 }, { 10, 28 }, { 10, 31 }, { 33, -11 },
+ { 52, -43 }, { 18, 15 }, { 28, 0 }, { 35, -22 },
+ { 38, -25 }, { 34, 0 }, { 39, -18 }, { 32, -12 },
+ { 102, -94 }, { 0, 0 }, { 56, -15 }, { 33, -4 },
+ { 29, 10 }, { 37, -5 }, { 51, -29 }, { 39, -9 },
+ { 52, -34 }, { 69, -58 }, { 67, -63 }, { 44, -5 },
+ { 32, 7 }, { 55, -29 }, { 32, 1 }, { 0, 0 },
+ { 27, 36 }, { 33, -25 }, { 34, -30 }, { 36, -28 },
+ { 38, -28 }, { 38, -27 }, { 34, -18 }, { 35, -16 },
+ { 34, -14 }, { 32, -8 }, { 37, -6 }, { 35, 0 },
+ { 30, 10 }, { 28, 18 }, { 26, 25 }, { 29, 41 },
+ { 4, 45 }, { 10, 28 }, { 10, 31 }, { 33, -11 },
+ { 52, -43 }, { 18, 15 }, { 28, 0 }, { 35, -22 },
+ { 38, -25 }, { 34, 0 }, { 39, -18 }, { 32, -12 },
+ { 102, -94 }, { 0, 0 }, { 56, -15 }, { 33, -4 },
+ { 29, 10 }, { 37, -5 }, { 51, -29 }, { 39, -9 },
+ { 52, -34 }, { 69, -58 }, { 67, -63 }, { 44, -5 },
+ { 32, 7 }, { 55, -29 }, { 32, 1 }, { 0, 0 },
+ { 27, 36 }, { 33, -25 }, { 34, -30 }, { 36, -28 },
+ { 38, -28 }, { 38, -27 }, { 34, -18 }, { 35, -16 },
+ { 34, -14 }, { 32, -8 }, { 37, -6 }, { 35, 0 },
+ { 30, 10 }, { 28, 18 }, { 26, 25 }, { 29, 41 },
+ { -5, 85 }, { -6, 81 }, { -10, 77 }, { -7, 81 },
+ { -17, 80 }, { -18, 73 }, { -4, 74 }, { -10, 83 },
+ { -9, 71 }, { -9, 67 }, { -1, 61 }, { -8, 66 },
+ { -14, 66 }, { 0, 59 }, { 2, 59 }, { -3, 81 },
+ { -3, 76 }, { -7, 72 }, { -6, 78 }, { -12, 72 },
+ { -14, 68 }, { -3, 70 }, { -6, 76 }, { -5, 66 },
+ { -5, 62 }, { 0, 57 }, { -4, 61 }, { -9, 60 },
+ { 1, 54 }, { 2, 58 }, { 17, -10 }, { 32, -13 },
+ { 42, -9 }, { 49, -5 }, { 53, 0 }, { 64, 3 },
+ { 68, 10 }, { 66, 27 }, { 47, 57 }, { 17, -10 },
+ { 32, -13 }, { 42, -9 }, { 49, -5 }, { 53, 0 },
+ { 64, 3 }, { 68, 10 }, { 66, 27 }, { 47, 57 },
+ { -5, 71 }, { 0, 24 }, { -1, 36 }, { -2, 42 },
+ { -2, 52 }, { -9, 57 }, { -6, 63 }, { -4, 65 },
+ { -4, 67 }, { -7, 82 }, { -5, 85 }, { -6, 81 },
+ { -10, 77 }, { -7, 81 }, { -17, 80 }, { -18, 73 },
+ { -4, 74 }, { -10, 83 }, { -9, 71 }, { -9, 67 },
+ { -1, 61 }, { -8, 66 }, { -14, 66 }, { 0, 59 },
+ { 2, 59 }, { -3, 81 }, { -3, 76 }, { -7, 72 },
+ { -6, 78 }, { -12, 72 }, { -14, 68 }, { -3, 70 },
+ { -6, 76 }, { -5, 66 }, { -5, 62 }, { 0, 57 },
+ { -4, 61 }, { -9, 60 }, { 1, 54 }, { 2, 58 },
+ { 17, -10 }, { 32, -13 }, { 42, -9 }, { 49, -5 },
+ { 53, 0 }, { 64, 3 }, { 68, 10 }, { 66, 27 },
+ { 47, 57 }, { 17, -10 }, { 32, -13 }, { 42, -9 },
+ { 49, -5 }, { 53, 0 }, { 64, 3 }, { 68, 10 },
+ { 66, 27 }, { 47, 57 }, { -5, 71 }, { 0, 24 },
+ { -1, 36 }, { -2, 42 }, { -2, 52 }, { -9, 57 },
+ { -6, 63 }, { -4, 65 }, { -4, 67 }, { -7, 82 },
+ { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
+ { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
+ { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
+ { -10, 95 }, { -14, 100 }, { -8, 95 }, { -17, 111 },
+ { -28, 114 }, { -6, 89 }, { -2, 80 }, { -4, 82 },
+ { -9, 85 }, { -8, 81 }, { -1, 72 }, { 5, 64 },
+ { 1, 67 }, { 9, 56 }, { 0, 69 }, { 1, 69 },
+ { 7, 69 }, { -7, 69 }, { -6, 67 }, { -16, 77 },
+ { -2, 64 }, { 2, 61 }, { -6, 67 }, { -3, 64 },
+ { 2, 57 }, { -3, 65 }, { -3, 66 }, { 0, 62 },
+ { 9, 51 }, { -1, 66 }, { -2, 71 }, { -2, 75 },
+ { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
+ { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
+ { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
+ { -10, 95 }, { -14, 100 }, { -8, 95 }, { -17, 111 },
+ { -28, 114 }, { -6, 89 }, { -2, 80 }, { -4, 82 },
+ { -9, 85 }, { -8, 81 }, { -1, 72 }, { 5, 64 },
+ { 1, 67 }, { 9, 56 }, { 0, 69 }, { 1, 69 },
+ { 7, 69 }, { -7, 69 }, { -6, 67 }, { -16, 77 },
+ { -2, 64 }, { 2, 61 }, { -6, 67 }, { -3, 64 },
+ { 2, 57 }, { -3, 65 }, { -3, 66 }, { 0, 62 },
+ { 9, 51 }, { -1, 66 }, { -2, 71 }, { -2, 75 },
+ { 19, -6 }, { 18, -6 }, { 14, 0 }, { 26, -12 },
+ { 31, -16 }, { 33, -25 }, { 33, -22 }, { 37, -28 },
+ { 39, -30 }, { 42, -30 }, { 47, -42 }, { 45, -36 },
+ { 49, -34 }, { 41, -17 }, { 32, 9 }, { 69, -71 },
+ { 63, -63 }, { 66, -64 }, { 77, -74 }, { 54, -39 },
+ { 52, -35 }, { 41, -10 }, { 36, 0 }, { 40, -1 },
+ { 30, 14 }, { 28, 26 }, { 23, 37 }, { 12, 55 },
+ { 11, 65 }, { 37, -33 }, { 39, -36 }, { 40, -37 },
+ { 38, -30 }, { 46, -33 }, { 42, -30 }, { 40, -24 },
+ { 49, -29 }, { 38, -12 }, { 40, -10 }, { 38, -3 },
+ { 46, -5 }, { 31, 20 }, { 29, 30 }, { 25, 44 },
+ { 19, -6 }, { 18, -6 }, { 14, 0 }, { 26, -12 },
+ { 31, -16 }, { 33, -25 }, { 33, -22 }, { 37, -28 },
+ { 39, -30 }, { 42, -30 }, { 47, -42 }, { 45, -36 },
+ { 49, -34 }, { 41, -17 }, { 32, 9 }, { 69, -71 },
+ { 63, -63 }, { 66, -64 }, { 77, -74 }, { 54, -39 },
+ { 52, -35 }, { 41, -10 }, { 36, 0 }, { 40, -1 },
+ { 30, 14 }, { 28, 26 }, { 23, 37 }, { 12, 55 },
+ { 11, 65 }, { 37, -33 }, { 39, -36 }, { 40, -37 },
+ { 38, -30 }, { 46, -33 }, { 42, -30 }, { 40, -24 },
+ { 49, -29 }, { 38, -12 }, { 40, -10 }, { 38, -3 },
+ { 46, -5 }, { 31, 20 }, { 29, 30 }, { 25, 44 },
+ { -23, 112 }, { -15, 71 }, { -7, 61 }, { 0, 53 },
+ { -5, 66 }, { -11, 77 }, { -9, 80 }, { -9, 84 },
+ { -10, 87 }, { -34, 127 }, { -21, 101 }, { -3, 39 },
+ { -5, 53 }, { -7, 61 }, { -11, 75 }, { -15, 77 },
+ { -17, 91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
+ { -11, 76 }, { -10, 44 }, { -10, 52 }, { -10, 57 },
+ { -9, 58 }, { -16, 72 }, { -7, 69 }, { -4, 69 },
+ { -5, 74 }, { -9, 86 }, { -23, 112 }, { -15, 71 },
+ { -7, 61 }, { 0, 53 }, { -5, 66 }, { -11, 77 },
+ { -9, 80 }, { -9, 84 }, { -10, 87 }, { -34, 127 },
+ { -21, 101 }, { -3, 39 }, { -5, 53 }, { -7, 61 },
+ { -11, 75 }, { -15, 77 }, { -17, 91 }, { -25, 107 },
+ { -25, 111 }, { -28, 122 }, { -11, 76 }, { -10, 44 },
+ { -10, 52 }, { -10, 57 }, { -9, 58 }, { -16, 72 },
+ { -7, 69 }, { -4, 69 }, { -5, 74 }, { -9, 86 },
+ { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
+ { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
+ { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 }
},
/* i_cabac_init_idc == 2 */
{ -14, 59 }, { -9, 52 }, { -11, 68 }, { 9, -2 },
{ 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 },
{ 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 },
+
+ /* 460 - 1024 */
+ { 11, 80 }, { 5, 76 }, { 2, 84 }, { 5, 78 },
+ { -6, 55 }, { 4, 61 }, { -14, 83 }, { -37, 127 },
+ { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
+ { 11, 80 }, { 5, 76 }, { 2, 84 }, { 5, 78 },
+ { -6, 55 }, { 4, 61 }, { -14, 83 }, { -37, 127 },
+ { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
+ { -4, 86 }, { -12, 88 }, { -5, 82 }, { -3, 72 },
+ { -4, 67 }, { -8, 72 }, { -16, 89 }, { -9, 69 },
+ { -1, 59 }, { 5, 66 }, { 4, 57 }, { -4, 71 },
+ { -2, 71 }, { 2, 58 }, { -1, 74 }, { -4, 44 },
+ { -1, 69 }, { 0, 62 }, { -7, 51 }, { -4, 47 },
+ { -6, 42 }, { -3, 41 }, { -6, 53 }, { 8, 76 },
+ { -9, 78 }, { -11, 83 }, { 9, 52 }, { 0, 67 },
+ { -5, 90 }, { 1, 67 }, { -15, 72 }, { -5, 75 },
+ { -8, 80 }, { -21, 83 }, { -21, 64 }, { -13, 31 },
+ { -25, 64 }, { -29, 94 }, { 9, 75 }, { 17, 63 },
+ { -8, 74 }, { -5, 35 }, { -2, 27 }, { 13, 91 },
+ { -4, 86 }, { -12, 88 }, { -5, 82 }, { -3, 72 },
+ { -4, 67 }, { -8, 72 }, { -16, 89 }, { -9, 69 },
+ { -1, 59 }, { 5, 66 }, { 4, 57 }, { -4, 71 },
+ { -2, 71 }, { 2, 58 }, { -1, 74 }, { -4, 44 },
+ { -1, 69 }, { 0, 62 }, { -7, 51 }, { -4, 47 },
+ { -6, 42 }, { -3, 41 }, { -6, 53 }, { 8, 76 },
+ { -9, 78 }, { -11, 83 }, { 9, 52 }, { 0, 67 },
+ { -5, 90 }, { 1, 67 }, { -15, 72 }, { -5, 75 },
+ { -8, 80 }, { -21, 83 }, { -21, 64 }, { -13, 31 },
+ { -25, 64 }, { -29, 94 }, { 9, 75 }, { 17, 63 },
+ { -8, 74 }, { -5, 35 }, { -2, 27 }, { 13, 91 },
+ { 4, 39 }, { 0, 42 }, { 7, 34 }, { 11, 29 },
+ { 8, 31 }, { 6, 37 }, { 7, 42 }, { 3, 40 },
+ { 8, 33 }, { 13, 43 }, { 13, 36 }, { 4, 47 },
+ { 3, 55 }, { 2, 58 }, { 6, 60 }, { 8, 44 },
+ { 11, 44 }, { 14, 42 }, { 7, 48 }, { 4, 56 },
+ { 4, 52 }, { 13, 37 }, { 9, 49 }, { 19, 58 },
+ { 10, 48 }, { 12, 45 }, { 0, 69 }, { 20, 33 },
+ { 8, 63 }, { 35, -18 }, { 33, -25 }, { 28, -3 },
+ { 24, 10 }, { 27, 0 }, { 34, -14 }, { 52, -44 },
+ { 39, -24 }, { 19, 17 }, { 31, 25 }, { 36, 29 },
+ { 24, 33 }, { 34, 15 }, { 30, 20 }, { 22, 73 },
+ { 4, 39 }, { 0, 42 }, { 7, 34 }, { 11, 29 },
+ { 8, 31 }, { 6, 37 }, { 7, 42 }, { 3, 40 },
+ { 8, 33 }, { 13, 43 }, { 13, 36 }, { 4, 47 },
+ { 3, 55 }, { 2, 58 }, { 6, 60 }, { 8, 44 },
+ { 11, 44 }, { 14, 42 }, { 7, 48 }, { 4, 56 },
+ { 4, 52 }, { 13, 37 }, { 9, 49 }, { 19, 58 },
+ { 10, 48 }, { 12, 45 }, { 0, 69 }, { 20, 33 },
+ { 8, 63 }, { 35, -18 }, { 33, -25 }, { 28, -3 },
+ { 24, 10 }, { 27, 0 }, { 34, -14 }, { 52, -44 },
+ { 39, -24 }, { 19, 17 }, { 31, 25 }, { 36, 29 },
+ { 24, 33 }, { 34, 15 }, { 30, 20 }, { 22, 73 },
+ { -3, 78 }, { -8, 74 }, { -9, 72 }, { -10, 72 },
+ { -18, 75 }, { -12, 71 }, { -11, 63 }, { -5, 70 },
+ { -17, 75 }, { -14, 72 }, { -16, 67 }, { -8, 53 },
+ { -14, 59 }, { -9, 52 }, { -11, 68 }, { -3, 78 },
+ { -8, 74 }, { -9, 72 }, { -10, 72 }, { -18, 75 },
+ { -12, 71 }, { -11, 63 }, { -5, 70 }, { -17, 75 },
+ { -14, 72 }, { -16, 67 }, { -8, 53 }, { -14, 59 },
+ { -9, 52 }, { -11, 68 }, { 9, -2 }, { 30, -10 },
+ { 31, -4 }, { 33, -1 }, { 33, 7 }, { 31, 12 },
+ { 37, 23 }, { 31, 38 }, { 20, 64 }, { 9, -2 },
+ { 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 },
+ { 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 },
+ { -9, 71 }, { -7, 37 }, { -8, 44 }, { -11, 49 },
+ { -10, 56 }, { -12, 59 }, { -8, 63 }, { -9, 67 },
+ { -6, 68 }, { -10, 79 }, { -3, 78 }, { -8, 74 },
+ { -9, 72 }, { -10, 72 }, { -18, 75 }, { -12, 71 },
+ { -11, 63 }, { -5, 70 }, { -17, 75 }, { -14, 72 },
+ { -16, 67 }, { -8, 53 }, { -14, 59 }, { -9, 52 },
+ { -11, 68 }, { -3, 78 }, { -8, 74 }, { -9, 72 },
+ { -10, 72 }, { -18, 75 }, { -12, 71 }, { -11, 63 },
+ { -5, 70 }, { -17, 75 }, { -14, 72 }, { -16, 67 },
+ { -8, 53 }, { -14, 59 }, { -9, 52 }, { -11, 68 },
+ { 9, -2 }, { 30, -10 }, { 31, -4 }, { 33, -1 },
+ { 33, 7 }, { 31, 12 }, { 37, 23 }, { 31, 38 },
+ { 20, 64 }, { 9, -2 }, { 30, -10 }, { 31, -4 },
+ { 33, -1 }, { 33, 7 }, { 31, 12 }, { 37, 23 },
+ { 31, 38 }, { 20, 64 }, { -9, 71 }, { -7, 37 },
+ { -8, 44 }, { -11, 49 }, { -10, 56 }, { -12, 59 },
+ { -8, 63 }, { -9, 67 }, { -6, 68 }, { -10, 79 },
+ { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
+ { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
+ { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
+ { -10, 94 }, { -15, 102 }, { -10, 99 }, { -13, 106 },
+ { -50, 127 }, { -5, 92 }, { 17, 57 }, { -5, 86 },
+ { -13, 94 }, { -12, 91 }, { -2, 77 }, { 0, 71 },
+ { -1, 73 }, { 4, 64 }, { -7, 81 }, { 5, 64 },
+ { 15, 57 }, { 1, 67 }, { 0, 68 }, { -10, 67 },
+ { 1, 68 }, { 0, 77 }, { 2, 64 }, { 0, 68 },
+ { -5, 78 }, { 7, 55 }, { 5, 59 }, { 2, 65 },
+ { 14, 54 }, { 15, 44 }, { 5, 60 }, { 2, 70 },
+ { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
+ { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
+ { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
+ { -10, 94 }, { -15, 102 }, { -10, 99 }, { -13, 106 },
+ { -50, 127 }, { -5, 92 }, { 17, 57 }, { -5, 86 },
+ { -13, 94 }, { -12, 91 }, { -2, 77 }, { 0, 71 },
+ { -1, 73 }, { 4, 64 }, { -7, 81 }, { 5, 64 },
+ { 15, 57 }, { 1, 67 }, { 0, 68 }, { -10, 67 },
+ { 1, 68 }, { 0, 77 }, { 2, 64 }, { 0, 68 },
+ { -5, 78 }, { 7, 55 }, { 5, 59 }, { 2, 65 },
+ { 14, 54 }, { 15, 44 }, { 5, 60 }, { 2, 70 },
+ { 17, -13 }, { 16, -9 }, { 17, -12 }, { 27, -21 },
+ { 37, -30 }, { 41, -40 }, { 42, -41 }, { 48, -47 },
+ { 39, -32 }, { 46, -40 }, { 52, -51 }, { 46, -41 },
+ { 52, -39 }, { 43, -19 }, { 32, 11 }, { 61, -55 },
+ { 56, -46 }, { 62, -50 }, { 81, -67 }, { 45, -20 },
+ { 35, -2 }, { 28, 15 }, { 34, 1 }, { 39, 1 },
+ { 30, 17 }, { 20, 38 }, { 18, 45 }, { 15, 54 },
+ { 0, 79 }, { 36, -16 }, { 37, -14 }, { 37, -17 },
+ { 32, 1 }, { 34, 15 }, { 29, 15 }, { 24, 25 },
+ { 34, 22 }, { 31, 16 }, { 35, 18 }, { 31, 28 },
+ { 33, 41 }, { 36, 28 }, { 27, 47 }, { 21, 62 },
+ { 17, -13 }, { 16, -9 }, { 17, -12 }, { 27, -21 },
+ { 37, -30 }, { 41, -40 }, { 42, -41 }, { 48, -47 },
+ { 39, -32 }, { 46, -40 }, { 52, -51 }, { 46, -41 },
+ { 52, -39 }, { 43, -19 }, { 32, 11 }, { 61, -55 },
+ { 56, -46 }, { 62, -50 }, { 81, -67 }, { 45, -20 },
+ { 35, -2 }, { 28, 15 }, { 34, 1 }, { 39, 1 },
+ { 30, 17 }, { 20, 38 }, { 18, 45 }, { 15, 54 },
+ { 0, 79 }, { 36, -16 }, { 37, -14 }, { 37, -17 },
+ { 32, 1 }, { 34, 15 }, { 29, 15 }, { 24, 25 },
+ { 34, 22 }, { 31, 16 }, { 35, 18 }, { 31, 28 },
+ { 33, 41 }, { 36, 28 }, { 27, 47 }, { 21, 62 },
+ { -24, 115 }, { -22, 82 }, { -9, 62 }, { 0, 53 },
+ { 0, 59 }, { -14, 85 }, { -13, 89 }, { -13, 94 },
+ { -11, 92 }, { -29, 127 }, { -21, 100 }, { -14, 57 },
+ { -12, 67 }, { -11, 71 }, { -10, 77 }, { -21, 85 },
+ { -16, 88 }, { -23, 104 }, { -15, 98 }, { -37, 127 },
+ { -10, 82 }, { -8, 48 }, { -8, 61 }, { -8, 66 },
+ { -7, 70 }, { -14, 75 }, { -10, 79 }, { -9, 83 },
+ { -12, 92 }, { -18, 108 }, { -24, 115 }, { -22, 82 },
+ { -9, 62 }, { 0, 53 }, { 0, 59 }, { -14, 85 },
+ { -13, 89 }, { -13, 94 }, { -11, 92 }, { -29, 127 },
+ { -21, 100 }, { -14, 57 }, { -12, 67 }, { -11, 71 },
+ { -10, 77 }, { -21, 85 }, { -16, 88 }, { -23, 104 },
+ { -15, 98 }, { -37, 127 }, { -10, 82 }, { -8, 48 },
+ { -8, 61 }, { -8, 66 }, { -7, 70 }, { -14, 75 },
+ { -10, 79 }, { -9, 83 }, { -12, 92 }, { -18, 108 },
+ { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
+ { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
+ { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 }
}
};
else tab = cabac_context_init_PB[h->cabac_init_idc];
/* calculate pre-state */
- for( i= 0; i < 460; i++ ) {
+ for( i= 0; i < 1024; i++ ) {
int pre = 2*(((tab[i][0] * slice_qp) >>4 ) + tab[i][1]) - 127;
pre^= pre>>31;
my += decode_cabac_mb_mvd( h, 47, amvd1, &mpy );\
}
-static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx, int is_dc ) {
+static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx, int max_coeff, int is_dc ) {
int nza, nzb;
int ctx = 0;
+ static const uint16_t base_ctx[14] = {85,89,93,97,101,1012,460,464,468,1016,472,476,480,1020};
if( is_dc ) {
- if( cat == 0 ) {
- nza = h->left_cbp&0x100;
- nzb = h-> top_cbp&0x100;
- } else {
+ if( cat == 3 ) {
idx -= CHROMA_DC_BLOCK_INDEX;
nza = (h->left_cbp>>(6+idx))&0x01;
nzb = (h-> top_cbp>>(6+idx))&0x01;
+ } else {
+ idx -= LUMA_DC_BLOCK_INDEX;
+ nza = h->left_cbp&(0x100<<idx);
+ nzb = h-> top_cbp&(0x100<<idx);
}
} else {
- assert(cat == 1 || cat == 2 || cat == 4);
nza = h->non_zero_count_cache[scan8[idx] - 1];
nzb = h->non_zero_count_cache[scan8[idx] - 8];
}
if( nzb > 0 )
ctx += 2;
- return ctx + 4 * cat;
+ return base_ctx[cat] + ctx;
}
DECLARE_ASM_CONST(1, uint8_t, last_coeff_flag_offset_8x8)[63] = {
};
static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff, int is_dc ) {
- static const int significant_coeff_flag_offset[2][6] = {
- { 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
- { 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
+ static const int significant_coeff_flag_offset[2][14] = {
+ { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 },
+ { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 }
};
- static const int last_coeff_flag_offset[2][6] = {
- { 166+0, 166+15, 166+29, 166+44, 166+47, 417 },
- { 338+0, 338+15, 338+29, 338+44, 338+47, 451 }
+ static const int last_coeff_flag_offset[2][14] = {
+ { 166+0, 166+15, 166+29, 166+44, 166+47, 417, 572+0, 572+15, 572+29, 690, 616+0, 616+15, 616+29, 748 },
+ { 338+0, 338+15, 338+29, 338+44, 338+47, 451, 864+0, 864+15, 864+29, 699, 908+0, 908+15, 908+29, 757 }
};
- static const int coeff_abs_level_m1_offset[6] = {
- 227+0, 227+10, 227+20, 227+30, 227+39, 426
+ static const int coeff_abs_level_m1_offset[14] = {
+ 227+0, 227+10, 227+20, 227+30, 227+39, 426, 952+0, 952+10, 952+20, 708, 982+0, 982+10, 982+20, 766
};
static const uint8_t significant_coeff_flag_offset_8x8[2][63] = {
{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
abs_level_m1_ctx_base = h->cabac_state
+ coeff_abs_level_m1_offset[cat];
- if( !is_dc && cat == 5 ) {
+ if( !is_dc && max_coeff == 64 ) {
#define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \
for(last= 0; last < coefs; last++) { \
uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \
}
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS)
- coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, sig_off);
+ coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index,
+ last_coeff_ctx_base-significant_coeff_ctx_base, sig_off);
} else {
- coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index);
+ coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index,
+ last_coeff_ctx_base-significant_coeff_ctx_base);
#else
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] );
} else {
assert(coeff_count > 0);
if( is_dc ) {
- if( cat == 0 )
- h->cbp_table[h->mb_xy] |= 0x100;
- else
+ if( cat == 3 )
h->cbp_table[h->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX);
+ else
+ h->cbp_table[h->mb_xy] |= 0x100 << (n - LUMA_DC_BLOCK_INDEX);
h->non_zero_count_cache[scan8[n]] = coeff_count;
} else {
- if( cat == 5 )
+ if( max_coeff == 64 )
fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
else {
- assert( cat == 1 || cat == 2 || cat == 4 );
+ assert( cat == 1 || cat == 2 || cat == 4 || cat == 7 || cat == 8 || cat == 11 || cat == 12 );
h->non_zero_count_cache[scan8[n]] = coeff_count;
}
}
static av_always_inline void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
/* read coded block flag */
- if( get_cabac( &h->cabac, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, 1 ) ] ) == 0 ) {
+ if( get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 1 ) ] ) == 0 ) {
h->non_zero_count_cache[scan8[n]] = 0;
return;
}
static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
/* read coded block flag */
- if( cat != 5 && get_cabac( &h->cabac, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, 0 ) ] ) == 0 ) {
- h->non_zero_count_cache[scan8[n]] = 0;
+ if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) {
+ if( max_coeff == 64 ) {
+ fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, 0, 1);
+ } else {
+ h->non_zero_count_cache[scan8[n]] = 0;
+ }
return;
}
decode_cabac_residual_nondc_internal( h, block, cat, n, scantable, qmul, max_coeff );
}
+static av_always_inline void decode_cabac_luma_residual( H264Context *h, const uint8_t *scan, const uint8_t *scan8x8, int pixel_shift, int mb_type, int cbp, int p )
+{
+ static const uint8_t ctx_cat[4][3] = {{0,6,10},{1,7,11},{2,8,12},{5,9,13}};
+ const uint32_t *qmul;
+ int i8x8, i4x4;
+ MpegEncContext * const s = &h->s;
+ int qscale = p == 0 ? s->qscale : h->chroma_qp[p-1];
+ if( IS_INTRA16x16( mb_type ) ) {
+ //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" );
+ AV_ZERO128(h->mb_luma_dc[p]+0);
+ AV_ZERO128(h->mb_luma_dc[p]+8);
+ AV_ZERO128(h->mb_luma_dc[p]+16);
+ AV_ZERO128(h->mb_luma_dc[p]+24);
+ decode_cabac_residual_dc(h, h->mb_luma_dc[p], ctx_cat[0][p], LUMA_DC_BLOCK_INDEX+p, scan, 16);
+
+ if( cbp&15 ) {
+ qmul = h->dequant4_coeff[p][qscale];
+ for( i4x4 = 0; i4x4 < 16; i4x4++ ) {
+ const int index = 16*p + i4x4;
+ //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", index );
+ decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), ctx_cat[1][p], index, scan + 1, qmul, 15);
+ }
+ } else {
+ fill_rectangle(&h->non_zero_count_cache[scan8[16*p]], 4, 4, 8, 0, 1);
+ }
+ } else {
+ int cqm = (IS_INTRA( mb_type ) ? 0:3) + p;
+ for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
+ if( cbp & (1<<i8x8) ) {
+ if( IS_8x8DCT(mb_type) ) {
+ const int index = 16*p + 4*i8x8;
+ decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), ctx_cat[3][p], index,
+ scan8x8, h->dequant8_coeff[cqm][qscale], 64);
+ } else {
+ qmul = h->dequant4_coeff[cqm][qscale];
+ for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
+ const int index = 16*p + 4*i8x8 + i4x4;
+ //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
+//START_TIMER
+ decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), ctx_cat[2][p], index, scan, qmul, 16);
+//STOP_TIMER("decode_residual")
+ }
+ }
+ } else {
+ uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8+16*p] ];
+ nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
+ }
+ }
+ }
+}
+
/**
* decodes a macroblock
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
int mb_xy;
int mb_type, partition_count, cbp = 0;
int dct8x8_allowed= h->pps.transform_8x8_mode;
+ int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
const int pixel_shift = h->pixel_shift;
mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
h->slice_table[ mb_xy ]= h->slice_num;
if(IS_INTRA_PCM(mb_type)) {
- const int mb_size = (384*h->sps.bit_depth_luma) >> 3;
+ static const uint16_t mb_sizes[4] = {256,384,512,768};
+ const int mb_size = mb_sizes[h->sps.chroma_format_idc]*h->sps.bit_depth_luma >> 3;
const uint8_t *ptr;
// We assume these blocks are very rare so we do not optimize it.
}
// The pixels are stored in the same order as levels in h->mb array.
- memcpy(h->mb, ptr, 2*mb_size/3); ptr+=2*mb_size/3;
- if(CHROMA){
- memcpy(h->mb+mb_size/3, ptr, mb_size/3); ptr+=mb_size/3;
- }
+ memcpy(h->mb, ptr, mb_size); ptr+=mb_size;
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
// All blocks are present
- h->cbp_table[mb_xy] = 0x1ef;
+ h->cbp_table[mb_xy] = 0xf7ef;
h->chroma_pred_mode_table[mb_xy] = 0;
// In deblocking, the quantizer is 0
s->current_picture.qscale_table[mb_xy]= 0;
// All coeffs are present
- memset(h->non_zero_count[mb_xy], 16, 32);
+ memset(h->non_zero_count[mb_xy], 16, 48);
s->current_picture.mb_type[mb_xy]= mb_type;
h->last_qscale_diff = 0;
return 0;
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode );
if( h->intra16x16_pred_mode < 0 ) return -1;
}
- if(CHROMA){
+ if(decode_chroma){
h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
if( !IS_INTRA16x16( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma( h );
- if(CHROMA)
+ if(decode_chroma)
cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
}
if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline( &h->cabac, &h->cabac_state[399 + h->neighbor_transform_size] );
}
+
+ /* It would be better to do this in fill_decode_caches, but we don't know
+ * the transform mode of the current macroblock there. */
+ if (CHROMA444 && IS_8x8DCT(mb_type)){
+ int i;
+ for (i = 0; i < 2; i++){
+ if (h->left_type[i] && !IS_8x8DCT(h->left_type[i])){
+ h->non_zero_count_cache[3+8* 1 + 2*8*i]=
+ h->non_zero_count_cache[3+8* 2 + 2*8*i]=
+ h->non_zero_count_cache[3+8* 6 + 2*8*i]=
+ h->non_zero_count_cache[3+8* 7 + 2*8*i]=
+ h->non_zero_count_cache[3+8*11 + 2*8*i]=
+ h->non_zero_count_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
+ }
+ }
+ if (h->top_type && !IS_8x8DCT(h->top_type)){
+ uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
+ AV_WN32A(&h->non_zero_count_cache[4+8* 0], top_empty);
+ AV_WN32A(&h->non_zero_count_cache[4+8* 5], top_empty);
+ AV_WN32A(&h->non_zero_count_cache[4+8*10], top_empty);
+ }
+ }
s->current_picture.mb_type[mb_xy]= mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
}else
h->last_qscale_diff=0;
- if( IS_INTRA16x16( mb_type ) ) {
- int i;
- //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" );
- AV_ZERO128(h->mb_luma_dc+0);
- AV_ZERO128(h->mb_luma_dc+8);
- AV_ZERO128(h->mb_luma_dc+16);
- AV_ZERO128(h->mb_luma_dc+24);
- decode_cabac_residual_dc( h, h->mb_luma_dc, 0, LUMA_DC_BLOCK_INDEX, scan, 16);
-
- if( cbp&15 ) {
- qmul = h->dequant4_coeff[0][s->qscale];
- for( i = 0; i < 16; i++ ) {
- //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i );
- decode_cabac_residual_nondc(h, h->mb + (16*i << pixel_shift), 1, i, scan + 1, qmul, 15);
- }
- } else {
- fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
- }
+ decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 0);
+ if(CHROMA444){
+ decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
+ decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2);
} else {
- int i8x8, i4x4;
- for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
- if( cbp & (1<<i8x8) ) {
- if( IS_8x8DCT(mb_type) ) {
- decode_cabac_residual_nondc(h, h->mb + (64*i8x8 << pixel_shift), 5, 4*i8x8,
- scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);
- } else {
- qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale];
- for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
- const int index = 4*i8x8 + i4x4;
- //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
-//START_TIMER
- decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 2, index, scan, qmul, 16);
-//STOP_TIMER("decode_residual")
- }
- }
- } else {
- uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
- nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
+ if( cbp&0x30 ){
+ int c;
+ for( c = 0; c < 2; c++ ) {
+ //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
+ decode_cabac_residual_dc(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
}
}
- }
- if( cbp&0x30 ){
- int c;
- for( c = 0; c < 2; c++ ) {
- //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
- decode_cabac_residual_dc(h, h->mb + ((256 + 16*4*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
- }
- }
-
- if( cbp&0x20 ) {
- int c, i;
- for( c = 0; c < 2; c++ ) {
- qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
- for( i = 0; i < 4; i++ ) {
- const int index = 16 + 4 * c + i;
- //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );
- decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15);
+ if( cbp&0x20 ) {
+ int c, i;
+ for( c = 0; c < 2; c++ ) {
+ qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
+ for( i = 0; i < 4; i++ ) {
+ const int index = 16 + 16 * c + i;
+ //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );
+ decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15);
+ }
}
+ } else {
+ fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
+ fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
}
- } else {
- uint8_t * const nnz= &h->non_zero_count_cache[0];
- nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
- nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
}
} else {
- uint8_t * const nnz= &h->non_zero_count_cache[0];
- fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);
- nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
- nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
+ fill_rectangle(&h->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1);
+ fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
+ fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
h->last_qscale_diff = 0;
}