| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | #include "avio_internal.h" | ||
| 30 | #include "mux.h" | ||
| 31 | #include "rawenc.h" | ||
| 32 | |||
| 33 | #define RAND_TAG MKBETAG('R','a','n','d') | ||
| 34 | |||
| 35 | 1 | static av_cold int init(AVFormatContext *s) | |
| 36 | { | ||
| 37 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) { |
| 38 | ✗ | av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n"); | |
| 39 | ✗ | return AVERROR_INVALIDDATA; | |
| 40 | } | ||
| 41 | 1 | return 0; | |
| 42 | } | ||
| 43 | |||
| 44 | 1 | static int write_trailer(AVFormatContext *s) | |
| 45 | { | ||
| 46 | 1 | AVIOContext *pb = s->pb; | |
| 47 | 1 | AVStream *st = s->streams[0]; | |
| 48 | |||
| 49 | 1 | avio_wb32(pb, RAND_TAG); | |
| 50 | 1 | avio_wb32(pb, st->nb_frames); | |
| 51 | 1 | avio_wb16(pb, 0); // packing method | |
| 52 | 1 | avio_wb16(pb, 0); // reserved | |
| 53 | 1 | avio_wb16(pb, st->codecpar->width); | |
| 54 | 1 | avio_wb16(pb, st->codecpar->height); | |
| 55 | 1 | avio_wb16(pb, 0); // leading | |
| 56 | // TODO: should be avg_frame_rate | ||
| 57 | 1 | avio_wb16(pb, st->time_base.den / st->time_base.num); | |
| 58 | 1 | ffio_fill(pb, 0x00, 16); // reserved | |
| 59 | |||
| 60 | 1 | return 0; | |
| 61 | } | ||
| 62 | |||
| 63 | const FFOutputFormat ff_filmstrip_muxer = { | ||
| 64 | .p.name = "filmstrip", | ||
| 65 | .p.long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"), | ||
| 66 | .p.extensions = "flm", | ||
| 67 | .p.audio_codec = AV_CODEC_ID_NONE, | ||
| 68 | .p.video_codec = AV_CODEC_ID_RAWVIDEO, | ||
| 69 | .p.subtitle_codec = AV_CODEC_ID_NONE, | ||
| 70 | .flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | | ||
| 71 | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, | ||
| 72 | .init = init, | ||
| 73 | .write_packet = ff_raw_write_packet, | ||
| 74 | .write_trailer = write_trailer, | ||
| 75 | }; | ||
| 76 |