libavformat/rawvideodec.c
Go to the documentation of this file.
00001 /*
00002  * RAW video demuxer
00003  * Copyright (c) 2001 Fabrice Bellard
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 #include "rawdec.h"
00024 
00025 static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
00026 {
00027     int packet_size, ret, width, height;
00028     AVStream *st = s->streams[0];
00029 
00030     width = st->codec->width;
00031     height = st->codec->height;
00032 
00033     packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
00034     if (packet_size < 0)
00035         return -1;
00036 
00037     ret= av_get_packet(s->pb, pkt, packet_size);
00038     pkt->pts=
00039     pkt->dts= pkt->pos / packet_size;
00040 
00041     pkt->stream_index = 0;
00042     if (ret < 0)
00043         return ret;
00044     return 0;
00045 }
00046 
00047 #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
00048 #define DEC AV_OPT_FLAG_DECODING_PARAM
00049 static const AVOption rawvideo_options[] = {
00050     { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
00051     { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC },
00052     { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
00053     { NULL },
00054 };
00055 
00056 static const AVClass rawvideo_demuxer_class = {
00057     .class_name = "rawvideo demuxer",
00058     .item_name  = av_default_item_name,
00059     .option     = rawvideo_options,
00060     .version    = LIBAVUTIL_VERSION_INT,
00061 };
00062 
00063 AVInputFormat ff_rawvideo_demuxer = {
00064     .name           = "rawvideo",
00065     .long_name      = NULL_IF_CONFIG_SMALL("raw video format"),
00066     .priv_data_size = sizeof(FFRawVideoDemuxerContext),
00067     .read_header    = ff_raw_read_header,
00068     .read_packet    = rawvideo_read_packet,
00069     .flags= AVFMT_GENERIC_INDEX,
00070     .extensions = "yuv,cif,qcif,rgb",
00071     .value = CODEC_ID_RAWVIDEO,
00072     .priv_class = &rawvideo_demuxer_class,
00073 };