• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/ipmovie.c

Go to the documentation of this file.
00001 /*
00002  * Interplay MVE File Demuxer
00003  * Copyright (c) 2003 The ffmpeg Project
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00035 #include "libavutil/intreadwrite.h"
00036 #include "avformat.h"
00037 
00038 #define CHUNK_PREAMBLE_SIZE 4
00039 #define OPCODE_PREAMBLE_SIZE 4
00040 
00041 #define CHUNK_INIT_AUDIO   0x0000
00042 #define CHUNK_AUDIO_ONLY   0x0001
00043 #define CHUNK_INIT_VIDEO   0x0002
00044 #define CHUNK_VIDEO        0x0003
00045 #define CHUNK_SHUTDOWN     0x0004
00046 #define CHUNK_END          0x0005
00047 /* these last types are used internally */
00048 #define CHUNK_DONE         0xFFFC
00049 #define CHUNK_NOMEM        0xFFFD
00050 #define CHUNK_EOF          0xFFFE
00051 #define CHUNK_BAD          0xFFFF
00052 
00053 #define OPCODE_END_OF_STREAM           0x00
00054 #define OPCODE_END_OF_CHUNK            0x01
00055 #define OPCODE_CREATE_TIMER            0x02
00056 #define OPCODE_INIT_AUDIO_BUFFERS      0x03
00057 #define OPCODE_START_STOP_AUDIO        0x04
00058 #define OPCODE_INIT_VIDEO_BUFFERS      0x05
00059 #define OPCODE_UNKNOWN_06              0x06
00060 #define OPCODE_SEND_BUFFER             0x07
00061 #define OPCODE_AUDIO_FRAME             0x08
00062 #define OPCODE_SILENCE_FRAME           0x09
00063 #define OPCODE_INIT_VIDEO_MODE         0x0A
00064 #define OPCODE_CREATE_GRADIENT         0x0B
00065 #define OPCODE_SET_PALETTE             0x0C
00066 #define OPCODE_SET_PALETTE_COMPRESSED  0x0D
00067 #define OPCODE_UNKNOWN_0E              0x0E
00068 #define OPCODE_SET_DECODING_MAP        0x0F
00069 #define OPCODE_UNKNOWN_10              0x10
00070 #define OPCODE_VIDEO_DATA              0x11
00071 #define OPCODE_UNKNOWN_12              0x12
00072 #define OPCODE_UNKNOWN_13              0x13
00073 #define OPCODE_UNKNOWN_14              0x14
00074 #define OPCODE_UNKNOWN_15              0x15
00075 
00076 #define PALETTE_COUNT 256
00077 
00078 typedef struct IPMVEContext {
00079 
00080     unsigned char *buf;
00081     int buf_size;
00082 
00083     uint64_t frame_pts_inc;
00084 
00085     unsigned int video_bpp;
00086     unsigned int video_width;
00087     unsigned int video_height;
00088     int64_t video_pts;
00089 
00090     unsigned int audio_bits;
00091     unsigned int audio_channels;
00092     unsigned int audio_sample_rate;
00093     enum CodecID audio_type;
00094     unsigned int audio_frame_count;
00095 
00096     int video_stream_index;
00097     int audio_stream_index;
00098 
00099     int64_t audio_chunk_offset;
00100     int audio_chunk_size;
00101     int64_t video_chunk_offset;
00102     int video_chunk_size;
00103     int64_t decode_map_chunk_offset;
00104     int decode_map_chunk_size;
00105 
00106     int64_t next_chunk_offset;
00107 
00108     AVPaletteControl palette_control;
00109 
00110 } IPMVEContext;
00111 
00112 static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
00113     AVPacket *pkt) {
00114 
00115     int chunk_type;
00116 
00117     if (s->audio_chunk_offset) {
00118 
00119         /* adjust for PCM audio by skipping chunk header */
00120         if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
00121             s->audio_chunk_offset += 6;
00122             s->audio_chunk_size -= 6;
00123         }
00124 
00125         avio_seek(pb, s->audio_chunk_offset, SEEK_SET);
00126         s->audio_chunk_offset = 0;
00127 
00128         if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
00129             return CHUNK_EOF;
00130 
00131         pkt->stream_index = s->audio_stream_index;
00132         pkt->pts = s->audio_frame_count;
00133 
00134         /* audio frame maintenance */
00135         if (s->audio_type != CODEC_ID_INTERPLAY_DPCM)
00136             s->audio_frame_count +=
00137             (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
00138         else
00139             s->audio_frame_count +=
00140                 (s->audio_chunk_size - 6) / s->audio_channels;
00141 
00142         av_dlog(NULL, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
00143                 pkt->pts, s->audio_frame_count);
00144 
00145         chunk_type = CHUNK_VIDEO;
00146 
00147     } else if (s->decode_map_chunk_offset) {
00148 
00149         /* send both the decode map and the video data together */
00150 
00151         if (av_new_packet(pkt, s->decode_map_chunk_size + s->video_chunk_size))
00152             return CHUNK_NOMEM;
00153 
00154         pkt->pos= s->decode_map_chunk_offset;
00155         avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
00156         s->decode_map_chunk_offset = 0;
00157 
00158         if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
00159             s->decode_map_chunk_size) {
00160             av_free_packet(pkt);
00161             return CHUNK_EOF;
00162         }
00163 
00164         avio_seek(pb, s->video_chunk_offset, SEEK_SET);
00165         s->video_chunk_offset = 0;
00166 
00167         if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
00168             s->video_chunk_size) != s->video_chunk_size) {
00169             av_free_packet(pkt);
00170             return CHUNK_EOF;
00171         }
00172 
00173         pkt->stream_index = s->video_stream_index;
00174         pkt->pts = s->video_pts;
00175 
00176         av_dlog(NULL, "sending video frame with pts %"PRId64"\n", pkt->pts);
00177 
00178         s->video_pts += s->frame_pts_inc;
00179 
00180         chunk_type = CHUNK_VIDEO;
00181 
00182     } else {
00183 
00184         avio_seek(pb, s->next_chunk_offset, SEEK_SET);
00185         chunk_type = CHUNK_DONE;
00186 
00187     }
00188 
00189     return chunk_type;
00190 }
00191 
00192 /* This function loads and processes a single chunk in an IP movie file.
00193  * It returns the type of chunk that was processed. */
00194 static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
00195     AVPacket *pkt)
00196 {
00197     unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
00198     int chunk_type;
00199     int chunk_size;
00200     unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
00201     unsigned char opcode_type;
00202     unsigned char opcode_version;
00203     int opcode_size;
00204     unsigned char scratch[1024];
00205     int i, j;
00206     int first_color, last_color;
00207     int audio_flags;
00208     unsigned char r, g, b;
00209 
00210     /* see if there are any pending packets */
00211     chunk_type = load_ipmovie_packet(s, pb, pkt);
00212     if (chunk_type != CHUNK_DONE)
00213         return chunk_type;
00214 
00215     /* read the next chunk, wherever the file happens to be pointing */
00216     if (url_feof(pb))
00217         return CHUNK_EOF;
00218     if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
00219         CHUNK_PREAMBLE_SIZE)
00220         return CHUNK_BAD;
00221     chunk_size = AV_RL16(&chunk_preamble[0]);
00222     chunk_type = AV_RL16(&chunk_preamble[2]);
00223 
00224     av_dlog(NULL, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
00225 
00226     switch (chunk_type) {
00227 
00228     case CHUNK_INIT_AUDIO:
00229         av_dlog(NULL, "initialize audio\n");
00230         break;
00231 
00232     case CHUNK_AUDIO_ONLY:
00233         av_dlog(NULL, "audio only\n");
00234         break;
00235 
00236     case CHUNK_INIT_VIDEO:
00237         av_dlog(NULL, "initialize video\n");
00238         break;
00239 
00240     case CHUNK_VIDEO:
00241         av_dlog(NULL, "video (and audio)\n");
00242         break;
00243 
00244     case CHUNK_SHUTDOWN:
00245         av_dlog(NULL, "shutdown\n");
00246         break;
00247 
00248     case CHUNK_END:
00249         av_dlog(NULL, "end\n");
00250         break;
00251 
00252     default:
00253         av_dlog(NULL, "invalid chunk\n");
00254         chunk_type = CHUNK_BAD;
00255         break;
00256 
00257     }
00258 
00259     while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
00260 
00261         /* read the next chunk, wherever the file happens to be pointing */
00262         if (url_feof(pb)) {
00263             chunk_type = CHUNK_EOF;
00264             break;
00265         }
00266         if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
00267             CHUNK_PREAMBLE_SIZE) {
00268             chunk_type = CHUNK_BAD;
00269             break;
00270         }
00271 
00272         opcode_size = AV_RL16(&opcode_preamble[0]);
00273         opcode_type = opcode_preamble[2];
00274         opcode_version = opcode_preamble[3];
00275 
00276         chunk_size -= OPCODE_PREAMBLE_SIZE;
00277         chunk_size -= opcode_size;
00278         if (chunk_size < 0) {
00279             av_dlog(NULL, "chunk_size countdown just went negative\n");
00280             chunk_type = CHUNK_BAD;
00281             break;
00282         }
00283 
00284         av_dlog(NULL, "  opcode type %02X, version %d, 0x%04X bytes: ",
00285                 opcode_type, opcode_version, opcode_size);
00286         switch (opcode_type) {
00287 
00288         case OPCODE_END_OF_STREAM:
00289             av_dlog(NULL, "end of stream\n");
00290             avio_skip(pb, opcode_size);
00291             break;
00292 
00293         case OPCODE_END_OF_CHUNK:
00294             av_dlog(NULL, "end of chunk\n");
00295             avio_skip(pb, opcode_size);
00296             break;
00297 
00298         case OPCODE_CREATE_TIMER:
00299             av_dlog(NULL, "create timer\n");
00300             if ((opcode_version > 0) || (opcode_size > 6)) {
00301                 av_dlog(NULL, "bad create_timer opcode\n");
00302                 chunk_type = CHUNK_BAD;
00303                 break;
00304             }
00305             if (avio_read(pb, scratch, opcode_size) !=
00306                 opcode_size) {
00307                 chunk_type = CHUNK_BAD;
00308                 break;
00309             }
00310             s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
00311             av_dlog(NULL, "  %.2f frames/second (timer div = %d, subdiv = %d)\n",
00312                     1000000.0 / s->frame_pts_inc, AV_RL32(&scratch[0]),
00313                     AV_RL16(&scratch[4]));
00314             break;
00315 
00316         case OPCODE_INIT_AUDIO_BUFFERS:
00317             av_dlog(NULL, "initialize audio buffers\n");
00318             if ((opcode_version > 1) || (opcode_size > 10)) {
00319                 av_dlog(NULL, "bad init_audio_buffers opcode\n");
00320                 chunk_type = CHUNK_BAD;
00321                 break;
00322             }
00323             if (avio_read(pb, scratch, opcode_size) !=
00324                 opcode_size) {
00325                 chunk_type = CHUNK_BAD;
00326                 break;
00327             }
00328             s->audio_sample_rate = AV_RL16(&scratch[4]);
00329             audio_flags = AV_RL16(&scratch[2]);
00330             /* bit 0 of the flags: 0 = mono, 1 = stereo */
00331             s->audio_channels = (audio_flags & 1) + 1;
00332             /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
00333             s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
00334             /* bit 2 indicates compressed audio in version 1 opcode */
00335             if ((opcode_version == 1) && (audio_flags & 0x4))
00336                 s->audio_type = CODEC_ID_INTERPLAY_DPCM;
00337             else if (s->audio_bits == 16)
00338                 s->audio_type = CODEC_ID_PCM_S16LE;
00339             else
00340                 s->audio_type = CODEC_ID_PCM_U8;
00341             av_dlog(NULL, "audio: %d bits, %d Hz, %s, %s format\n",
00342                     s->audio_bits, s->audio_sample_rate,
00343                     (s->audio_channels == 2) ? "stereo" : "mono",
00344                     (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
00345                     "Interplay audio" : "PCM");
00346             break;
00347 
00348         case OPCODE_START_STOP_AUDIO:
00349             av_dlog(NULL, "start/stop audio\n");
00350             avio_skip(pb, opcode_size);
00351             break;
00352 
00353         case OPCODE_INIT_VIDEO_BUFFERS:
00354             av_dlog(NULL, "initialize video buffers\n");
00355             if ((opcode_version > 2) || (opcode_size > 8)) {
00356                 av_dlog(NULL, "bad init_video_buffers opcode\n");
00357                 chunk_type = CHUNK_BAD;
00358                 break;
00359             }
00360             if (avio_read(pb, scratch, opcode_size) !=
00361                 opcode_size) {
00362                 chunk_type = CHUNK_BAD;
00363                 break;
00364             }
00365             s->video_width = AV_RL16(&scratch[0]) * 8;
00366             s->video_height = AV_RL16(&scratch[2]) * 8;
00367             if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
00368                 s->video_bpp = 8;
00369             } else {
00370                 s->video_bpp = 16;
00371             }
00372             av_dlog(NULL, "video resolution: %d x %d\n",
00373                     s->video_width, s->video_height);
00374             break;
00375 
00376         case OPCODE_UNKNOWN_06:
00377         case OPCODE_UNKNOWN_0E:
00378         case OPCODE_UNKNOWN_10:
00379         case OPCODE_UNKNOWN_12:
00380         case OPCODE_UNKNOWN_13:
00381         case OPCODE_UNKNOWN_14:
00382         case OPCODE_UNKNOWN_15:
00383             av_dlog(NULL, "unknown (but documented) opcode %02X\n", opcode_type);
00384             avio_skip(pb, opcode_size);
00385             break;
00386 
00387         case OPCODE_SEND_BUFFER:
00388             av_dlog(NULL, "send buffer\n");
00389             avio_skip(pb, opcode_size);
00390             break;
00391 
00392         case OPCODE_AUDIO_FRAME:
00393             av_dlog(NULL, "audio frame\n");
00394 
00395             /* log position and move on for now */
00396             s->audio_chunk_offset = avio_tell(pb);
00397             s->audio_chunk_size = opcode_size;
00398             avio_skip(pb, opcode_size);
00399             break;
00400 
00401         case OPCODE_SILENCE_FRAME:
00402             av_dlog(NULL, "silence frame\n");
00403             avio_skip(pb, opcode_size);
00404             break;
00405 
00406         case OPCODE_INIT_VIDEO_MODE:
00407             av_dlog(NULL, "initialize video mode\n");
00408             avio_skip(pb, opcode_size);
00409             break;
00410 
00411         case OPCODE_CREATE_GRADIENT:
00412             av_dlog(NULL, "create gradient\n");
00413             avio_skip(pb, opcode_size);
00414             break;
00415 
00416         case OPCODE_SET_PALETTE:
00417             av_dlog(NULL, "set palette\n");
00418             /* check for the logical maximum palette size
00419              * (3 * 256 + 4 bytes) */
00420             if (opcode_size > 0x304) {
00421                 av_dlog(NULL, "demux_ipmovie: set_palette opcode too large\n");
00422                 chunk_type = CHUNK_BAD;
00423                 break;
00424             }
00425             if (avio_read(pb, scratch, opcode_size) != opcode_size) {
00426                 chunk_type = CHUNK_BAD;
00427                 break;
00428             }
00429 
00430             /* load the palette into internal data structure */
00431             first_color = AV_RL16(&scratch[0]);
00432             last_color = first_color + AV_RL16(&scratch[2]) - 1;
00433             /* sanity check (since they are 16 bit values) */
00434             if ((first_color > 0xFF) || (last_color > 0xFF)) {
00435                 av_dlog(NULL, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
00436                     first_color, last_color);
00437                 chunk_type = CHUNK_BAD;
00438                 break;
00439             }
00440             j = 4;  /* offset of first palette data */
00441             for (i = first_color; i <= last_color; i++) {
00442                 /* the palette is stored as a 6-bit VGA palette, thus each
00443                  * component is shifted up to a 8-bit range */
00444                 r = scratch[j++] * 4;
00445                 g = scratch[j++] * 4;
00446                 b = scratch[j++] * 4;
00447                 s->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
00448             }
00449             /* indicate a palette change */
00450             s->palette_control.palette_changed = 1;
00451             break;
00452 
00453         case OPCODE_SET_PALETTE_COMPRESSED:
00454             av_dlog(NULL, "set palette compressed\n");
00455             avio_skip(pb, opcode_size);
00456             break;
00457 
00458         case OPCODE_SET_DECODING_MAP:
00459             av_dlog(NULL, "set decoding map\n");
00460 
00461             /* log position and move on for now */
00462             s->decode_map_chunk_offset = avio_tell(pb);
00463             s->decode_map_chunk_size = opcode_size;
00464             avio_skip(pb, opcode_size);
00465             break;
00466 
00467         case OPCODE_VIDEO_DATA:
00468             av_dlog(NULL, "set video data\n");
00469 
00470             /* log position and move on for now */
00471             s->video_chunk_offset = avio_tell(pb);
00472             s->video_chunk_size = opcode_size;
00473             avio_skip(pb, opcode_size);
00474             break;
00475 
00476         default:
00477             av_dlog(NULL, "*** unknown opcode type\n");
00478             chunk_type = CHUNK_BAD;
00479             break;
00480 
00481         }
00482     }
00483 
00484     /* make a note of where the stream is sitting */
00485     s->next_chunk_offset = avio_tell(pb);
00486 
00487     /* dispatch the first of any pending packets */
00488     if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
00489         chunk_type = load_ipmovie_packet(s, pb, pkt);
00490 
00491     return chunk_type;
00492 }
00493 
00494 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
00495 
00496 static int ipmovie_probe(AVProbeData *p)
00497 {
00498     uint8_t *b = p->buf;
00499     uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
00500     do {
00501         if (memcmp(b++, signature, sizeof(signature)) == 0)
00502             return AVPROBE_SCORE_MAX;
00503     } while (b < b_end);
00504 
00505     return 0;
00506 }
00507 
00508 static int ipmovie_read_header(AVFormatContext *s,
00509                                AVFormatParameters *ap)
00510 {
00511     IPMVEContext *ipmovie = s->priv_data;
00512     AVIOContext *pb = s->pb;
00513     AVPacket pkt;
00514     AVStream *st;
00515     unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
00516     int chunk_type;
00517     uint8_t signature_buffer[sizeof(signature)];
00518 
00519     avio_read(pb, signature_buffer, sizeof(signature_buffer));
00520     while (memcmp(signature_buffer, signature, sizeof(signature))) {
00521         memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
00522         signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
00523         if (url_feof(pb))
00524             return AVERROR_EOF;
00525     }
00526     /* initialize private context members */
00527     ipmovie->video_pts = ipmovie->audio_frame_count = 0;
00528     ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
00529     ipmovie->decode_map_chunk_offset = 0;
00530 
00531     /* on the first read, this will position the stream at the first chunk */
00532     ipmovie->next_chunk_offset = avio_tell(pb) + 4;
00533 
00534     /* process the first chunk which should be CHUNK_INIT_VIDEO */
00535     if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
00536         return AVERROR_INVALIDDATA;
00537 
00538     /* peek ahead to the next chunk-- if it is an init audio chunk, process
00539      * it; if it is the first video chunk, this is a silent file */
00540     if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
00541         CHUNK_PREAMBLE_SIZE)
00542         return AVERROR(EIO);
00543     chunk_type = AV_RL16(&chunk_preamble[2]);
00544     avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
00545 
00546     if (chunk_type == CHUNK_VIDEO)
00547         ipmovie->audio_type = CODEC_ID_NONE;  /* no audio */
00548     else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
00549         return AVERROR_INVALIDDATA;
00550 
00551     /* initialize the stream decoders */
00552     st = av_new_stream(s, 0);
00553     if (!st)
00554         return AVERROR(ENOMEM);
00555     av_set_pts_info(st, 63, 1, 1000000);
00556     ipmovie->video_stream_index = st->index;
00557     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
00558     st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
00559     st->codec->codec_tag = 0;  /* no fourcc */
00560     st->codec->width = ipmovie->video_width;
00561     st->codec->height = ipmovie->video_height;
00562     st->codec->bits_per_coded_sample = ipmovie->video_bpp;
00563 
00564     /* palette considerations */
00565     st->codec->palctrl = &ipmovie->palette_control;
00566 
00567     if (ipmovie->audio_type) {
00568         st = av_new_stream(s, 0);
00569         if (!st)
00570             return AVERROR(ENOMEM);
00571         av_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
00572         ipmovie->audio_stream_index = st->index;
00573         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
00574         st->codec->codec_id = ipmovie->audio_type;
00575         st->codec->codec_tag = 0;  /* no tag */
00576         st->codec->channels = ipmovie->audio_channels;
00577         st->codec->sample_rate = ipmovie->audio_sample_rate;
00578         st->codec->bits_per_coded_sample = ipmovie->audio_bits;
00579         st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
00580             st->codec->bits_per_coded_sample;
00581         if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
00582             st->codec->bit_rate /= 2;
00583         st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
00584     }
00585 
00586     return 0;
00587 }
00588 
00589 static int ipmovie_read_packet(AVFormatContext *s,
00590                                AVPacket *pkt)
00591 {
00592     IPMVEContext *ipmovie = s->priv_data;
00593     AVIOContext *pb = s->pb;
00594     int ret;
00595 
00596     ret = process_ipmovie_chunk(ipmovie, pb, pkt);
00597     if (ret == CHUNK_BAD)
00598         ret = AVERROR_INVALIDDATA;
00599     else if (ret == CHUNK_EOF)
00600         ret = AVERROR(EIO);
00601     else if (ret == CHUNK_NOMEM)
00602         ret = AVERROR(ENOMEM);
00603     else if (ret == CHUNK_VIDEO)
00604         ret = 0;
00605     else
00606         ret = -1;
00607 
00608     return ret;
00609 }
00610 
00611 AVInputFormat ff_ipmovie_demuxer = {
00612     "ipmovie",
00613     NULL_IF_CONFIG_SMALL("Interplay MVE format"),
00614     sizeof(IPMVEContext),
00615     ipmovie_probe,
00616     ipmovie_read_header,
00617     ipmovie_read_packet,
00618 };

Generated on Fri Feb 22 2013 07:24:31 for FFmpeg by  doxygen 1.7.1