comparison mpegvideo.c @ 2764:2b37bcabe608 libavcodec

spelling fixes patch by Peter Robinson pbrobinson @ at @ gmail . dot . com and myself
author diego
date Fri, 17 Jun 2005 15:02:53 +0000
parents 9994e07cd45f
children 0a8c847ad5e7
comparison
equal deleted inserted replaced
2763:01ed2c3b8f08 2764:2b37bcabe608
362 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n"); 362 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
363 return -1; 363 return -1;
364 } 364 }
365 365
366 if(pic->linesize[1] != pic->linesize[2]){ 366 if(pic->linesize[1] != pic->linesize[2]){
367 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride missmatch)\n"); 367 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
368 return -1; 368 return -1;
369 } 369 }
370 370
371 s->linesize = pic->linesize[0]; 371 s->linesize = pic->linesize[0];
372 s->uvlinesize= pic->linesize[1]; 372 s->uvlinesize= pic->linesize[1];
540 COPY(qscale); 540 COPY(qscale);
541 COPY(lambda); 541 COPY(lambda);
542 COPY(lambda2); 542 COPY(lambda2);
543 COPY(picture_in_gop_number); 543 COPY(picture_in_gop_number);
544 COPY(gop_picture_number); 544 COPY(gop_picture_number);
545 COPY(frame_pred_frame_dct); //FIXME dont set in encode_header 545 COPY(frame_pred_frame_dct); //FIXME don't set in encode_header
546 COPY(progressive_frame); //FIXME dont set in encode_header 546 COPY(progressive_frame); //FIXME don't set in encode_header
547 COPY(partitioned_frame); //FIXME dont set in encode_header 547 COPY(partitioned_frame); //FIXME don't set in encode_header
548 #undef COPY 548 #undef COPY
549 } 549 }
550 550
551 /** 551 /**
552 * sets the given MpegEncContext to common defaults (same for encoding and decoding). 552 * sets the given MpegEncContext to common defaults (same for encoding and decoding).
1473 } 1473 }
1474 } 1474 }
1475 } 1475 }
1476 alloc: 1476 alloc:
1477 if(!s->encoding){ 1477 if(!s->encoding){
1478 /* release non refernce frames */ 1478 /* release non reference frames */
1479 for(i=0; i<MAX_PICTURE_COUNT; i++){ 1479 for(i=0; i<MAX_PICTURE_COUNT; i++){
1480 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ 1480 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
1481 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); 1481 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
1482 } 1482 }
1483 } 1483 }
1524 if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr); 1524 if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr);
1525 if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr); 1525 if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
1526 1526
1527 if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){ 1527 if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){
1528 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n"); 1528 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
1529 assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference 1529 assert(s->pict_type != B_TYPE); //these should have been dropped if we don't have a reference
1530 goto alloc; 1530 goto alloc;
1531 } 1531 }
1532 1532
1533 assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0])); 1533 assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
1534 1534
1546 } 1546 }
1547 1547
1548 s->hurry_up= s->avctx->hurry_up; 1548 s->hurry_up= s->avctx->hurry_up;
1549 s->error_resilience= avctx->error_resilience; 1549 s->error_resilience= avctx->error_resilience;
1550 1550
1551 /* set dequantizer, we cant do it during init as it might change for mpeg4 1551 /* set dequantizer, we can't do it during init as it might change for mpeg4
1552 and we cant do it in the header decode as init isnt called for mpeg4 there yet */ 1552 and we can't do it in the header decode as init isnt called for mpeg4 there yet */
1553 if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){ 1553 if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){
1554 s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra; 1554 s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
1555 s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter; 1555 s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
1556 }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){ 1556 }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
1557 s->dct_unquantize_intra = s->dct_unquantize_h263_intra; 1557 s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
1606 } 1606 }
1607 assert(i<MAX_PICTURE_COUNT); 1607 assert(i<MAX_PICTURE_COUNT);
1608 #endif 1608 #endif
1609 1609
1610 if(s->encoding){ 1610 if(s->encoding){
1611 /* release non refernce frames */ 1611 /* release non-reference frames */
1612 for(i=0; i<MAX_PICTURE_COUNT; i++){ 1612 for(i=0; i<MAX_PICTURE_COUNT; i++){
1613 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ 1613 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
1614 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); 1614 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
1615 } 1615 }
1616 } 1616 }
2144 2144
2145 for(i=1; i<MAX_PICTURE_COUNT; i++) 2145 for(i=1; i<MAX_PICTURE_COUNT; i++)
2146 s->reordered_input_picture[i-1]= s->reordered_input_picture[i]; 2146 s->reordered_input_picture[i-1]= s->reordered_input_picture[i];
2147 s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL; 2147 s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL;
2148 2148
2149 /* set next picture types & ordering */ 2149 /* set next picture type & ordering */
2150 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ 2150 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
2151 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ 2151 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
2152 s->reordered_input_picture[0]= s->input_picture[0]; 2152 s->reordered_input_picture[0]= s->input_picture[0];
2153 s->reordered_input_picture[0]->pict_type= I_TYPE; 2153 s->reordered_input_picture[0]->pict_type= I_TYPE;
2154 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; 2154 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
2261 s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0; 2261 s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
2262 2262
2263 copy_picture(&s->new_picture, s->reordered_input_picture[0]); 2263 copy_picture(&s->new_picture, s->reordered_input_picture[0]);
2264 2264
2265 if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){ 2265 if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
2266 // input is a shared pix, so we cant modifiy it -> alloc a new one & ensure that the shared one is reuseable 2266 // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable
2267 2267
2268 int i= ff_find_unused_picture(s, 0); 2268 int i= ff_find_unused_picture(s, 0);
2269 Picture *pic= &s->picture[i]; 2269 Picture *pic= &s->picture[i];
2270 2270
2271 /* mark us unused / free shared pic */ 2271 /* mark us unused / free shared pic */
3208 } 3208 }
3209 pix_op[lowres](dest_cr, ptr, s->uvlinesize, block_s, sx, sy); 3209 pix_op[lowres](dest_cr, ptr, s->uvlinesize, block_s, sx, sy);
3210 } 3210 }
3211 3211
3212 /** 3212 /**
3213 * motion compesation of a single macroblock 3213 * motion compensation of a single macroblock
3214 * @param s context 3214 * @param s context
3215 * @param dest_y luma destination pointer 3215 * @param dest_y luma destination pointer
3216 * @param dest_cb chroma cb/u destination pointer 3216 * @param dest_cb chroma cb/u destination pointer
3217 * @param dest_cr chroma cr/v destination pointer 3217 * @param dest_cr chroma cr/v destination pointer
3218 * @param dir direction (0->forward, 1->backward) 3218 * @param dir direction (0->forward, 1->backward)
3457 default: assert(0); 3457 default: assert(0);
3458 } 3458 }
3459 } 3459 }
3460 3460
3461 /** 3461 /**
3462 * motion compesation of a single macroblock 3462 * motion compensation of a single macroblock
3463 * @param s context 3463 * @param s context
3464 * @param dest_y luma destination pointer 3464 * @param dest_y luma destination pointer
3465 * @param dest_cb chroma cb/u destination pointer 3465 * @param dest_cb chroma cb/u destination pointer
3466 * @param dest_cr chroma cr/v destination pointer 3466 * @param dest_cr chroma cr/v destination pointer
3467 * @param dir direction (0->forward, 1->backward) 3467 * @param dir direction (0->forward, 1->backward)
4002 y, s->picture_structure, h); 4002 y, s->picture_structure, h);
4003 } 4003 }
4004 } 4004 }
4005 4005
4006 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename 4006 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
4007 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics 4007 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
4008 const int uvlinesize= s->current_picture.linesize[1]; 4008 const int uvlinesize= s->current_picture.linesize[1];
4009 const int mb_size= 4 - s->avctx->lowres; 4009 const int mb_size= 4 - s->avctx->lowres;
4010 4010
4011 s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2; 4011 s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2;
4012 s->block_index[1]= s->b8_stride*(s->mb_y*2 ) - 1 + s->mb_x*2; 4012 s->block_index[1]= s->b8_stride*(s->mb_y*2 ) - 1 + s->mb_x*2;