[FFmpeg-cvslog] r14000 - trunk/libavformat/psxstr.c

michael subversion
Fri Jun 27 00:53:43 CEST 2008


Author: michael
Date: Fri Jun 27 00:53:43 2008
New Revision: 14000

Log:
Get rid of weird pre reading code.


Modified:
   trunk/libavformat/psxstr.c

Modified: trunk/libavformat/psxstr.c
==============================================================================
--- trunk/libavformat/psxstr.c	(original)
+++ trunk/libavformat/psxstr.c	Fri Jun 27 00:53:43 2008
@@ -94,11 +94,9 @@ static int str_read_header(AVFormatConte
 {
     ByteIOContext *pb = s->pb;
     StrDemuxContext *str = s->priv_data;
-    AVStream *st;
     unsigned char sector[RAW_CD_SECTOR_SIZE];
     int start;
     int i;
-    int channel;
 
     /* skip over any RIFF header */
     if (get_buffer(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
@@ -115,75 +113,7 @@ static int str_read_header(AVFormatConte
         str->channels[i].audio_stream_index= -1;
     }
 
-    /* check through the first 32 sectors for individual channels */
-    for (i = 0; i < 32; i++) {
-        if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
-            return AVERROR(EIO);
-
-        channel = sector[0x11];
-        if (channel >= 32)
-            return AVERROR_INVALIDDATA;
-
-        switch (sector[0x12] & CDXA_TYPE_MASK) {
-
-        case CDXA_TYPE_DATA:
-        case CDXA_TYPE_VIDEO:
-                /* qualify the magic number */
-                if (AV_RL32(&sector[0x18]) != STR_MAGIC)
-                    break;
-                if(str->channels[channel].video_stream_index != -1)
-                    break;
-
-                /* allocate a new AVStream */
-                st = av_new_stream(s, 0);
-                if (!st)
-                    return AVERROR(ENOMEM);
-                av_set_pts_info(st, 64, 1, 15);
-
-                str->channels[channel].video_stream_index = st->index;
-
-                st->codec->codec_type = CODEC_TYPE_VIDEO;
-                st->codec->codec_id   = CODEC_ID_MDEC;
-                st->codec->codec_tag  = 0;  /* no fourcc */
-                st->codec->width      = AV_RL16(&sector[0x28]);
-                st->codec->height     = AV_RL16(&sector[0x2A]);
-            break;
-
-        case CDXA_TYPE_AUDIO:
-            {
-                int fmt;
-
-                if(str->channels[channel].audio_stream_index != -1)
-                    break;
-
-                /* allocate a new AVStream */
-                st = av_new_stream(s, 0);
-                if (!st)
-                    return AVERROR(ENOMEM);
-
-                str->channels[channel].audio_stream_index = st->index;
-
-                fmt = sector[0x13];
-                st->codec->codec_type  = CODEC_TYPE_AUDIO;
-                st->codec->codec_id    = CODEC_ID_ADPCM_XA;
-                st->codec->codec_tag   = 0;  /* no fourcc */
-                st->codec->channels    = (fmt&1)?2:1;
-                st->codec->sample_rate = (fmt&4)?18900:37800;
-            //    st->codec->bit_rate = 0; //FIXME;
-                st->codec->block_align = 128;
-
-                av_set_pts_info(st, 64, 128, st->codec->sample_rate);
-            }
-            break;
-
-        default:
-            /* ignore */
-            break;
-        }
-    }
-
-    /* back to the start */
-    url_fseek(pb, start, SEEK_SET);
+    s->ctx_flags |= AVFMTCTX_NOHEADER;
 
     return 0;
 }
@@ -196,6 +126,7 @@ static int str_read_packet(AVFormatConte
     unsigned char sector[RAW_CD_SECTOR_SIZE];
     int channel;
     AVPacket *pkt;
+    AVStream *st;
 
     while (1) {
 
@@ -223,6 +154,22 @@ static int str_read_packet(AVFormatConte
                     return AVERROR_INVALIDDATA;
                 }
 
+                if(str->channels[channel].video_stream_index < 0){
+                    /* allocate a new AVStream */
+                    st = av_new_stream(s, 0);
+                    if (!st)
+                        return AVERROR(ENOMEM);
+                    av_set_pts_info(st, 64, 1, 15);
+
+                    str->channels[channel].video_stream_index = st->index;
+
+                    st->codec->codec_type = CODEC_TYPE_VIDEO;
+                    st->codec->codec_id   = CODEC_ID_MDEC;
+                    st->codec->codec_tag  = 0;  /* no fourcc */
+                    st->codec->width      = AV_RL16(&sector[0x28]);
+                    st->codec->height     = AV_RL16(&sector[0x2A]);
+                }
+
                 /* if this is the first sector of the frame, allocate a pkt */
                 pkt = &str->channels[channel].tmp_pkt;
 
@@ -254,6 +201,26 @@ static int str_read_packet(AVFormatConte
             break;
 
         case CDXA_TYPE_AUDIO:
+            if(str->channels[channel].audio_stream_index < 0){
+                int fmt;
+                /* allocate a new AVStream */
+                st = av_new_stream(s, 0);
+                if (!st)
+                    return AVERROR(ENOMEM);
+
+                str->channels[channel].audio_stream_index = st->index;
+
+                fmt = sector[0x13];
+                st->codec->codec_type  = CODEC_TYPE_AUDIO;
+                st->codec->codec_id    = CODEC_ID_ADPCM_XA;
+                st->codec->codec_tag   = 0;  /* no fourcc */
+                st->codec->channels    = (fmt&1)?2:1;
+                st->codec->sample_rate = (fmt&4)?18900:37800;
+            //    st->codec->bit_rate = 0; //FIXME;
+                st->codec->block_align = 128;
+
+                av_set_pts_info(st, 64, 128, st->codec->sample_rate);
+            }
                 pkt = ret_pkt;
                 if (av_new_packet(pkt, 2304))
                     return AVERROR(EIO);




More information about the ffmpeg-cvslog mailing list