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

libavformat/cdg.c

Go to the documentation of this file.
00001 /*
00002  * CD Graphics Demuxer
00003  * Copyright (c) 2009 Michael Tison
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 
00022 #include "avformat.h"
00023 
00024 #define CDG_PACKET_SIZE    24
00025 
00026 static int read_header(AVFormatContext *s, AVFormatParameters *ap)
00027 {
00028     AVStream *vst;
00029     int ret;
00030 
00031     vst = av_new_stream(s, 0);
00032     if (!vst)
00033         return AVERROR(ENOMEM);
00034 
00035     vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
00036     vst->codec->codec_id   = CODEC_ID_CDGRAPHICS;
00037 
00039     av_set_pts_info(vst, 32, 1, 300);
00040 
00041     ret = url_fsize(s->pb);
00042     if (ret > 0)
00043         vst->duration = (ret * vst->time_base.den) / (CDG_PACKET_SIZE * 300);
00044 
00045     return 0;
00046 }
00047 
00048 static int read_packet(AVFormatContext *s, AVPacket *pkt)
00049 {
00050     int ret;
00051 
00052     ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
00053 
00054     pkt->stream_index = 0;
00055     return ret;
00056 }
00057 
00058 AVInputFormat cdg_demuxer = {
00059     "cdg",
00060     NULL_IF_CONFIG_SMALL("CD Graphics Format"),
00061     0,
00062     NULL,
00063     read_header,
00064     read_packet,
00065     .extensions = "cdg"
00066 };

Generated on Fri Sep 16 2011 17:17:48 for FFmpeg by  doxygen 1.7.1