changeset 17907:d8a6e0c22f0c

10l (null pointer dereference)
author michael
date Tue, 21 Mar 2006 22:12:48 +0000
parents 20aca9baf5d8
children dcfaebcdde14
files libmpcodecs/ve_lavc.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ve_lavc.c	Tue Mar 21 21:26:42 2006 +0000
+++ b/libmpcodecs/ve_lavc.c	Tue Mar 21 22:12:48 2006 +0000
@@ -854,6 +854,7 @@
 static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts){
     const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'};
     int out_size;
+    double dts;
 
     if(pic){
         pic->opaque= malloc(sizeof(pts));
@@ -862,15 +863,24 @@
 	out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
 	    pic);
 
+    if(pts != MP_NOPTS_VALUE) 
+        dts= pts - lavc_venc_context->delay * av_q2d(lavc_venc_context->time_base);
+    else
+        dts= MP_NOPTS_VALUE;
+
+    pts= lavc_venc_context->coded_frame->opaque ?
+           *(double*)lavc_venc_context->coded_frame->opaque
+         : MP_NOPTS_VALUE;
+
     if(out_size == 0) {
         ++mux_v->encoder_delay;
         return 0;
     }
            
     muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0, 
-                      pts, 
-                      *(double*)lavc_venc_context->coded_frame->opaque);
+                      dts, pts);
     free(lavc_venc_context->coded_frame->opaque);
+    lavc_venc_context->coded_frame->opaque= NULL;
         
 #if LIBAVCODEC_BUILD >= 4643
     /* store psnr / pict size / type / qscale */