Mercurial > libavcodec.hg
comparison mpegvideo.c @ 925:7fccaa0d699d libavcodec
AVVideoFrame -> AVFrame
author | michaelni |
---|---|
date | Mon, 09 Dec 2002 12:03:43 +0000 |
parents | 3814e9115672 |
children | 6bcb214d6a17 |
comparison
equal
deleted
inserted
replaced
924:3814e9115672 | 925:7fccaa0d699d |
---|---|
280 }else{ | 280 }else{ |
281 int r; | 281 int r; |
282 | 282 |
283 assert(!pic->data[0]); | 283 assert(!pic->data[0]); |
284 | 284 |
285 r= s->avctx->get_buffer(s->avctx, (AVVideoFrame*)pic); | 285 r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic); |
286 | 286 |
287 if(r<0 || !pic->age || !pic->type || !pic->data[0]){ | 287 if(r<0 || !pic->age || !pic->type || !pic->data[0]){ |
288 fprintf(stderr, "get_buffer() failed (%d %d %d %X)\n", r, pic->age, pic->type, (int)pic->data[0]); | 288 fprintf(stderr, "get_buffer() failed (%d %d %d %X)\n", r, pic->age, pic->type, (int)pic->data[0]); |
289 return -1; | 289 return -1; |
290 } | 290 } |
325 */ | 325 */ |
326 static void free_picture(MpegEncContext *s, Picture *pic){ | 326 static void free_picture(MpegEncContext *s, Picture *pic){ |
327 int i; | 327 int i; |
328 | 328 |
329 if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){ | 329 if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){ |
330 s->avctx->release_buffer(s->avctx, (AVVideoFrame*)pic); | 330 s->avctx->release_buffer(s->avctx, (AVFrame*)pic); |
331 } | 331 } |
332 | 332 |
333 av_freep(&pic->mb_var); | 333 av_freep(&pic->mb_var); |
334 av_freep(&pic->mc_mb_var); | 334 av_freep(&pic->mc_mb_var); |
335 av_freep(&pic->mb_mean); | 335 av_freep(&pic->mb_mean); |
381 + (toupper((s->avctx->fourcc>>16)&0xFF)<<16) | 381 + (toupper((s->avctx->fourcc>>16)&0xFF)<<16) |
382 + (toupper((s->avctx->fourcc>>24)&0xFF)<<24); | 382 + (toupper((s->avctx->fourcc>>24)&0xFF)<<24); |
383 | 383 |
384 CHECKED_ALLOCZ(s->edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance | 384 CHECKED_ALLOCZ(s->edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance |
385 | 385 |
386 s->avctx->coded_picture= (AVVideoFrame*)&s->current_picture; | 386 s->avctx->coded_frame= (AVFrame*)&s->current_picture; |
387 | 387 |
388 if (s->encoding) { | 388 if (s->encoding) { |
389 int mv_table_size= (s->mb_width+2)*(s->mb_height+2); | 389 int mv_table_size= (s->mb_width+2)*(s->mb_height+2); |
390 | 390 |
391 /* Allocate MV tables */ | 391 /* Allocate MV tables */ |
841 | 841 |
842 /* generic function for encode/decode called before a frame is coded/decoded */ | 842 /* generic function for encode/decode called before a frame is coded/decoded */ |
843 int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) | 843 int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) |
844 { | 844 { |
845 int i; | 845 int i; |
846 AVVideoFrame *pic; | 846 AVFrame *pic; |
847 | 847 |
848 s->mb_skiped = 0; | 848 s->mb_skiped = 0; |
849 | 849 |
850 /* mark&release old frames */ | 850 /* mark&release old frames */ |
851 if (s->pict_type != B_TYPE && s->last_picture.data[0]) { | 851 if (s->pict_type != B_TYPE && s->last_picture.data[0]) { |
852 for(i=0; i<MAX_PICTURE_COUNT; i++){ | 852 for(i=0; i<MAX_PICTURE_COUNT; i++){ |
853 //printf("%8X %d %d %X %X\n", s->picture[i].data[0], s->picture[i].type, i, s->next_picture.data[0], s->last_picture.data[0]); | 853 //printf("%8X %d %d %X %X\n", s->picture[i].data[0], s->picture[i].type, i, s->next_picture.data[0], s->last_picture.data[0]); |
854 if(s->picture[i].data[0] == s->last_picture.data[0]){ | 854 if(s->picture[i].data[0] == s->last_picture.data[0]){ |
855 // s->picture[i].reference=0; | 855 // s->picture[i].reference=0; |
856 avctx->release_buffer(avctx, (AVVideoFrame*)&s->picture[i]); | 856 avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]); |
857 break; | 857 break; |
858 } | 858 } |
859 } | 859 } |
860 assert(i<MAX_PICTURE_COUNT); | 860 assert(i<MAX_PICTURE_COUNT); |
861 | 861 |
863 /* if(mpeg124/h263) */ | 863 /* if(mpeg124/h263) */ |
864 if(!s->encoding){ | 864 if(!s->encoding){ |
865 for(i=0; i<MAX_PICTURE_COUNT; i++){ | 865 for(i=0; i<MAX_PICTURE_COUNT; i++){ |
866 if(s->picture[i].data[0] && s->picture[i].data[0] != s->next_picture.data[0] && s->picture[i].reference){ | 866 if(s->picture[i].data[0] && s->picture[i].data[0] != s->next_picture.data[0] && s->picture[i].reference){ |
867 fprintf(stderr, "releasing zombie picture\n"); | 867 fprintf(stderr, "releasing zombie picture\n"); |
868 avctx->release_buffer(avctx, (AVVideoFrame*)&s->picture[i]); | 868 avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]); |
869 } | 869 } |
870 } | 870 } |
871 } | 871 } |
872 } | 872 } |
873 alloc: | 873 alloc: |
874 if(!s->encoding){ | 874 if(!s->encoding){ |
875 i= find_unused_picture(s, 0); | 875 i= find_unused_picture(s, 0); |
876 | 876 |
877 pic= (AVVideoFrame*)&s->picture[i]; | 877 pic= (AVFrame*)&s->picture[i]; |
878 pic->reference= s->pict_type != B_TYPE; | 878 pic->reference= s->pict_type != B_TYPE; |
879 pic->coded_picture_number= s->current_picture.coded_picture_number+1; | 879 pic->coded_picture_number= s->current_picture.coded_picture_number+1; |
880 | 880 |
881 alloc_picture(s, (Picture*)pic, 0); | 881 alloc_picture(s, (Picture*)pic, 0); |
882 | 882 |
944 assert(i<MAX_PICTURE_COUNT); | 944 assert(i<MAX_PICTURE_COUNT); |
945 | 945 |
946 /* release non refernce frames */ | 946 /* release non refernce frames */ |
947 for(i=0; i<MAX_PICTURE_COUNT; i++){ | 947 for(i=0; i<MAX_PICTURE_COUNT; i++){ |
948 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/) | 948 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/) |
949 s->avctx->release_buffer(s->avctx, (AVVideoFrame*)&s->picture[i]); | 949 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); |
950 } | 950 } |
951 } | 951 } |
952 | 952 |
953 static int get_sae(uint8_t *src, int ref, int stride){ | 953 static int get_sae(uint8_t *src, int ref, int stride){ |
954 int x,y; | 954 int x,y; |
982 } | 982 } |
983 return acc; | 983 return acc; |
984 } | 984 } |
985 | 985 |
986 | 986 |
987 static int load_input_picture(MpegEncContext *s, AVVideoFrame *pic_arg){ | 987 static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){ |
988 AVVideoFrame *pic; | 988 AVFrame *pic; |
989 int i; | 989 int i; |
990 const int encoding_delay= s->max_b_frames; | 990 const int encoding_delay= s->max_b_frames; |
991 int direct=1; | 991 int direct=1; |
992 | 992 |
993 if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0; | 993 if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0; |
998 // printf("%d %d %d %d\n",pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize); | 998 // printf("%d %d %d %d\n",pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize); |
999 | 999 |
1000 if(direct){ | 1000 if(direct){ |
1001 i= find_unused_picture(s, 1); | 1001 i= find_unused_picture(s, 1); |
1002 | 1002 |
1003 pic= (AVVideoFrame*)&s->picture[i]; | 1003 pic= (AVFrame*)&s->picture[i]; |
1004 pic->reference= 1; | 1004 pic->reference= 1; |
1005 | 1005 |
1006 for(i=0; i<4; i++){ | 1006 for(i=0; i<4; i++){ |
1007 pic->data[i]= pic_arg->data[i]; | 1007 pic->data[i]= pic_arg->data[i]; |
1008 pic->linesize[i]= pic_arg->linesize[i]; | 1008 pic->linesize[i]= pic_arg->linesize[i]; |
1009 } | 1009 } |
1010 alloc_picture(s, (Picture*)pic, 1); | 1010 alloc_picture(s, (Picture*)pic, 1); |
1011 }else{ | 1011 }else{ |
1012 i= find_unused_picture(s, 0); | 1012 i= find_unused_picture(s, 0); |
1013 | 1013 |
1014 pic= (AVVideoFrame*)&s->picture[i]; | 1014 pic= (AVFrame*)&s->picture[i]; |
1015 pic->reference= 1; | 1015 pic->reference= 1; |
1016 | 1016 |
1017 alloc_picture(s, (Picture*)pic, 0); | 1017 alloc_picture(s, (Picture*)pic, 0); |
1018 | 1018 |
1019 if( pic->data[0] == pic_arg->data[0] | 1019 if( pic->data[0] == pic_arg->data[0] |
1192 | 1192 |
1193 int MPV_encode_picture(AVCodecContext *avctx, | 1193 int MPV_encode_picture(AVCodecContext *avctx, |
1194 unsigned char *buf, int buf_size, void *data) | 1194 unsigned char *buf, int buf_size, void *data) |
1195 { | 1195 { |
1196 MpegEncContext *s = avctx->priv_data; | 1196 MpegEncContext *s = avctx->priv_data; |
1197 AVVideoFrame *pic_arg = data; | 1197 AVFrame *pic_arg = data; |
1198 int i; | 1198 int i; |
1199 | 1199 |
1200 init_put_bits(&s->pb, buf, buf_size, NULL, NULL); | 1200 init_put_bits(&s->pb, buf, buf_size, NULL, NULL); |
1201 | 1201 |
1202 s->picture_in_gop_number++; | 1202 s->picture_in_gop_number++; |