00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include "libavutil/intreadwrite.h"
00028 #include "avformat.h"
00029
00030 #define RAND_TAG MKBETAG('R','a','n','d')
00031
00032 typedef struct {
00033 int nb_frames;
00034 } FilmstripMuxContext;
00035
00036 static int write_header(AVFormatContext *s)
00037 {
00038 if (s->streams[0]->codec->pix_fmt != PIX_FMT_RGBA) {
00039 av_log(s, AV_LOG_ERROR, "only PIX_FMT_RGBA is supported\n");
00040 return AVERROR_INVALIDDATA;
00041 }
00042 return 0;
00043 }
00044
00045 static int write_packet(AVFormatContext *s, AVPacket *pkt)
00046 {
00047 FilmstripMuxContext *film = s->priv_data;
00048 avio_write(s->pb, pkt->data, pkt->size);
00049 film->nb_frames++;
00050 return 0;
00051 }
00052
00053 static int write_trailer(AVFormatContext *s)
00054 {
00055 FilmstripMuxContext *film = s->priv_data;
00056 AVIOContext *pb = s->pb;
00057 AVStream *st = s->streams[0];
00058 int i;
00059
00060 avio_wb32(pb, RAND_TAG);
00061 avio_wb32(pb, film->nb_frames);
00062 avio_wb16(pb, 0);
00063 avio_wb16(pb, 0);
00064 avio_wb16(pb, st->codec->width);
00065 avio_wb16(pb, st->codec->height);
00066 avio_wb16(pb, 0);
00067 avio_wb16(pb, 1/av_q2d(st->codec->time_base));
00068 for (i = 0; i < 16; i++)
00069 avio_w8(pb, 0x00);
00070 avio_flush(pb);
00071 return 0;
00072 }
00073
00074 AVOutputFormat ff_filmstrip_muxer = {
00075 .name = "filmstrip",
00076 .long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
00077 .extensions = "flm",
00078 .priv_data_size = sizeof(FilmstripMuxContext),
00079 .audio_codec = CODEC_ID_NONE,
00080 .video_codec = CODEC_ID_RAWVIDEO,
00081 .write_header = write_header,
00082 .write_packet = write_packet,
00083 .write_trailer = write_trailer,
00084 };