Mercurial > mplayer.hg
comparison libmpcodecs/ve_lavc.c @ 14080:b4532e84bb4d
suppress dummy frames due to B-frame delay.
flush delayed frames.
author | lorenm |
---|---|
date | Wed, 01 Dec 2004 20:32:05 +0000 |
parents | 633a4ed68311 |
children | 0c10f923746e |
comparison
equal
deleted
inserted
replaced
14079:f60d6dee476b | 14080:b4532e84bb4d |
---|---|
322 | 322 |
323 #if LIBAVCODEC_BUILD < 4684 | 323 #if LIBAVCODEC_BUILD < 4684 |
324 #define FF_QP2LAMBDA 1 | 324 #define FF_QP2LAMBDA 1 |
325 #endif | 325 #endif |
326 | 326 |
327 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic); | |
328 | |
327 static int config(struct vf_instance_s* vf, | 329 static int config(struct vf_instance_s* vf, |
328 int width, int height, int d_width, int d_height, | 330 int width, int height, int d_width, int d_height, |
329 unsigned int flags, unsigned int outfmt){ | 331 unsigned int flags, unsigned int outfmt){ |
330 int size, i; | 332 int size, i; |
331 void *p; | 333 void *p; |
738 return 1; | 740 return 1; |
739 } | 741 } |
740 | 742 |
741 static int control(struct vf_instance_s* vf, int request, void* data){ | 743 static int control(struct vf_instance_s* vf, int request, void* data){ |
742 | 744 |
743 return CONTROL_UNKNOWN; | 745 switch(request){ |
746 case VFCTRL_FLUSH_FRAMES: | |
747 if(vf->priv->codec->capabilities & CODEC_CAP_DELAY) | |
748 while(encode_frame(vf, NULL) > 0); | |
749 return CONTROL_TRUE; | |
750 default: | |
751 return CONTROL_UNKNOWN; | |
752 } | |
744 } | 753 } |
745 | 754 |
746 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | 755 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
747 switch(fmt){ | 756 switch(fmt){ |
748 case IMGFMT_YV12: | 757 case IMGFMT_YV12: |
779 if(d==0) return INFINITY; | 788 if(d==0) return INFINITY; |
780 return -10.0*log(d)/log(10); | 789 return -10.0*log(d)/log(10); |
781 } | 790 } |
782 | 791 |
783 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | 792 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
784 const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; | |
785 int out_size; | |
786 AVFrame *pic= vf->priv->pic; | 793 AVFrame *pic= vf->priv->pic; |
787 | 794 |
788 pic->data[0]=mpi->planes[0]; | 795 pic->data[0]=mpi->planes[0]; |
789 pic->data[1]=mpi->planes[1]; | 796 pic->data[1]=mpi->planes[1]; |
790 pic->data[2]=mpi->planes[2]; | 797 pic->data[2]=mpi->planes[2]; |
802 if(lavc_param_top!=-1) | 809 if(lavc_param_top!=-1) |
803 pic->top_field_first= lavc_param_top; | 810 pic->top_field_first= lavc_param_top; |
804 } | 811 } |
805 #endif | 812 #endif |
806 | 813 |
814 return (encode_frame(vf, pic) >= 0); | |
815 } | |
816 | |
817 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic){ | |
818 const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; | |
819 int out_size; | |
820 | |
807 out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size, | 821 out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size, |
808 pic); | 822 pic); |
809 | 823 |
824 if(out_size == 0) | |
825 return 0; | |
810 | 826 |
811 muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0); | 827 muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0); |
812 | 828 |
813 #if LIBAVCODEC_BUILD >= 4643 | 829 #if LIBAVCODEC_BUILD >= 4643 |
814 /* store psnr / pict size / type / qscale */ | 830 /* store psnr / pict size / type / qscale */ |
833 fvstats = fopen(filename,"w"); | 849 fvstats = fopen(filename,"w"); |
834 if(!fvstats) { | 850 if(!fvstats) { |
835 perror("fopen"); | 851 perror("fopen"); |
836 lavc_param_psnr=0; // disable block | 852 lavc_param_psnr=0; // disable block |
837 mp_msg(MSGT_MENCODER,MSGL_ERR,"Can't open %s for writing. Check its permissions.\n",filename); | 853 mp_msg(MSGT_MENCODER,MSGL_ERR,"Can't open %s for writing. Check its permissions.\n",filename); |
838 return 0; | 854 return -1; |
839 /*exit(1);*/ | 855 /*exit(1);*/ |
840 } | 856 } |
841 } | 857 } |
842 | 858 |
843 // average MB quantizer | 859 // average MB quantizer |
868 } | 884 } |
869 #endif | 885 #endif |
870 /* store stats if there are any */ | 886 /* store stats if there are any */ |
871 if(lavc_venc_context->stats_out && stats_file) | 887 if(lavc_venc_context->stats_out && stats_file) |
872 fprintf(stats_file, "%s", lavc_venc_context->stats_out); | 888 fprintf(stats_file, "%s", lavc_venc_context->stats_out); |
873 return 1; | 889 return out_size; |
874 } | 890 } |
875 | 891 |
876 static void uninit(struct vf_instance_s* vf){ | 892 static void uninit(struct vf_instance_s* vf){ |
877 const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; | 893 const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; |
878 | 894 |