Hi,
On Fri, Mar 16, 2012 at 11:03 AM, Diego Biurrun <[email protected]> wrote:
> +static const uint8_t div6[QP_MAX_NUM + 1] = {
> + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3,
> + 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
> + 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10,10,
Space between "," and "10" at the end.
> #if 0
> @@ -380,37 +447,38 @@ static void await_references(H264Context *h){
> * DCT transforms the 16 dc values.
> * @param qp quantization parameter ??? FIXME
> */
> -static void h264_luma_dc_dct_c(DCTELEM *block/*, int qp*/){
> -// const int qmul= dequant_coeff[qp][0];
> +static void h264_luma_dc_dct_c(DCTELEM *block /*, int qp*/)
> +{
> + // const int qmul= dequant_coeff[qp][0];
> int i;
> - int temp[16]; //FIXME check if this is a good idea
> - static const int x_offset[4]={0, 1*stride, 4* stride, 5*stride};
> - static const int y_offset[4]={0, 2*stride, 8* stride, 10*stride};
> -
> - for(i=0; i<4; i++){
> - const int offset= y_offset[i];
> - const int z0= block[offset+stride*0] + block[offset+stride*4];
> - const int z1= block[offset+stride*0] - block[offset+stride*4];
> - const int z2= block[offset+stride*1] - block[offset+stride*5];
> - const int z3= block[offset+stride*1] + block[offset+stride*5];
> -
> - temp[4*i+0]= z0+z3;
> - temp[4*i+1]= z1+z2;
> - temp[4*i+2]= z1-z2;
> - temp[4*i+3]= z0-z3;
> - }
> -
> - for(i=0; i<4; i++){
> - const int offset= x_offset[i];
> - const int z0= temp[4*0+i] + temp[4*2+i];
> - const int z1= temp[4*0+i] - temp[4*2+i];
> - const int z2= temp[4*1+i] - temp[4*3+i];
> - const int z3= temp[4*1+i] + temp[4*3+i];
> -
> - block[stride*0 +offset]= (z0 + z3)>>1;
> - block[stride*2 +offset]= (z1 + z2)>>1;
> - block[stride*8 +offset]= (z1 - z2)>>1;
> - block[stride*10+offset]= (z0 - z3)>>1;
> + int temp[16]; // FIXME check if this is a good idea
> + static const int x_offset[4] = { 0, 1 * stride, 4 * stride, 5 * stride
> };
> + static const int y_offset[4] = { 0, 2 * stride, 8 * stride, 10 * stride
> };
> +
> + for (i = 0; i < 4; i++) {
> + const int offset = y_offset[i];
> + const int z0 = block[offset + stride * 0] + block[offset +
> stride * 4];
> + const int z1 = block[offset + stride * 0] - block[offset +
> stride * 4];
> + const int z2 = block[offset + stride * 1] - block[offset +
> stride * 5];
> + const int z3 = block[offset + stride * 1] + block[offset +
> stride * 5];
> +
> + temp[4 * i + 0] = z0 + z3;
> + temp[4 * i + 1] = z1 + z2;
> + temp[4 * i + 2] = z1 - z2;
> + temp[4 * i + 3] = z0 - z3;
> + }
> +
> + for (i = 0; i < 4; i++) {
> + const int offset = x_offset[i];
> + const int z0 = temp[4 * 0 + i] + temp[4 * 2 + i];
> + const int z1 = temp[4 * 0 + i] - temp[4 * 2 + i];
> + const int z2 = temp[4 * 1 + i] - temp[4 * 3 + i];
> + const int z3 = temp[4 * 1 + i] + temp[4 * 3 + i];
> +
> + block[stride * 0 + offset] = (z0 + z3) >> 1;
> + block[stride * 2 + offset] = (z1 + z2) >> 1;
> + block[stride * 8 + offset] = (z1 - z2) >> 1;
> + block[stride * 10 + offset] = (z0 - z3) >> 1;
> }
> }
> #endif
> @@ -419,208 +487,236 @@ static void h264_luma_dc_dct_c(DCTELEM *block/*, int
> qp*/){
> #undef stride
>
> #if 0
> -static void chroma_dc_dct_c(DCTELEM *block){
> - const int stride= 16*2;
> - const int xStride= 16;
> - int a,b,c,d,e;
> -
> - a= block[stride*0 + xStride*0];
> - b= block[stride*0 + xStride*1];
> - c= block[stride*1 + xStride*0];
> - d= block[stride*1 + xStride*1];
> -
> - e= a-b;
> - a= a+b;
> - b= c-d;
> - c= c+d;
> -
> - block[stride*0 + xStride*0]= (a+c);
> - block[stride*0 + xStride*1]= (e+b);
> - block[stride*1 + xStride*0]= (a-c);
> - block[stride*1 + xStride*1]= (e-b);
> +static void chroma_dc_dct_c(DCTELEM *block)
> +{
> + const int stride = 16 * 2;
> + const int xStride = 16;
> + int a, b, c, d, e;
> +
> + a = block[stride * 0 + xStride * 0];
> + b = block[stride * 0 + xStride * 1];
> + c = block[stride * 1 + xStride * 0];
> + d = block[stride * 1 + xStride * 1];
> +
> + e = a - b;
> + a = a + b;
> + b = c - d;
> + c = c + d;
> +
> + block[stride * 0 + xStride * 0] = (a + c);
> + block[stride * 0 + xStride * 1] = (e + b);
> + block[stride * 1 + xStride * 0] = (a - c);
> + block[stride * 1 + xStride * 1] = (e - b);
> }
> +
> #endif
Just remove that code.
> +static av_always_inline void mc_part(H264Context *h, int n, int square,
> + int height, int delta,
> + uint8_t *dest_y, uint8_t *dest_cb,
> + uint8_t *dest_cr,
> + 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,
> + h264_weight_func *weight_op,
> + h264_biweight_func *weight_avg,
> + int list0, int list1,
> + int pixel_shift, int chroma_idc)
> {
> - 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)
> + 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)
&& goes on previous line. Same for ||.
> /* Sort B-frames into display order */
>
> - if(h->sps.bitstream_restriction_flag
> - && s->avctx->has_b_frames < h->sps.num_reorder_frames){
> + if (h->sps.bitstream_restriction_flag
> + && s->avctx->has_b_frames < h->sps.num_reorder_frames) {
&& on previous line.
> - if( s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT
> - && !h->sps.bitstream_restriction_flag){
> + if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT
> + && !h->sps.bitstream_restriction_flag) {
Same.
> + if (luma_weight_flag) {
> + h->luma_weight[i][list][0] = get_se_golomb(&s->gb);
> + h->luma_weight[i][list][1] = get_se_golomb(&s->gb);
> + if (h->luma_weight[i][list][0] != luma_def
> + || h->luma_weight[i][list][1] != 0) {
Same.
> + for (j = 0; j < 2; j++) {
> + h->chroma_weight[i][list][j][0] =
> get_se_golomb(&s->gb);
> + h->chroma_weight[i][list][j][1] =
> get_se_golomb(&s->gb);
> + if (h->chroma_weight[i][list][j][0] != chroma_def
> + || h->chroma_weight[i][list][j][1] != 0) {
Same.
> + if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF
> + && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2 * cur_poc)
> {
Same.
> + // printf("poc: %d %d\n", h->poc_msb, h->poc_lsb);
> + field_poc[0] =
> + field_poc[1] = h->poc_msb + h->poc_lsb;
That looks weird.
> - memcpy(dst->short_ref, src->short_ref,
> sizeof(dst->short_ref));
> - memcpy(dst->long_ref, src->long_ref,
> sizeof(dst->long_ref));
> + memcpy(dst->block_offset, src->block_offset, sizeof(dst->block_offset));
[..]
> + memcpy(dst->short_ref, src->short_ref, sizeof(dst->short_ref));
> + memcpy(dst->long_ref, src->long_ref, sizeof(dst->long_ref));
> memcpy(dst->default_ref_list, src->default_ref_list,
> sizeof(dst->default_ref_list));
> - memcpy(dst->ref_list, src->ref_list,
> sizeof(dst->ref_list));
> + memcpy(dst->ref_list, src->ref_list, sizeof(dst->ref_list));
>
> - memcpy(dst->dequant4_coeff, src->dequant4_coeff,
> sizeof(src->dequant4_coeff));
> - memcpy(dst->dequant8_coeff, src->dequant8_coeff,
> sizeof(src->dequant8_coeff));
> + memcpy(dst->dequant4_coeff, src->dequant4_coeff,
> sizeof(src->dequant4_coeff));
> + memcpy(dst->dequant8_coeff, src->dequant8_coeff,
> sizeof(src->dequant8_coeff));
I don't think this looks as good, can you re-do this piece to vertically align?
> if (slice_type == AV_PICTURE_TYPE_I
> - || (h0->current_slice != 0 && slice_type == h0->last_slice_type) ) {
> + || (h0->current_slice != 0 && slice_type == h0->last_slice_type)) {
|| on previous line.
> if (s->context_initialized
> - && ( s->width != s->avctx->width || s->height != s->avctx->height
> + && (s->width != s->avctx->width || s->height != s->avctx->height
> || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {
&& and || on previous line.
> - if( (h->pps.weighted_pred && h->slice_type_nos ==
> AV_PICTURE_TYPE_P )
> - || (h->pps.weighted_bipred_idc==1 && h->slice_type_nos==
> AV_PICTURE_TYPE_B ) )
> + if ((h->pps.weighted_pred && h->slice_type_nos == AV_PICTURE_TYPE_P)
> + || (h->pps.weighted_bipred_idc == 1 &&
|| on previous line.
> - if( s->avctx->skip_loop_filter >= AVDISCARD_ALL
> - ||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
> h->slice_type_nos != AV_PICTURE_TYPE_I)
> - ||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
> h->slice_type_nos == AV_PICTURE_TYPE_B)
> - ||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc
> == 0))
> - h->deblocking_filter= 0;
> + if (s->avctx->skip_loop_filter >= AVDISCARD_ALL
> + || (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
> h->slice_type_nos != AV_PICTURE_TYPE_I)
> + || (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
> h->slice_type_nos == AV_PICTURE_TYPE_B)
> + || (s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc
> == 0))
> + h->deblocking_filter = 0;
Same.
> + h->qp_thresh = 15 + 52
> + - FFMIN(h->slice_alpha_c0_offset,
> + h->slice_beta_offset)
> + - FFMAX3(0,
> + h->pps.chroma_qp_index_offset[0],
> + h->pps.chroma_qp_index_offset[1])
> + + 6 * (h->sps.bit_depth_luma - 8);
+/- on previous line.
> + ref2frm[0] =
> + ref2frm[1] = -1;
> + for (i = 0; i < 16; i++)
> + ref2frm[i + 2] = 4 * id_list[i]
> + + (h->ref_list[j][i].f.reference & 3);
Same.
> + ref2frm[18 + 0] =
> + ref2frm[18 + 1] = -1;
> + for (i = 16; i < 48; i++)
> + ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1]
> + + (h->ref_list[j][i].f.reference & 3);
Same.
> @@ -3243,7 +3569,7 @@ static int decode_slice_header(H264Context *h,
> H264Context *h0){
> int ff_h264_get_slice_type(const H264Context *h)
> {
> switch (h->slice_type) {
> - case AV_PICTURE_TYPE_P: return 0;
> + case AV_PICTURE_TYPE_P : return 0;
> case AV_PICTURE_TYPE_B: return 1;
> case AV_PICTURE_TYPE_I: return 2;
> case AV_PICTURE_TYPE_SP: return 3;
Why?
> -static void predict_field_decoding_flag(H264Context *h){
> - MpegEncContext * const s = &h->s;
> - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
> - int mb_type = (h->slice_table[mb_xy-1] == h->slice_num)
> - ? s->current_picture.f.mb_type[mb_xy - 1]
> - : (h->slice_table[mb_xy-s->mb_stride] == h->slice_num)
> - ? s->current_picture.f.mb_type[mb_xy - s->mb_stride]
> - : 0;
> - h->mb_mbaff = h->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0;
> +static void predict_field_decoding_flag(H264Context *h)
> +{
> + MpegEncContext *const s = &h->s;
> + const int mb_xy = s->mb_x + s->mb_y * s->mb_stride;
> + int mb_type = (h->slice_table[mb_xy - 1] == h->slice_num)
> + ? s->current_picture.f.mb_type[mb_xy - 1]
> + : (h->slice_table[mb_xy - s->mb_stride] ==
> h->slice_num)
> + ? s->current_picture.f.mb_type[mb_xy - s->mb_stride]
> + : 0;
? and : should go on previous line.
Please fix the above and feel free to commit.
Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel