Author: rolf
Date: 2008-01-24 11:07:20 -0500 (Thu, 24 Jan 2008)
New Revision: 93809

Modified:
   trunk/moon/src/asf/ChangeLog
   trunk/moon/src/asf/Makefile
   trunk/moon/src/asf/asf-debug.h
   trunk/moon/src/asf/asf-test.h
   trunk/moon/src/asf/asf.cpp
   trunk/moon/src/asf/asf.h
Log:
* asf.h: Fix comment to follow coding style. Fix ASFSource::Read
  signature.

Modified: trunk/moon/src/asf/ChangeLog
===================================================================
--- trunk/moon/src/asf/ChangeLog        2008-01-24 15:59:58 UTC (rev 93808)
+++ trunk/moon/src/asf/ChangeLog        2008-01-24 16:07:20 UTC (rev 93809)
@@ -1,5 +1,9 @@
 2008-01-24  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
+       * asf.h: Fix comment to follow coding style. Fix ASFSource::Read 
signature.
+
+2008-01-24  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
+
        * asf-ffmpeg.cpp, asf-ffmpeg.h: Removed, no longer needed.
        * asf-generated.h, asf.cpp: Updated.
        * asf-structures.cpp, asf-test.cpp, asf-debug.h: Use int*_t 
consistently.

Modified: trunk/moon/src/asf/Makefile
===================================================================
--- trunk/moon/src/asf/Makefile 2008-01-24 15:59:58 UTC (rev 93808)
+++ trunk/moon/src/asf/Makefile 2008-01-24 16:07:20 UTC (rev 93809)
@@ -1,8 +1,9 @@
-ASF_COMPILER_ARGUMENTS=-MMD -Wall -g -O0 -DDEBUG -I/usr/include/glib-2.0 
-I/usr/lib/glib-2.0/include -I../.. -I.prec -c
+ASF_COMPILER_ARGUMENTS=-MMD -Wall -g -O0 -DDEBUG -I/usr/include/glib-2.0 
-I/usr/lib/glib-2.0/include -I../.. -I.prec -c --coverage
+ASF_DUMP_ARGUMENTS=-Ddump -DDEBUG -Dlog
 ASF_BIN=asf
 
 default: asf-generated.h compile
-       g++ -o $(ASF_BIN) asf.o asf-generated.o asf-guids.o asf-structures.o 
asf-debug.o asf-test.o -lglib-2.0
+       g++ -o $(ASF_BIN) asf.o asf-generated.o asf-guids.o asf-structures.o 
asf-debug.o asf-test.o -lglib-2.0 -lgcov
 
 compile:
        g++ $(ASF_COMPILER_ARGUMENTS) asf.cpp -o asf.o
@@ -32,3 +33,12 @@
 corrupt: default
        valgrind --tool=memcheck -v --leak-check=full --log-file=v.log 
--smc-check=all $(ASF_BIN) -in:a.wmv -test -corruption:2000
 
+asf-dump:
+       g++ $(ASF_COMPILER_ARGUMENTS) $(ASF_DUMP_ARGUMENTS)  asf.cpp -o asf-d.o
+       g++ $(ASF_COMPILER_ARGUMENTS) $(ASF_DUMP_ARGUMENTS) asf-generated.cpp 
-o asf-generated-d.o
+       g++ $(ASF_COMPILER_ARGUMENTS) $(ASF_DUMP_ARGUMENTS) asf-guids.cpp -o 
asf-guids-d.o
+       g++ $(ASF_COMPILER_ARGUMENTS) $(ASF_DUMP_ARGUMENTS) asf-structures.cpp 
-o asf-structures-d.o
+       g++ $(ASF_COMPILER_ARGUMENTS) $(ASF_DUMP_ARGUMENTS) asf-debug.cpp -o 
asf-debug-d.o
+       g++ $(ASF_COMPILER_ARGUMENTS)                       asf-test.cpp -o 
asf-test-d.o        
+       g++ -o $(ASF_BIN)-dump asf-d.o asf-generated-d.o asf-guids-d.o 
asf-structures-d.o asf-debug-d.o asf-test-d.o -lglib-2.0 -lgcov
+       

Modified: trunk/moon/src/asf/asf-debug.h
===================================================================
--- trunk/moon/src/asf/asf-debug.h      2008-01-24 15:59:58 UTC (rev 93808)
+++ trunk/moon/src/asf/asf-debug.h      2008-01-24 16:07:20 UTC (rev 93809)
@@ -14,6 +14,8 @@
 #if DEBUG
 
 #include <stdio.h>
+#include <stdint.h>
+#include <glib.h>
 
 class ObjectTracker {
 public:

Modified: trunk/moon/src/asf/asf-test.h
===================================================================
--- trunk/moon/src/asf/asf-test.h       2008-01-24 15:59:58 UTC (rev 93808)
+++ trunk/moon/src/asf/asf-test.h       2008-01-24 16:07:20 UTC (rev 93809)
@@ -22,15 +22,15 @@
        corruption:                     introduce corruption approximately once 
every X bytes.
 */
 
-bool
-corrupt_file (const char* input_filename, const char* output_filename, const 
char* log_filename, bool replay, double corruption);
+//bool
+//corrupt_file (const char* input_filename, const char* output_filename, const 
char* log_filename, bool replay, double corruption);
 
 /*
        Tries to do everything possible with the file (parses everything, reads 
all packets, frames, etc).
 */
 
-bool
-test_file (const char* file);
+//bool
+//test_file (const char* file);
 
 
 

Modified: trunk/moon/src/asf/asf.cpp
===================================================================
--- trunk/moon/src/asf/asf.cpp  2008-01-24 15:59:58 UTC (rev 93808)
+++ trunk/moon/src/asf/asf.cpp  2008-01-24 16:07:20 UTC (rev 93809)
@@ -692,6 +692,7 @@
        payloads = NULL;
        eof = false;
        
+       first_pts = parser->GetFileProperties ()->preroll;
        
        script_command_stream_index = 0;
        FindScriptCommandStream ();
