00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 };