[cvs] / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/encoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.134, Sat Dec 18 16:02:00 2010 UTC revision 1.135.2.5, Tue Mar 8 19:18:44 2011 UTC
# Line 1609  Line 1609 
1609                  memcpy((void *)((ptr_t)bs->start + pos),                  memcpy((void *)((ptr_t)bs->start + pos),
1610                             (void *)((ptr_t)pEnc->smpData[k].bs->start), len);                             (void *)((ptr_t)pEnc->smpData[k].bs->start), len);
1611    
1612                  current->length = pos += len;                  current->length += len;
1613                    pos += len;
1614    
1615                  /* collect stats */                  /* collect stats */
1616                  current->sStat.iTextBits += pEnc->smpData[k].sStat->iTextBits;                  current->sStat.iTextBits += pEnc->smpData[k].sStat->iTextBits;
# Line 1645  Line 1646 
1646          int bound = 0, num_slices = pEnc->num_slices;          int bound = 0, num_slices = pEnc->num_slices;
1647          int num_threads = MAX(1, MIN(pEnc->num_threads, num_slices));          int num_threads = MAX(1, MIN(pEnc->num_threads, num_slices));
1648          int slices_per_thread = (num_slices*1024 / num_threads);          int slices_per_thread = (num_slices*1024 / num_threads);
         int mb_width = pEnc->mbParam.mb_width;  
1649          int mb_height = pEnc->mbParam.mb_height;          int mb_height = pEnc->mbParam.mb_height;
1650          void * status = NULL;          void * status = NULL;
1651          uint16_t k;          uint16_t k;
# Line 1755  Line 1755 
1755          FRAMEINFO *const current = pEnc->current;          FRAMEINFO *const current = pEnc->current;
1756          FRAMEINFO *const reference = pEnc->reference;          FRAMEINFO *const reference = pEnc->reference;
1757          MBParam * const pParam = &pEnc->mbParam;          MBParam * const pParam = &pEnc->mbParam;
         IMAGE *pRef = &reference->image;  