@@ -752,7 +753,7 @@
 bool
 ASFFrameReader::Seek (int stream_id, int64_t pts)
 {
-       ASF_LOG ("ASFFrameReader::Seek (%d, %lld).\n", stream_id, pts);
+       //printf ("ASFFrameReader::Seek (%d, %lld).\n", stream_id, pts);
        
        if (!CanSeek ())
                return false;
@@ -762,31 +763,54 @@
        // then we seek again from the first frame until the number of frames 
counted - 1.      
        
        int counter = 0;
-       bool found = true;
+       bool found = true; // <- This is broken...
        
        current_packet_index = 0;
        RemoveAll ();
        
-       while (Advance ()) {
-               if (Pts () > pts && IsKeyFrame ()) {
-                       found = true;
-                       break;
+       while (Advance (stream_id)) {
+               //printf ("ASFFrameReader::Seek (%d, %lld): Checking pts: 
%lld\n", stream_id, pts, Pts ());
+               if (Pts () > pts) {
+                       //printf ("ASFFrameReader::Seek (%d, %lld): Found pts: 
%lld\n", stream_id, pts, Pts ());
+                       if (IsKeyFrame ()) {
+                               //printf ("ASFFrameReader::Seek (%d, %lld): 
Found a key frame\n", stream_id, pts);
+                               found = true;
+                       } else if (false) {
+                               //printf ("ASFFrameReader::Seek (%d, %lld): 
Checking for audio frame..\n", stream_id, pts);
+                               asf_stream_properties* asp = parser->GetStream 
(StreamId ());
+                               found = asp->is_audio ();
+                               //printf ("ASFFrameReader::Seek (%d, %lld): 
Checking for audio frame: %s\n", stream_id, pts, found ? "true" : "false");
+                       }
+                       if (found)
+                               break;
                }
                counter++;
        }
        
-       if (!found)
+       if (!found) {
+               //printf ("ASFFrameReader::Seek (%d, %lld): Didn't find the 
requested pts.\n", stream_id, pts);
                return false;
+       }
        
+       //printf ("ASFFrameReader::Seek (%d, %lld): Counted to %i.\n", 
stream_id, pts, counter);
+               
        current_packet_index = 0;
        RemoveAll ();
        
        while (counter-- > 0) {
-               if (!Advance ()) {
+               if (!Advance (stream_id)) {
                        return false;
                }
+               //printf ("ASFFrameReader::Seek (%d, %lld): Counting: %i, pts: 
%lld, size: %i.\n", stream_id, pts, counter, Pts (), Size ());
        }
        
+       // Don't return any frames before the pts we seeked to.
+       // This might happen if we found the requested pts in stream #1, but 
stream #2 
+       // has frames with pts below this one.
+       first_pts = pts; 
+       
+       //printf ("ASFFrameReader::Seek (%d, %lld): Found the requested pts, 
we're now at: %lld.\n", stream_id, pts, Pts ());
+       
        return true;
 }
 
@@ -860,7 +884,11 @@
                
                asf_single_payload* payload = current->payload;
                
-               if (stream_id == 0 || payload->stream_id == stream_id) {
+               if (false && payload->presentation_time < first_pts) {
+                       ASFFrameReaderData* tmp = current;
+                       current = current->next;
+                       Remove (tmp);
+               } else if (stream_id == 0 || payload->stream_id == stream_id) {
                        if (payload_count > 0 && payload->media_object_number 
!= media_object_number) {
                                // We've found the end of the current frame's 
payloads
                                ASF_LOG ("ASFFrameReader::Advance (): reached 
media object number %i (while reading %i).\n", payload->media_object_number, 
media_object_number);

Modified: trunk/moon/src/asf/asf.h
===================================================================
--- trunk/moon/src/asf/asf.h    2008-01-24 15:59:58 UTC (rev 93808)
+++ trunk/moon/src/asf/asf.h    2008-01-24 16:07:20 UTC (rev 93809)
@@ -27,7 +27,6 @@
 struct asf_object;
 
 class ASFParser;
-class ASFFileSource;
 class ASFSource;
 
 #define ASF_ERROR_VAL(fail, ...) { fprintf (stderr, __VA_ARGS__); return fail; 
}
@@ -70,7 +69,7 @@
        // into the destionation.
        bool ReadEncoded (uint32_t encoded_length, uint32_t *dest);     
        
-       bool Read (void *buf, size_t n); // Reads the requested number of bytes 
into the destination
+       bool Read (void *buf, uint32_t n); // Reads the requested number of 
bytes into the destination
        
        bool Seek (int64_t offset); // Seeks to the offset from the current 
position
        bool Seek (int64_t offset, int mode); // Seeks to the offset, with the 
specified mode (SEEK_CUR, SEEK_END, SEEK_SET)
@@ -132,34 +131,37 @@
 };
 
 /*
-       The data in an ASF file has the following structure:
-               Data
-                       Packets
-                               Payload(s)
-                                       Chunks of Media objects
-       
-       The problem is that one chunk of "Media object data" can span several 
payloads (and packets),
-       and the pieces may come unordered, like this:
-       
-       - first 25% of media object #1 for stream #1
-       - first 25% of media object #1 for stream #2
-       - first 25% of media object #1 for stream #3
-       - middle 50% of media object #1 for stream #2
-       - last 75% of media object #1 for stream #1
-       => we have now all the data for the first media object of stream #1
-       
-       This class implements a reader that allows the consumer to just call 
Advance() and then get the all data
-       for each "Media object" (here called "Frame", since it's shorter, and 
in general it corresponds
-       to a frame of video/audio, etc, even though the ASF spec states that it 
can be just about anything)
-       in one convenient Write () call.
-       
-       We keep reading payloads until we have all the data for a frame, the 
payloads currently not wanted are 
-       kept in a queue until the next Advance ().
-*/
+ *     The data in an ASF file has the following structure:
+ *             Data
+ *                     Packets
+ *                             Payload(s)
+ *                                     Chunks of Media objects
+ *     
+ *     The problem is that one chunk of "Media object data" can span several 
payloads (and packets),
+ *     and the pieces may come unordered, like this:
+ *     
+ *     - first 25% of media object #1 for stream #1
+ *     - first 25% of media object #1 for stream #2
+ *     - first 25% of media object #1 for stream #3
+ *     - middle 50% of media object #1 for stream #2
+ *     - last 75% of media object #1 for stream #1
+ *     => we have now all the data for the first media object of stream #1
+ *     
+ *     This class implements a reader that allows the consumer to just call 
Advance() and then get the all data
+ *     for each "Media object" (here called "Frame", since it's shorter, and 
in general it corresponds
+ *     to a frame of video/audio, etc, even though the ASF spec states that it 
can be just about anything)
+ *     in one convenient Write () call.
+ *     
+ *     We keep reading payloads until we have all the data for a frame, the 
payloads currently not wanted are 
+ *     kept in a queue until the next Advance ().
+ */
 
 class ASFFrameReader {
        ASFParser *parser;
        
+       // The first pts that should be returned, any frames with pts below 
this one will be dropped.
+       int64_t first_pts;
+       
        int current_packet_index;
        int script_command_stream_index;
        
@@ -209,8 +211,13 @@
        bool IsKeyFrame () { return (payloads_size > 0 && payloads [0] != NULL) 
? payloads [0]->is_key_frame : false; }
        int64_t Pts () { return (payloads_size > 0 && payloads [0] != NULL) ? 
payloads [0]->get_presentation_time () : 0; }
        int StreamId () { return (payloads_size > 0 && payloads [0] != NULL) ? 
payloads [0]->stream_id : 0; }
-       bool Eof () { return eof; } // EOF might be true even if there are more 
packets in the reader (if Advance () fails, and Eof () = true, then advance 
failed because of eof.
+       bool Eof () { return eof; } // EOF might be true even if there are more 
packets in the reader (if Advance () fails, and Eof () = true, then advance 
failed because of eof).
        void FindScriptCommandStream ();
+       
+       // Index 
+       uint32_t FrameSearch (int64_t pts);
+       // Adds the current frame to the index.
+       void AddFrameIndex ();
 };
 
 class ASFParser {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to