⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frame.c.svn-base

📁 X264最新源码
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
                int bS[4];  /* filtering strength */                if( b_8x8_transform && (i_edge&1) )                    continue;                mbn_xy  = i_edge > 0 ? mb_xy  : ( i_dir == 0 ? mb_xy  - 1 : mb_xy - h->mb.i_mb_stride );                mbn_8x8 = i_edge > 0 ? mb_8x8 : ( i_dir == 0 ? mb_8x8 - 2 : mb_8x8 - 2 * s8x8 );                mbn_4x4 = i_edge > 0 ? mb_4x4 : ( i_dir == 0 ? mb_4x4 - 4 : mb_4x4 - 4 * s4x4 );                if( b_interlaced && i_edge == 0 && i_dir == 1 )                {                    mbn_xy -= h->mb.i_mb_stride;                    mbn_8x8 -= 2 * s8x8;                    mbn_4x4 -= 4 * s4x4;                }                /* *** Get bS for each 4px for the current edge *** */                if( IS_INTRA( h->mb.type[mb_xy] ) || IS_INTRA( h->mb.type[mbn_xy] ) )                {                    bS[0] = bS[1] = bS[2] = bS[3] = ( i_edge == 0 && !(b_interlaced && i_dir) ? 4 : 3 );                }                else                {                    int i;                    for( i = 0; i < 4; i++ )                    {                        int x  = i_dir == 0 ? i_edge : i;                        int y  = i_dir == 0 ? i      : i_edge;                        int xn = (x - (i_dir == 0 ? 1 : 0 ))&0x03;                        int yn = (y - (i_dir == 0 ? 0 : 1 ))&0x03;                        if( h->mb.non_zero_count[mb_xy][block_idx_xy[x][y]] != 0 ||                            h->mb.non_zero_count[mbn_xy][block_idx_xy[xn][yn]] != 0 )                        {                            bS[i] = 2;                        }                        else                        {                            /* FIXME: A given frame may occupy more than one position in                             * the reference list. So we should compare the frame numbers,                             * not the indices in the ref list.                             * No harm yet, as we don't generate that case.*/                            int i8p= mb_8x8+(x/2)+(y/2)*s8x8;                            int i8q= mbn_8x8+(xn/2)+(yn/2)*s8x8;                            int i4p= mb_4x4+x+y*s4x4;                            int i4q= mbn_4x4+xn+yn*s4x4;                            int l;                            bS[i] = 0;                            for( l = 0; l < 1 + (h->sh.i_type == SLICE_TYPE_B); l++ )                            {                                if( h->mb.ref[l][i8p] != h->mb.ref[l][i8q] ||                                    abs( h->mb.mv[l][i4p][0] - h->mb.mv[l][i4q][0] ) >= 4 ||                                    abs( h->mb.mv[l][i4p][1] - h->mb.mv[l][i4q][1] ) >= mvy_limit )                                {                                    bS[i] = 1;                                    break;                                }                            }                        }                    }                }                /* *** filter *** */                /* Y plane */                i_qp = h->mb.qp[mb_xy];                i_qpn= h->mb.qp[mbn_xy];                if( i_dir == 0 )                {                    /* vertical edge */                    deblock_edge( h, &h->fdec->plane[0][i_pix_y[0] + 4*i_edge],                                  i_stride2[0], bS, (i_qp+i_qpn+1) >> 1, 0,                                  h->loopf.deblock_h_luma, h->loopf.deblock_h_luma_intra );                    if( !(i_edge & 1) )                    {                        /* U/V planes */                        int i_qpc = ( i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )] +                                      i_chroma_qp_table[x264_clip3( i_qpn + h->pps->i_chroma_qp_index_offset, 0, 51 )] + 1 ) >> 1;                        deblock_edge( h, &h->fdec->plane[1][i_pix_y[1] + 2*i_edge],                                      i_stride2[1], bS, i_qpc, 1,                                      h->loopf.deblock_h_chroma, h->loopf.deblock_h_chroma_intra );                        deblock_edge( h, &h->fdec->plane[2][i_pix_y[2] + 2*i_edge],                                      i_stride2[2], bS, i_qpc, 1,                                      h->loopf.deblock_h_chroma, h->loopf.deblock_h_chroma_intra );                    }                }                else                {                    /* horizontal edge */                    deblock_edge( h, &h->fdec->plane[0][i_pix_y[0] + 4*i_edge*i_stride2[0]],                                  i_stride2[0], bS, (i_qp+i_qpn+1) >> 1, 0,                                  h->loopf.deblock_v_luma, h->loopf.deblock_v_luma_intra );                    /* U/V planes */                    if( !(i_edge & 1) )                    {                        int i_qpc = ( i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )] +                                      i_chroma_qp_table[x264_clip3( i_qpn + h->pps->i_chroma_qp_index_offset, 0, 51 )] + 1 ) >> 1;                        deblock_edge( h, &h->fdec->plane[1][i_pix_y[1] + 2*i_edge*i_stride2[1]],                                      i_stride2[1], bS, i_qpc, 1,                                      h->loopf.deblock_v_chroma, h->loopf.deblock_v_chroma_intra );                        deblock_edge( h, &h->fdec->plane[2][i_pix_y[2] + 2*i_edge*i_stride2[2]],                                      i_stride2[2], bS, i_qpc, 1,                                      h->loopf.deblock_v_chroma, h->loopf.deblock_v_chroma_intra );                    }                }            }        }        /* next mb */        if( !b_interlaced || (mb_y&1) )            mb_x++;        mb_y ^= b_interlaced;    }    if( !h->pps->b_cabac && h->pps->b_transform_8x8_mode )        munge_cavlc_nnz( h, mb_y, h->mb.nnz_backup, restore_cavlc_nnz_row );}void x264_frame_deblock( x264_t *h ){    int mb_y;    for( mb_y = 0; mb_y < h->sps->i_mb_height; mb_y += 1 + h->sh.b_mbaff )        x264_frame_deblock_row( h, mb_y );}#ifdef HAVE_MMXvoid x264_deblock_v_chroma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );void x264_deblock_h_chroma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );void x264_deblock_v_chroma_intra_mmxext( uint8_t *pix, int stride, int alpha, int beta );void x264_deblock_h_chroma_intra_mmxext( uint8_t *pix, int stride, int alpha, int beta );#ifdef ARCH_X86_64void x264_deblock_v_luma_sse2( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );void x264_deblock_h_luma_sse2( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );#elsevoid x264_deblock_h_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );void x264_deblock_v8_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );void x264_deblock_v_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ){    x264_deblock_v8_luma_mmxext( pix,   stride, alpha, beta, tc0   );    x264_deblock_v8_luma_mmxext( pix+8, stride, alpha, beta, tc0+2 );}#endif#endif#ifdef ARCH_PPCvoid x264_deblock_v_luma_altivec( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );void x264_deblock_h_luma_altivec( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );#endif // ARCH_PPCvoid x264_deblock_init( int cpu, x264_deblock_function_t *pf ){    pf->deblock_v_luma = deblock_v_luma_c;    pf->deblock_h_luma = deblock_h_luma_c;    pf->deblock_v_chroma = deblock_v_chroma_c;    pf->deblock_h_chroma = deblock_h_chroma_c;    pf->deblock_v_luma_intra = deblock_v_luma_intra_c;    pf->deblock_h_luma_intra = deblock_h_luma_intra_c;    pf->deblock_v_chroma_intra = deblock_v_chroma_intra_c;    pf->deblock_h_chroma_intra = deblock_h_chroma_intra_c;#ifdef HAVE_MMX    if( cpu&X264_CPU_MMXEXT )    {        pf->deblock_v_chroma = x264_deblock_v_chroma_mmxext;        pf->deblock_h_chroma = x264_deblock_h_chroma_mmxext;        pf->deblock_v_chroma_intra = x264_deblock_v_chroma_intra_mmxext;        pf->deblock_h_chroma_intra = x264_deblock_h_chroma_intra_mmxext;#ifdef ARCH_X86_64        if( cpu&X264_CPU_SSE2 )        {            pf->deblock_v_luma = x264_deblock_v_luma_sse2;            pf->deblock_h_luma = x264_deblock_h_luma_sse2;        }#else        pf->deblock_v_luma = x264_deblock_v_luma_mmxext;        pf->deblock_h_luma = x264_deblock_h_luma_mmxext;#endif    }#endif#ifdef ARCH_PPC    if( cpu&X264_CPU_ALTIVEC )    {        pf->deblock_v_luma = x264_deblock_v_luma_altivec;        pf->deblock_h_luma = x264_deblock_h_luma_altivec;   }#endif // ARCH_PPC}/* threading */#ifdef HAVE_PTHREADvoid x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed ){    pthread_mutex_lock( &frame->mutex );    frame->i_lines_completed = i_lines_completed;    pthread_cond_broadcast( &frame->cv );    pthread_mutex_unlock( &frame->mutex );}void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed ){    pthread_mutex_lock( &frame->mutex );    while( frame->i_lines_completed < i_lines_completed )        pthread_cond_wait( &frame->cv, &frame->mutex );    pthread_mutex_unlock( &frame->mutex );}#elsevoid x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed ){}void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed ){}#endif/* list operators */void x264_frame_push( x264_frame_t **list, x264_frame_t *frame ){    int i = 0;    while( list[i] ) i++;    list[i] = frame;}x264_frame_t *x264_frame_pop( x264_frame_t **list ){    x264_frame_t *frame;    int i = 0;    assert( list[0] );    while( list[i+1] ) i++;    frame = list[i];    list[i] = NULL;    return frame;}void x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame ){    int i = 0;    while( list[i] ) i++;    while( i-- )        list[i+1] = list[i];    list[0] = frame;}x264_frame_t *x264_frame_shift( x264_frame_t **list ){    x264_frame_t *frame = list[0];    int i;    for( i = 0; list[i]; i++ )        list[i] = list[i+1];    assert(frame);    return frame;}void x264_frame_push_unused( x264_t *h, x264_frame_t *frame ){    assert( frame->i_reference_count > 0 );    frame->i_reference_count--;    if( frame->i_reference_count == 0 )        x264_frame_push( h->frames.unused, frame );    assert( h->frames.unused[ sizeof(h->frames.unused) / sizeof(*h->frames.unused) - 1 ] == NULL );}x264_frame_t *x264_frame_pop_unused( x264_t *h ){    x264_frame_t *frame;    if( h->frames.unused[0] )        frame = x264_frame_pop( h->frames.unused );    else        frame = x264_frame_new( h );    assert( frame->i_reference_count == 0 );    frame->i_reference_count = 1;    return frame;}void x264_frame_sort( x264_frame_t **list, int b_dts ){    int i, b_ok;    do {        b_ok = 1;        for( i = 0; list[i+1]; i++ )        {            int dtype = list[i]->i_type - list[i+1]->i_type;            int dtime = list[i]->i_frame - list[i+1]->i_frame;            int swap = b_dts ? dtype > 0 || ( dtype == 0 && dtime > 0 )                             : dtime > 0;            if( swap )            {                XCHG( x264_frame_t*, list[i], list[i+1] );                b_ok = 0;            }        }    } while( !b_ok );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -