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 put_buffer(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 ByteIOContext *pb = s->pb;
00057 AVStream *st = s->streams[0];
00058 int i;
00059
00060 put_be32(pb, RAND_TAG);
00061 put_be32(pb, film->nb_frames);
00062 put_be16(pb, 0);
00063 put_be16(pb, 0);
00064 put_be16(pb, st->codec->width);
00065 put_be16(pb, st->codec->height);
00066 put_be16(pb, 0);
00067 put_be16(pb, 1/av_q2d(st->codec->time_base));
00068 for (i = 0; i < 16; i++)
00069 put_byte(pb, 0x00);
00070 put_flush_packet(pb);
00071 return 0;
00072 }
00073
00074 AVOutputFormat filmstrip_muxer = {
00075 "filmstrip",
00076 NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
00077 NULL,
00078 "flm",
00079 sizeof(FilmstripMuxContext),
00080 CODEC_ID_NONE,
00081 CODEC_ID_RAWVIDEO,
00082 write_header,
00083 write_packet,
00084 write_trailer,
00085 };