1758          int mb_width = pParam->mb_width;          int mb_width = pParam->mb_width;
1759          int mb_height = pParam->mb_height;          int mb_height = pParam->mb_height;
1760    
# Line 1855  Line 1854 
1854                                                  iSAD = sad16(reference->image.y + 16*y*pParam->edged_width + 16*x,                                                  iSAD = sad16(reference->image.y + 16*y*pParam->edged_width + 16*x,
1855                                                                                  pEnc->bframes[k]->image.y + 16*y*pParam->edged_width + 16*x,                                                                                  pEnc->bframes[k]->image.y + 16*y*pParam->edged_width + 16*x,
1856                                                                                  pParam->edged_width, BFRAME_SKIP_THRESHHOLD * pMB->quant);                                                                                  pParam->edged_width, BFRAME_SKIP_THRESHHOLD * pMB->quant);
1857                                                  if (iSAD >= BFRAME_SKIP_THRESHHOLD * pMB->quant) {                                                  if (iSAD >= BFRAME_SKIP_THRESHHOLD * pMB->quant || ((bound > 1) &&
1858                                                            ((y*mb_width+x == bound) || (y*mb_width+x == bound+1)))) { /* Some third-party decoders have problems with coloc skip MB before or after
1859                                                                                                                                                                               resync marker in BVOP. We avoid any ambiguity and force no skip at slice boundary */
1860                                                          bSkip = 0; /* could not SKIP */                                                          bSkip = 0; /* could not SKIP */
1861                                                          if (pParam->vol_flags & XVID_VOL_QUARTERPEL) {                                                          if (pParam->vol_flags & XVID_VOL_QUARTERPEL) {
1862                                                                  VECTOR predMV = get_qpmv2(current->mbs, pParam->mb_width, bound, x, y, 0);                                                                  VECTOR predMV = get_qpmv2(current->mbs, pParam->mb_width, bound, x, y, 0);
# Line 1916  Line 1917 
1917          if (!reference->is_edged) {          if (!reference->is_edged) {
1918                  start_timer();                  start_timer();
1919                  image_setedges(pRef, pParam->edged_width, pParam->edged_height,                  image_setedges(pRef, pParam->edged_width, pParam->edged_height,
1920                                             pParam->width, pParam->height, 0);                                             pParam->width, pParam->height, XVID_BS_VERSION);
1921                  stop_edges_timer();                  stop_edges_timer();
1922                  reference->is_edged = 1;                  reference->is_edged = 1;
1923          }          }
# Line 2129  Line 2130 
2130    
2131          if (current->sStat.kblks + current->sStat.mblks <          if (current->sStat.kblks + current->sStat.mblks <
2132                  (pParam->frame_drop_ratio * mb_width * mb_height) / 100 &&                  (pParam->frame_drop_ratio * mb_width * mb_height) / 100 &&
2133                  ( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) )                  ( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) &&
2134                    (current->coding_type == P_VOP) )
2135          {          {
2136                  current->sStat.kblks = current->sStat.mblks = current->sStat.iTextBits = 0;                  current->sStat.kblks = current->sStat.mblks = current->sStat.iTextBits = 0;
2137                  current->sStat.ublks = mb_width * mb_height;                  current->sStat.ublks = mb_width * mb_height;
# Line 2206  Line 2208 
2208          int num_slices = pEnc->num_slices;          int num_slices = pEnc->num_slices;
2209    
2210          if (data->start_y > 0) { /* write resync marker */          if (data->start_y > 0) { /* write resync marker */
2211                  write_video_packet_header(bs, pParam, frame, bound);                  write_video_packet_header(bs, pParam, frame, bound+1);
2212          }          }
2213    
2214          for (y = data->start_y; y < data->stop_y; y++) {          for (y = data->start_y; y < MIN(data->stop_y+1, mb_height); y++) {
2215                  int new_bound = mb_width * ((((y*num_slices) / mb_height) * mb_height + (num_slices-1)) / num_slices);                  int new_bound = mb_width * ((((y*num_slices) / mb_height) * mb_height + (num_slices-1)) / num_slices);
2216                    int stop_x = (y == data->stop_y) ? 1 : mb_width;
2217                    int start_x = (y == data->start_y && y > 0) ? 1 : 0;
2218    
2219                  if (new_bound > bound) {                  for (x = start_x; x < stop_x; x++) {
                         bound = new_bound;  
                         BitstreamPadAlways(bs);  
                         write_video_packet_header(bs, pParam, frame, bound);  
                 }  
   
                 for (x = 0; x < mb_width; x++) {  
2220                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];
2221    
2222                          /* decoder ignores mb when refence block is INTER(0,0), CBP=0 */                          /* decoder ignores mb when refence block is INTER(0,0), CBP=0 */
# Line 2230  Line 2228 
2228                                  continue;                                  continue;
2229                          }                          }
2230    
2231                            if (new_bound > bound && x > 0) {
2232                                    bound = new_bound;
2233                                    BitstreamPadAlways(bs);
2234                                    write_video_packet_header(bs, pParam, frame, y*mb_width+x);
2235                            }
2236    
2237                          mb->quant = frame->quant;                          mb->quant = frame->quant;
2238    
2239                          if (mb->cbp != 0 || pParam->plugin_flags & XVID_REQORIGINAL) {                          if (mb->cbp != 0 || pParam->plugin_flags & XVID_REQORIGINAL) {
# Line 2281  Line 2285 
2285          IMAGE *b_ref = &pEnc->current->image;          IMAGE *b_ref = &pEnc->current->image;
2286    
2287          MBParam * const pParam = &pEnc->mbParam;          MBParam * const pParam = &pEnc->mbParam;
         int mb_width = pParam->mb_width;  
2288          int mb_height = pParam->mb_height;          int mb_height = pParam->mb_height;
2289    
2290          #ifdef BFRAMES_DEC_DEBUG          #ifdef BFRAMES_DEC_DEBUG
# Line 2300  Line 2303 
2303          if (!pEnc->reference->is_edged) {          if (!pEnc->reference->is_edged) {
2304                  image_setedges(f_ref, pEnc->mbParam.edged_width,                  image_setedges(f_ref, pEnc->mbParam.edged_width,
2305                                             pEnc->mbParam.edged_height, pEnc->mbParam.width,                                             pEnc->mbParam.edged_height, pEnc->mbParam.width,
2306                                             pEnc->mbParam.height, 0);                                             pEnc->mbParam.height, XVID_BS_VERSION);
2307                  pEnc->current->is_edged = 1;                  pEnc->reference->is_edged = 1;
2308          }          }
2309    
2310          if (pEnc->reference->is_interpolated != 0) {          if (pEnc->reference->is_interpolated != 0) {
# Line 2317  Line 2320 
2320          if (!pEnc->current->is_edged) {          if (!pEnc->current->is_edged) {
2321                  image_setedges(b_ref, pEnc->mbParam.edged_width,                  image_setedges(b_ref, pEnc->mbParam.edged_width,
2322                                             pEnc->mbParam.edged_height, pEnc->mbParam.width,                                             pEnc->mbParam.edged_height, pEnc->mbParam.width,
2323                                             pEnc->mbParam.height, 0);                                             pEnc->mbParam.height, XVID_BS_VERSION);
2324                  pEnc->current->is_edged = 1;                  pEnc->current->is_edged = 1;
2325          }          }
2326    
# Line 2332  Line 2335 
2335    
2336          frame->coding_type = B_VOP;          frame->coding_type = B_VOP;
2337    
2338          if (pEnc->current->vop_flags & XVID_VOP_RD_PSNRHVSM) {          if ((frame->vop_flags & XVID_VOP_RD_PSNRHVSM) && (frame->vop_flags & XVID_VOP_RD_BVOP)) {
2339                  image_block_variance(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->current->mbs,                  image_block_variance(&frame->image, pEnc->mbParam.edged_width, frame->mbs,
2340                                       pEnc->mbParam.mb_width, pEnc->mbParam.mb_height);                                       pEnc->mbParam.mb_width, pEnc->mbParam.mb_height);
2341          }          }
2342    
# Line 2406  Line 2409 
2409                                                           pEnc->reference->mbs, f_ref,                                                           pEnc->reference->mbs, f_ref,
2410                                                           &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                                                           &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,
2411                                                           pEnc->current, b_ref, &pEnc->vInterH,                                                           pEnc->current, b_ref, &pEnc->vInterH,
2412                                                           &pEnc->vInterV, &pEnc->vInterHV);                                                           &pEnc->vInterV, &pEnc->vInterHV,
2413                                                             pEnc->num_slices);
2414          }          }
2415          stop_motion_timer();          stop_motion_timer();
2416    

Legend:
Removed from v.1.134  
changed lines
  Added in v.1.135.2.5

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4