[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xine-cvslog
Subject:    [xine-cvs] CVS: xine-lib/src/libffmpeg video_decoder.c,1.71,1.72
From:       Diego_Pettenò <dgp85 () users ! sourceforge ! net>
Date:       2007-03-29 17:58:51
Message-ID: E1HWyvC-0001vB-8X () sc8-pr-cvs10 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/xine/xine-lib/src/libffmpeg
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7314

Modified Files:
	video_decoder.c 
Log Message:
Create and initialise the mpeg parser only when actually needed, and dispose it on instance disposal.

Index: video_decoder.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/video_decoder.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- video_decoder.c	29 Mar 2007 17:48:34 -0000	1.71
+++ video_decoder.c	29 Mar 2007 18:00:23 -0000	1.72
@@ -106,7 +106,7 @@
   pp_mode_t        *pp_mode;
 
   /* mpeg-es parsing */
-  mpeg_parser_t     mpeg_parser;
+  mpeg_parser_t    *mpeg_parser;
 
   double            aspect_ratio;
   int               aspect_ratio_prio;
@@ -523,7 +523,7 @@
     data.pan_scan = 0;
     xine_event_send(this->stream, &event);
   }
-  this->video_step = this->mpeg_parser.frame_duration;
+  this->video_step = this->mpeg_parser->frame_duration;
   
   return 1;
 }
@@ -826,8 +826,14 @@
   lprintf ("preview buffer\n");
 
   codec_type = buf->type & 0xFFFF0000;
-  if (codec_type == BUF_VIDEO_MPEG)
+  if (codec_type == BUF_VIDEO_MPEG) {
     this->is_mpeg12 = 1;
+    if ( this->mpeg_parser == NULL ) {
+      this->mpeg_parser = xine_xmalloc(sizeof(mpeg_parser_t));
+      mpeg_parser_init(this->mpeg_parser);
+      this->decoder_init_mode = 0;
+    }
+  }
 
   if (this->decoder_init_mode && !this->is_mpeg12) {
     init_video_codec(this, codec_type);
@@ -980,7 +986,7 @@
 
     got_picture = 0;
     if (!flush) {
-      current = mpeg_parser_decode_data(&this->mpeg_parser,
+      current = mpeg_parser_decode_data(this->mpeg_parser,
                                         buf->content + offset, buf->content + offset + size,
                                         &next_flush);
     } else {
@@ -992,8 +998,8 @@
       return;
     }
 
-    if (this->mpeg_parser.has_sequence) {
-      ff_handle_mpeg_sequence(this, &this->mpeg_parser);
+    if (this->mpeg_parser->has_sequence) {
+      ff_handle_mpeg_sequence(this, this->mpeg_parser);
     }
 
     if (!this->decoder_ok)
@@ -1002,16 +1008,16 @@
     if (flush) {
       lprintf("flush lavc buffers\n");
       /* hack: ffmpeg outputs the last frame if size=0 */
-      this->mpeg_parser.buffer_size = 0;
+      this->mpeg_parser->buffer_size = 0;
     }
 
     /* skip decoding b frames if too late */
     this->context->hurry_up = (this->skipframes > 0);
 
-    lprintf("avcodec_decode_video: size=%d\n", this->mpeg_parser.buffer_size);
+    lprintf("avcodec_decode_video: size=%d\n", this->mpeg_parser->buffer_size);
     len = avcodec_decode_video (this->context, this->av_frame,
-                                &got_picture, this->mpeg_parser.chunk_buffer,
-                                this->mpeg_parser.buffer_size);
+                                &got_picture, this->mpeg_parser->chunk_buffer,
+                                this->mpeg_parser->buffer_size);
     lprintf("avcodec_decode_video: decoded_size=%d, got_picture=%d\n",
             len, got_picture);
     len = current - buf->content - offset;
@@ -1364,7 +1370,7 @@
     avcodec_flush_buffers(this->context);
   
   if (this->is_mpeg12)
-    mpeg_parser_reset(&this->mpeg_parser);
+    mpeg_parser_reset(this->mpeg_parser);
 }
 
 static void ff_discontinuity (video_decoder_t *this_gen) {
@@ -1423,6 +1429,8 @@
     
   if(this->pp_mode)
     pp_free_mode(this->pp_mode);
+
+  mpeg_parser_dispose(this->mpeg_parser);
     
   xine_list_delete(this->dr1_frames);
   
@@ -1464,9 +1472,9 @@
   this->pp_context        = NULL;
   this->pp_mode           = NULL;
   
-  this->dr1_frames        = xine_list_new();
+  this->mpeg_parser       = NULL;
   
-  mpeg_parser_init(&this->mpeg_parser);
+  this->dr1_frames        = xine_list_new();
 
   return &this->video_decoder;
 }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
Xine-cvslog@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xine-cvslog
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic