Mercurial > libavcodec.hg
comparison utils.c @ 924:3814e9115672 libavcodec
cleanup / messup?
fixes 20% speedloss bug
removes redundant variables from MpegEncContext
release buffers in avcodec_flush_buffers() (untested)
author | michaelni |
---|---|
date | Mon, 09 Dec 2002 00:29:17 +0000 |
parents | 2ac4caad5ca6 |
children | 7fccaa0d699d |
comparison
equal
deleted
inserted
replaced
923:3b5d9ecedc73 | 924:3814e9115672 |
---|---|
123 int avcodec_default_get_buffer(AVCodecContext *s, AVVideoFrame *pic){ | 123 int avcodec_default_get_buffer(AVCodecContext *s, AVVideoFrame *pic){ |
124 int i; | 124 int i; |
125 const int width = s->width; | 125 const int width = s->width; |
126 const int height= s->height; | 126 const int height= s->height; |
127 DefaultPicOpaque *opaque; | 127 DefaultPicOpaque *opaque; |
128 | |
129 assert(pic->data[0]==NULL); | |
130 assert(pic->type==0 || pic->type==FF_TYPE_INTERNAL); | |
128 | 131 |
129 if(pic->opaque){ | 132 if(pic->opaque){ |
130 opaque= (DefaultPicOpaque *)pic->opaque; | 133 opaque= (DefaultPicOpaque *)pic->opaque; |
131 for(i=0; i<3; i++) | 134 for(i=0; i<3; i++) |
132 pic->data[i]= opaque->data[i]; | 135 pic->data[i]= opaque->data[i]; |
184 if(pic->base[i]==NULL) return -1; | 187 if(pic->base[i]==NULL) return -1; |
185 | 188 |
186 memset(pic->base[i], 128, pic->linesize[i]*h>>v_shift); | 189 memset(pic->base[i], 128, pic->linesize[i]*h>>v_shift); |
187 | 190 |
188 if(s->flags&CODEC_FLAG_EMU_EDGE) | 191 if(s->flags&CODEC_FLAG_EMU_EDGE) |
189 pic->data[i] = pic->base[i]; | 192 pic->data[i] = pic->base[i] + 16; //FIXME 16 |
190 else | 193 else |
191 pic->data[i] = pic->base[i] + (pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift); | 194 pic->data[i] = pic->base[i] + (pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift) + 16; //FIXME 16 |
192 | 195 |
193 opaque->data[i]= pic->data[i]; | 196 opaque->data[i]= pic->data[i]; |
194 } | 197 } |
195 pic->age= 256*256*256*64; | 198 pic->age= 256*256*256*64; |
199 pic->type= FF_BUFFER_TYPE_INTERNAL; | |
196 } | 200 } |
197 | 201 |
198 return 0; | 202 return 0; |
199 } | 203 } |
200 | 204 |
201 void avcodec_default_release_buffer(AVCodecContext *s, AVVideoFrame *pic){ | 205 void avcodec_default_release_buffer(AVCodecContext *s, AVVideoFrame *pic){ |
202 int i; | 206 int i; |
207 | |
208 assert(pic->type==FF_BUFFER_TYPE_INTERNAL); | |
203 | 209 |
204 for(i=0; i<3; i++) | 210 for(i=0; i<3; i++) |
205 pic->data[i]=NULL; | 211 pic->data[i]=NULL; |
206 //printf("R%X\n", pic->opaque); | 212 //printf("R%X\n", pic->opaque); |
207 } | 213 } |
640 inited = 1; | 646 inited = 1; |
641 | 647 |
642 //dsputil_init(); | 648 //dsputil_init(); |
643 } | 649 } |
644 | 650 |
645 /* this should be called after seeking and before trying to decode the next frame */ | 651 /* this can be called after seeking and before trying to decode the next keyframe */ |
646 void avcodec_flush_buffers(AVCodecContext *avctx) | 652 void avcodec_flush_buffers(AVCodecContext *avctx) |
647 { | 653 { |
654 int i; | |
648 MpegEncContext *s = avctx->priv_data; | 655 MpegEncContext *s = avctx->priv_data; |
649 s->num_available_buffers=0; | 656 |
650 } | 657 switch(avctx->codec_id){ |
651 | 658 case CODEC_ID_MPEG1VIDEO: |
659 case CODEC_ID_H263: | |
660 case CODEC_ID_RV10: | |
661 case CODEC_ID_MJPEG: | |
662 case CODEC_ID_MJPEGB: | |
663 case CODEC_ID_MPEG4: | |
664 case CODEC_ID_MSMPEG4V1: | |
665 case CODEC_ID_MSMPEG4V2: | |
666 case CODEC_ID_MSMPEG4V3: | |
667 case CODEC_ID_WMV1: | |
668 case CODEC_ID_WMV2: | |
669 case CODEC_ID_H263P: | |
670 case CODEC_ID_H263I: | |
671 case CODEC_ID_SVQ1: | |
672 for(i=0; i<MAX_PICTURE_COUNT; i++){ | |
673 if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL | |
674 || s->picture[i].type == FF_BUFFER_TYPE_USER)) | |
675 avctx->release_buffer(avctx, (AVVideoFrame*)&s->picture[i]); | |
676 } | |
677 break; | |
678 default: | |
679 //FIXME | |
680 break; | |
681 } | |
682 } | |
652 | 683 |
653 static int raw_encode_init(AVCodecContext *s) | 684 static int raw_encode_init(AVCodecContext *s) |
654 { | 685 { |
655 return 0; | 686 return 0; |
656 } | 687 } |