Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1021:2d7c9f5738de libavcodec
trying to fix mb skip bug in mpeg1/2 if slices are not used
author | michaelni |
---|---|
date | Mon, 20 Jan 2003 20:37:24 +0000 |
parents | 48349e11c9b2 |
children | d6ba0641cc36 |
comparison
equal
deleted
inserted
replaced
1020:617e3531d3fb | 1021:2d7c9f5738de |
---|---|
18 * | 18 * |
19 * 4MV & hq & b-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> | 19 * 4MV & hq & b-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> |
20 */ | 20 */ |
21 | 21 |
22 #include <ctype.h> | 22 #include <ctype.h> |
23 #include <limits.h> | |
23 #include "avcodec.h" | 24 #include "avcodec.h" |
24 #include "dsputil.h" | 25 #include "dsputil.h" |
25 #include "mpegvideo.h" | 26 #include "mpegvideo.h" |
26 #include "simple_idct.h" | 27 #include "simple_idct.h" |
27 | 28 |
320 CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(UINT8)+1) //the +1 is for the slice end check | 321 CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(UINT8)+1) //the +1 is for the slice end check |
321 CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(UINT8)) | 322 CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(UINT8)) |
322 pic->qstride= s->mb_width; | 323 pic->qstride= s->mb_width; |
323 } | 324 } |
324 | 325 |
326 //it might be nicer if the application would keep track of these but it would require a API change | |
327 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); | |
328 s->prev_pict_types[0]= s->pict_type; | |
329 if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == B_TYPE) | |
330 pic->age= INT_MAX; // skiped MBs in b frames are quite rare in mpeg1/2 and its a bit tricky to skip them anyway | |
331 | |
325 return 0; | 332 return 0; |
326 fail: //for the CHECKED_ALLOCZ macro | 333 fail: //for the CHECKED_ALLOCZ macro |
327 return -1; | 334 return -1; |
328 } | 335 } |
329 | 336 |
477 s->picture_structure = PICT_FRAME; | 484 s->picture_structure = PICT_FRAME; |
478 | 485 |
479 /* init macroblock skip table */ | 486 /* init macroblock skip table */ |
480 CHECKED_ALLOCZ(s->mbskip_table, s->mb_num+1); | 487 CHECKED_ALLOCZ(s->mbskip_table, s->mb_num+1); |
481 //Note the +1 is for a quicker mpeg4 slice_end detection | 488 //Note the +1 is for a quicker mpeg4 slice_end detection |
489 CHECKED_ALLOCZ(s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE); | |
482 | 490 |
483 s->block= s->blocks[0]; | 491 s->block= s->blocks[0]; |
484 | 492 |
485 s->parse_context.state= -1; | 493 s->parse_context.state= -1; |
486 | 494 |
516 av_freep(&s->me.scratchpad); | 524 av_freep(&s->me.scratchpad); |
517 av_freep(&s->me.map); | 525 av_freep(&s->me.map); |
518 av_freep(&s->me.score_map); | 526 av_freep(&s->me.score_map); |
519 | 527 |
520 av_freep(&s->mbskip_table); | 528 av_freep(&s->mbskip_table); |
529 av_freep(&s->prev_pict_types); | |
521 av_freep(&s->bitstream_buffer); | 530 av_freep(&s->bitstream_buffer); |
522 av_freep(&s->tex_pb_buffer); | 531 av_freep(&s->tex_pb_buffer); |
523 av_freep(&s->pb2_buffer); | 532 av_freep(&s->pb2_buffer); |
524 av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL; | 533 av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL; |
525 av_freep(&s->co_located_type_table); | 534 av_freep(&s->co_located_type_table); |
2014 | 2023 |
2015 (*mbskip_ptr) ++; /* indicate that this time we skiped it */ | 2024 (*mbskip_ptr) ++; /* indicate that this time we skiped it */ |
2016 if(*mbskip_ptr >99) *mbskip_ptr= 99; | 2025 if(*mbskip_ptr >99) *mbskip_ptr= 99; |
2017 | 2026 |
2018 /* if previous was skipped too, then nothing to do ! */ | 2027 /* if previous was skipped too, then nothing to do ! */ |
2019 if (*mbskip_ptr >= age){ | 2028 if (*mbskip_ptr >= age && s->current_picture.reference){ |
2020 //if(s->pict_type!=B_TYPE && s->mb_x==0) printf("\n"); | 2029 return; |
2021 //if(s->pict_type!=B_TYPE) printf("%d%d ", *mbskip_ptr, age); | 2030 } |
2022 if(s->pict_type!=B_TYPE) return; | 2031 } else if(!s->current_picture.reference){ |
2023 if(s->avctx->draw_horiz_band==NULL && *mbskip_ptr > age) return; | 2032 (*mbskip_ptr) ++; /* increase counter so the age can be compared cleanly */ |
2024 /* we dont draw complete frames here so we cant skip */ | 2033 if(*mbskip_ptr >99) *mbskip_ptr= 99; |
2025 } | 2034 } else{ |
2026 } else { | |
2027 *mbskip_ptr = 0; /* not skipped */ | 2035 *mbskip_ptr = 0; /* not skipped */ |
2028 } | 2036 } |
2029 }else | 2037 }else |
2030 s->mb_skiped= 0; | 2038 s->mb_skiped= 0; |
2031 | 2039 |