comparison libmpcodecs/ve_lavc.c @ 17906:20aca9baf5d8

passing pts through the filter layer (lets see if pts or cola comes out at the end)
author michael
date Tue, 21 Mar 2006 21:26:42 +0000
parents d526e19c56c3
children d8a6e0c22f0c
comparison
equal deleted inserted replaced
17905:433494f162a9 17906:20aca9baf5d8
336 336
337 #if LIBAVCODEC_BUILD < 4684 337 #if LIBAVCODEC_BUILD < 4684
338 #define FF_QP2LAMBDA 1 338 #define FF_QP2LAMBDA 1
339 #endif 339 #endif
340 340
341 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic); 341 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts);
342 342
343 static int config(struct vf_instance_s* vf, 343 static int config(struct vf_instance_s* vf,
344 int width, int height, int d_width, int d_height, 344 int width, int height, int d_width, int d_height,
345 unsigned int flags, unsigned int outfmt){ 345 unsigned int flags, unsigned int outfmt){
346 int size, i; 346 int size, i;
780 static int control(struct vf_instance_s* vf, int request, void* data){ 780 static int control(struct vf_instance_s* vf, int request, void* data){
781 781
782 switch(request){ 782 switch(request){
783 case VFCTRL_FLUSH_FRAMES: 783 case VFCTRL_FLUSH_FRAMES:
784 if(vf->priv->codec->capabilities & CODEC_CAP_DELAY) 784 if(vf->priv->codec->capabilities & CODEC_CAP_DELAY)
785 while(encode_frame(vf, NULL) > 0); 785 while(encode_frame(vf, NULL, MP_NOPTS_VALUE) > 0);
786 return CONTROL_TRUE; 786 return CONTROL_TRUE;
787 default: 787 default:
788 return CONTROL_UNKNOWN; 788 return CONTROL_UNKNOWN;
789 } 789 }
790 } 790 }
824 static double psnr(double d){ 824 static double psnr(double d){
825 if(d==0) return INFINITY; 825 if(d==0) return INFINITY;
826 return -10.0*log(d)/log(10); 826 return -10.0*log(d)/log(10);
827 } 827 }
828 828
829 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ 829 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
830 AVFrame *pic= vf->priv->pic; 830 AVFrame *pic= vf->priv->pic;
831 831
832 pic->data[0]=mpi->planes[0]; 832 pic->data[0]=mpi->planes[0];
833 pic->data[1]=mpi->planes[1]; 833 pic->data[1]=mpi->planes[1];
834 pic->data[2]=mpi->planes[2]; 834 pic->data[2]=mpi->planes[2];
846 if(lavc_param_top!=-1) 846 if(lavc_param_top!=-1)
847 pic->top_field_first= lavc_param_top; 847 pic->top_field_first= lavc_param_top;
848 } 848 }
849 #endif 849 #endif
850 850
851 return (encode_frame(vf, pic) >= 0); 851 return (encode_frame(vf, pic, pts) >= 0);
852 } 852 }
853 853
854 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic){ 854 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts){
855 const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; 855 const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'};
856 int out_size; 856 int out_size;
857 857
858 if(pic){
859 pic->opaque= malloc(sizeof(pts));
860 memcpy(pic->opaque, &pts, sizeof(pts));
861 }
858 out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size, 862 out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
859 pic); 863 pic);
860 864
861 if(out_size == 0) { 865 if(out_size == 0) {
862 ++mux_v->encoder_delay; 866 ++mux_v->encoder_delay;
863 return 0; 867 return 0;
864 } 868 }
865 869
866 muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE); 870 muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0,
871 pts,
872 *(double*)lavc_venc_context->coded_frame->opaque);
873 free(lavc_venc_context->coded_frame->opaque);
867 874
868 #if LIBAVCODEC_BUILD >= 4643 875 #if LIBAVCODEC_BUILD >= 4643
869 /* store psnr / pict size / type / qscale */ 876 /* store psnr / pict size / type / qscale */
870 if(lavc_param_psnr){ 877 if(lavc_param_psnr){
871 static FILE *fvstats=NULL; 878 static FILE *fvstats=NULL;