[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.138, Fri Dec 31 10:17:29 2010 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 2206  Line 2207 
2207          int num_slices = pEnc->num_slices;          int num_slices = pEnc->num_slices;
2208    
2209          if (data->start_y > 0) { /* write resync marker */          if (data->start_y > 0) { /* write resync marker */
2210                  write_video_packet_header(bs, pParam, frame, bound);                  write_video_packet_header(bs, pParam, frame, bound+1);
2211          }          }
2212    
2213          for (y = data->start_y; y < data->stop_y; y++) {          for (y = data->start_y; y < MIN(data->stop_y+1, mb_height); y++) {
2214                  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);
2215                    int stop_x = (y == data->stop_y) ? 1 : mb_width;
2216                    int start_x = (y == data->start_y && y > 0) ? 1 : 0;
2217    
2218                  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++) {  
2219                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];
2220    
2221                          /* 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 2227 
2227                                  continue;                                  continue;
2228                          }                          }
2229    
2230                            if (new_bound > bound && x > 0) {
2231                                    bound = new_bound;
2232                                    BitstreamPadAlways(bs);
2233                                    write_video_packet_header(bs, pParam, frame, y*mb_width+x);
2234                            }
2235    
2236                          mb->quant = frame->quant;                          mb->quant = frame->quant;
2237    
2238                          if (mb->cbp != 0 || pParam->plugin_flags & XVID_REQORIGINAL) {                          if (mb->cbp != 0 || pParam->plugin_flags & XVID_REQORIGINAL) {
# Line 2281  Line 2284 
2284          IMAGE *b_ref = &pEnc->current->image;          IMAGE *b_ref = &pEnc->current->image;
2285    
2286          MBParam * const pParam = &pEnc->mbParam;          MBParam * const pParam = &pEnc->mbParam;
         int mb_width = pParam->mb_width;  
2287          int mb_height = pParam->mb_height;          int mb_height = pParam->mb_height;
2288    
2289          #ifdef BFRAMES_DEC_DEBUG          #ifdef BFRAMES_DEC_DEBUG
# Line 2301  Line 2303 
2303                  image_setedges(f_ref, pEnc->mbParam.edged_width,                  image_setedges(f_ref, pEnc->mbParam.edged_width,
2304                                             pEnc->mbParam.edged_height, pEnc->mbParam.width,                                             pEnc->mbParam.edged_height, pEnc->mbParam.width,
2305                                             pEnc->mbParam.height, 0);                                             pEnc->mbParam.height, 0);
2306                  pEnc->current->is_edged = 1;                  pEnc->reference->is_edged = 1;
2307          }          }
2308    
2309          if (pEnc->reference->is_interpolated != 0) {          if (pEnc->reference->is_interpolated != 0) {
# Line 2332  Line 2334 
2334    
2335          frame->coding_type = B_VOP;          frame->coding_type = B_VOP;
2336    
2337          if (pEnc->current->vop_flags & XVID_VOP_RD_PSNRHVSM) {          if ((frame->vop_flags & XVID_VOP_RD_PSNRHVSM) && (frame->vop_flags & XVID_VOP_RD_BVOP)) {
2338                  image_block_variance(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->current->mbs,                  image_block_variance(&frame->image, pEnc->mbParam.edged_width, frame->mbs,
2339                                       pEnc->mbParam.mb_width, pEnc->mbParam.mb_height);                                       pEnc->mbParam.mb_width, pEnc->mbParam.mb_height);
2340          }          }
2341    
# Line 2406  Line 2408 
2408                                                           pEnc->reference->mbs, f_ref,                                                           pEnc->reference->mbs, f_ref,
2409                                                           &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                                                           &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,
2410                                                           pEnc->current, b_ref, &pEnc->vInterH,                                                           pEnc->current, b_ref, &pEnc->vInterH,
2411                                                           &pEnc->vInterV, &pEnc->vInterHV);                                                           &pEnc->vInterV, &pEnc->vInterHV,
2412                                                             pEnc->num_slices);
2413          }          }
2414          stop_motion_timer();          stop_motion_timer();
2415    

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

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