📄 getpic.c
字号:
/* if we are missing the last gob of the previous frame and * the first gob of the current frame, framenum should be * incremented */ /* store the missing GOB number for error concealment */ if (gob - MBA / mb_width < 0) { ++framenum; number_of_mb_rows_missing = (MBAmax - MBA) / mb_width ; }else number_of_mb_rows_missing = gob - MBA / mb_width ; start_mb_row_missing = MBA / mb_width; decode_last_mb = 1; pypos = ypos; } xpos = 0; ypos = gob; MBA = ypos * mb_width; newgob = 1; gobheader_read = 1;//20070702 } } } if (decode_last_mb) { if (!start_mb_row_missing) { /* the first gob is missing, we don't need to decode the last MB */ goto conceal_gob; } else { xpos = 0; ypos = ++pypos; COD = 1; goto reconstruct_mb; } } dont_reconstruct_next_mb = 0;finish_gob: /* SAC specific label */ if (!gobheader_read) { xpos = MBA % mb_width; ypos = MBA / mb_width; if (xpos == 0 && ypos > 0) newgob = 0; } else { gobheader_read = 0; }read_cod: if (syntax_arith_coding) { //20070702 } else { if (PCT_INTER == pict_type || PCT_IPB == pict_type) { COD = showbits (1); if (trace) { fprintf (trace_file, "COD : %d \n", COD); } } else { COD = 0; /* Intra picture -> not skipped */ coded_map[ypos + 1][xpos + 1] = 1; } } if (!COD) { /* COD == 0 --> not skipped */ if (syntax_arith_coding) { //20070702 } else { if (PCT_INTER == pict_type || PCT_IPB == pict_type) { /* flush COD bit */ flushbits (1); } if (PCT_INTRA == pict_type) { MCBPC = getMCBPCintra (); } else { MCBPC = getMCBPC (); } } if (fault) goto resync; if (MCBPC == 255) { /* stuffing - read next COD without advancing MB count. */ goto read_cod; } else { /* normal MB data */ Mode = MCBPC & 7; if (advanced_intra_coding && (Mode == MODE_INTRA || Mode == MODE_INTRA_Q)) { /* get INTRA_AC_DC mode for annex I */ if (syntax_arith_coding) { //20070702 } else { /* using VLC */ if (!showbits (1)) INTRA_AC_DC = getbits (1); else INTRA_AC_DC = getbits (2); } if (trace) fprintf (trace_file, "INTRA_AC_DC: %d\n", INTRA_AC_DC); } /* MODB and CBPB */ if (pb_frame) { CBPB = 0; if (syntax_arith_coding) { //20070702 } else MODB = getMODB (); if ( (MODB == PBMODE_CBPB_MVDB && pb_frame == PB_FRAMES) || (pb_frame == IM_PB_FRAMES && (MODB == PBMODE_CBPB_FRW_PRED || MODB == PBMODE_CBPB_BIDIR_PRED || MODB == PBMODE_CBPB_BCKW_PRED) ) ) { if (syntax_arith_coding) { //20070702 } else CBPB = getbits (6); if (trace) fprintf (trace_file, "CBPB = %d\n", CBPB); } } if (syntax_arith_coding) { //20070702 } else { CBPY = getCBPY (); } } /* Decode Mode and CBP */ if ((Mode == MODE_INTRA || Mode == MODE_INTRA_Q)) { /* Intra */ coded_map[ypos + 1][xpos + 1] = 1; if (!syntax_arith_coding) CBPY = CBPY ^ 15; /* needed in huffman coding only */ } else if (!syntax_arith_coding && alternative_inter_VLC_mode && ((MCBPC >> 4) == 3)) CBPY = CBPY ^ 15; /* Annex S.3 change */ CBP = (CBPY << 2) | (MCBPC >> 4); if ((Mode == MODE_INTER4V || Mode == MODE_INTER4V_Q) && !use_4mv) { fault = 1; if (!quiet) { /* Could set fault-flag and resync */ printf ("8x8 vectors not allowed in normal prediction mode\n"); } if (trace) fprintf (trace_file, "8x8 vectors not allowed in normal prediction mode\n"); } if (Mode == MODE_INTER_Q || Mode == MODE_INTRA_Q || Mode == MODE_INTER4V_Q) { /* Read DQUANT if necessary */ if (syntax_arith_coding) { //20070702 } else { if (!modified_quantization_mode) { DQUANT = getbits (2); quant += DQ_tab[DQUANT]; if (trace) { fprintf (trace_file, "DQUANT ("); printbits (DQUANT, 2, 2); fprintf (trace_file, "): %d = %d\n", DQUANT, DQ_tab[DQUANT]); } } else { tmp = getbits (1); if (tmp) { /* only one more additional bit was sent */ tmp = getbits (1); if (tmp) { /* second bit of quant is 1 */ DQUANT = change_of_quant_tab_11[quant]; } else { /* second bit of quant is 0 */ DQUANT = change_of_quant_tab_10[quant]; } quant += DQUANT; if (trace) { fprintf (trace_file, "DQUANT (1"); printbits (tmp, 1, 1); fprintf (trace_file, "): %d \n", DQUANT); } } else { /* five additional bits were sent as * DQUANT */ DQUANT = getbits (5); quant = DQUANT; if (trace) { fprintf (trace_file, "DQUANT ("); printbits (DQUANT, 5, 5); fprintf (trace_file, "): %d \n", DQUANT); } } } } if (quant > 31 || quant < 1) { if (!quiet) printf ("Quantizer out of range: clipping\n"); quant = mmax (1, mmin (31, quant)); /* could set fault-flag and resync here */ fault = 1; } } /* motion vectors */ if (Mode == MODE_INTER || Mode == MODE_INTER_Q || Mode == MODE_INTER4V || Mode == MODE_INTER4V_Q || pb_frame) { if (Mode == MODE_INTER4V || Mode == MODE_INTER4V_Q) { startmv = 1; stopmv = 4; } else { startmv = 0; stopmv = 0; } for (k = startmv; k <= stopmv; k++) { if (syntax_arith_coding) { //20070702 } else { if (plus_type && long_vectors) { mvx = getRVLC (); mvy = getRVLC (); /* flush start code emulation bit */ if (mvx == 1 && mvy == 1) flushbits(1); } else { mvx = getTMNMV (); mvy = getTMNMV (); } } pmv0 = find_pmv (xpos, ypos, k, 0); pmv1 = find_pmv (xpos, ypos, k, 1); if (plus_type && long_vectors && !syntax_arith_coding) { mvx += pmv0; mvy += pmv1; } else { mvx = motion_decode (mvx, pmv0); mvy = motion_decode (mvy, pmv1); } if (trace) { fprintf (trace_file, "mvx: %d\n", mvx); fprintf (trace_file, "mvy: %d\n", mvy); } /* store coded or not-coded */ coded_map[ypos + 1][xpos + 1] = 1; /* Check mv's to prevent seg.faults when error rate is high */ if (!mv_outside_frame) { bsize = k ? 8 : 16; offset = k ? (((k - 1) & 1) << 3) : 0; /* checking only integer component */ if ((xpos << 4) + (mvx / 2) + offset < 0 || (xpos << 4) + (mvx / 2) + offset > (mb_width << 4) - bsize) { if (!quiet) printf ("mvx out of range: searching for sync\n"); fault = 1; } offset = k ? (((k - 1) & 2) << 2) : 0; if ((ypos << 4) + (mvy / 2) + offset < 0 || (ypos << 4) + (mvy / 2) + offset > (mb_height << 4) - bsize) { if (!quiet) printf ("mvy out of range: searching for sync\n"); fault = 1; } } true_B_direct_mode_MV[0][k][ypos + 1][xpos + 1] = MV[0][k][ypos + 1][xpos + 1] = mvx; true_B_direct_mode_MV[1][k][ypos + 1][xpos + 1] = MV[1][k][ypos + 1][xpos + 1] = mvy; } /* PB frame delta vectors */ if (pb_frame) { if (((MODB == PBMODE_MVDB || MODB == PBMODE_CBPB_MVDB) && pb_frame == PB_FRAMES) || (pb_frame == IM_PB_FRAMES && (MODB == PBMODE_CBPB_FRW_PRED || MODB == PBMODE_FRW_PRED))) { if (syntax_arith_coding) { //20070702 } else { if (plus_type && long_vectors) { mvdbx = getRVLC (); mvdby = getRVLC (); /* flush start code emulation bit */ if (mvdbx == 1 && mvdby == 1) flushbits(1); } else { mvdbx = getTMNMV (); mvdby = getTMNMV (); } } long_vectors_bak = long_vectors; /* turn off long vectors when decoding forward motion vector * of im.pb frames */ pmv0 = 0; pmv1 = 0; if (pb_frame == IM_PB_FRAMES && (MODB == PBMODE_CBPB_FRW_PRED || MODB == PBMODE_FRW_PRED)) { long_vectors = 0; if (MBA % mb_width && (pMODB == PBMODE_CBPB_FRW_PRED || pMODB == PBMODE_FRW_PRED)) { /* MBA%mb_width : if not new gob */ pmv0 = pmvdbx; pmv1 = pmvdby; } } if (plus_type && long_vectors && !syntax_arith_coding) { mvdbx += pmv0; mvdby += pmv1; } else { mvdbx = motion_decode (mvdbx, pmv0); mvdby = motion_decode (mvdby, pmv1); } long_vectors = long_vectors_bak; /* This will not work if the PB deltas are so large they * require the second colums of the motion vector VLC table to * be used. To fix this it is necessary to calculate the MV * predictor for the PB delta: TRB*MV/TRD here, and use this * as the second parameter to motion_decode(). The B vector * itself will then be returned from motion_decode(). This * will have to be changed to the PB delta again, since it is * the PB delta which is used later */ if (trace) { fprintf (trace_file, "MVDB x: %d\n", mvdbx); fprintf (trace_file, "MVDB y: %d\n", mvdby); } } else { mvdbx = 0; mvdby = 0; } } } /* Intra. */ else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -