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

libavformat/filmstripenc.c

Go to the documentation of this file.
00001 /*
00002  * Adobe Filmstrip muxer
00003  * Copyright (c) 2010 Peter Ross
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 
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);  // packing method
00063     put_be16(pb, 0);  // reserved
00064     put_be16(pb, st->codec->width);
00065     put_be16(pb, st->codec->height);
00066     put_be16(pb, 0);  // leading
00067     put_be16(pb, 1/av_q2d(st->codec->time_base));
00068     for (i = 0; i < 16; i++)
00069         put_byte(pb, 0x00);  // reserved
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 };

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