LCOV - code coverage report
Current view: top level - libavformat - filmstripenc.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 23 25 92.0 %
Date: 2017-12-17 16:07:53 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Adobe Filmstrip muxer
       3             :  * Copyright (c) 2010 Peter Ross
       4             :  *
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : /**
      23             :  * @file
      24             :  * Adobe Filmstrip muxer
      25             :  */
      26             : 
      27             : #include "libavutil/intreadwrite.h"
      28             : #include "avformat.h"
      29             : 
      30             : #define RAND_TAG MKBETAG('R','a','n','d')
      31             : 
      32             : typedef struct FilmstripMuxContext {
      33             :     int nb_frames;
      34             : } FilmstripMuxContext;
      35             : 
      36           1 : static int write_header(AVFormatContext *s)
      37             : {
      38           1 :     if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
      39           0 :         av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n");
      40           0 :         return AVERROR_INVALIDDATA;
      41             :     }
      42           1 :     return 0;
      43             : }
      44             : 
      45          25 : static int write_packet(AVFormatContext *s, AVPacket *pkt)
      46             : {
      47          25 :     FilmstripMuxContext *film = s->priv_data;
      48          25 :     avio_write(s->pb, pkt->data, pkt->size);
      49          25 :     film->nb_frames++;
      50          25 :     return 0;
      51             : }
      52             : 
      53           1 : static int write_trailer(AVFormatContext *s)
      54             : {
      55           1 :     FilmstripMuxContext *film = s->priv_data;
      56           1 :     AVIOContext *pb = s->pb;
      57           1 :     AVStream *st = s->streams[0];
      58             :     int i;
      59             : 
      60           1 :     avio_wb32(pb, RAND_TAG);
      61           1 :     avio_wb32(pb, film->nb_frames);
      62           1 :     avio_wb16(pb, 0);  // packing method
      63           1 :     avio_wb16(pb, 0);  // reserved
      64           1 :     avio_wb16(pb, st->codecpar->width);
      65           1 :     avio_wb16(pb, st->codecpar->height);
      66           1 :     avio_wb16(pb, 0);  // leading
      67             :     // TODO: should be avg_frame_rate
      68           1 :     avio_wb16(pb, st->time_base.den / st->time_base.num);
      69          17 :     for (i = 0; i < 16; i++)
      70          16 :         avio_w8(pb, 0x00);  // reserved
      71             : 
      72           1 :     return 0;
      73             : }
      74             : 
      75             : AVOutputFormat ff_filmstrip_muxer = {
      76             :     .name              = "filmstrip",
      77             :     .long_name         = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
      78             :     .extensions        = "flm",
      79             :     .priv_data_size    = sizeof(FilmstripMuxContext),
      80             :     .audio_codec       = AV_CODEC_ID_NONE,
      81             :     .video_codec       = AV_CODEC_ID_RAWVIDEO,
      82             :     .write_header      = write_header,
      83             :     .write_packet      = write_packet,
      84             :     .write_trailer     = write_trailer,
      85             : };

Generated by: LCOV version 1.13