Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (94 sloc) 3.315 kb
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
1 /*
2 * Adobe Filmstrip demuxer
3 * Copyright (c) 2010 Peter Ross
4 *
2912e87 @mansr Replace FFmpeg with Libav in licence headers
mansr authored
5 * This file is part of Libav.
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
6 *
2912e87 @mansr Replace FFmpeg with Libav in licence headers
mansr authored
7 * Libav is free software; you can redistribute it and/or
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
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 *
2912e87 @mansr Replace FFmpeg with Libav in licence headers
mansr authored
12 * Libav is distributed in the hope that it will be useful,
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
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
2912e87 @mansr Replace FFmpeg with Libav in licence headers
mansr authored
18 * License along with Libav; if not, write to the Free Software
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
ba87f08 @DonDiego Remove explicit filename from Doxygen @file commands.
DonDiego authored
23 * @file
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
24 * Adobe Filmstrip demuxer
25 */
26
27 #include "libavutil/intreadwrite.h"
28 #include "avformat.h"
c3f9ebf @elenril lavf: make av_set_pts_info private.
elenril authored
29 #include "internal.h"
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
30
31 #define RAND_TAG MKBETAG('R','a','n','d')
32
33 typedef struct {
34 int leading;
35 } FilmstripDemuxContext;
36
37 static int read_header(AVFormatContext *s,
38 AVFormatParameters *ap)
39 {
40 FilmstripDemuxContext *film = s->priv_data;
ae628ec @elenril avio: rename ByteIOContext to AVIOContext.
elenril authored
41 AVIOContext *pb = s->pb;
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
42 AVStream *st;
43
8978fed @elenril avio: introduce an AVIOContext.seekable field
elenril authored
44 if (!s->pb->seekable)
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
45 return AVERROR(EIO);
46
76aa876 @elenril avio: avio_ prefix for url_fsize
elenril authored
47 avio_seek(pb, avio_size(pb) - 36, SEEK_SET);
b7effd4 @elenril avio: avio_ prefixes for get_* functions
elenril authored
48 if (avio_rb32(pb) != RAND_TAG) {
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
49 av_log(s, AV_LOG_ERROR, "magic number not found");
50 return AVERROR_INVALIDDATA;
51 }
52
3b3bbdd @elenril lavf,lavd: replace av_new_stream->avformat_new_stream part I.
elenril authored
53 st = avformat_new_stream(s, NULL);
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
54 if (!st)
55 return AVERROR(ENOMEM);
56
b7effd4 @elenril avio: avio_ prefixes for get_* functions
elenril authored
57 st->nb_frames = avio_rb32(pb);
58 if (avio_rb16(pb) != 0) {
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
59 av_log_ask_for_sample(s, "unsupported packing method\n");
60 return AVERROR_INVALIDDATA;
61 }
62
45a8a02 @elenril lavf: replace avio_seek(SEEK_CUR) with avio_skip where it makes sense
elenril authored
63 avio_skip(pb, 2);
72415b2 Define AVMediaType enum, and use it instead of enum CodecType, which
Stefano Sabatini authored
64 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
65 st->codec->codec_id = CODEC_ID_RAWVIDEO;
66 st->codec->pix_fmt = PIX_FMT_RGBA;
67 st->codec->codec_tag = 0; /* no fourcc */
b7effd4 @elenril avio: avio_ prefixes for get_* functions
elenril authored
68 st->codec->width = avio_rb16(pb);
69 st->codec->height = avio_rb16(pb);
70 film->leading = avio_rb16(pb);
c3f9ebf @elenril lavf: make av_set_pts_info private.
elenril authored
71 avpriv_set_pts_info(st, 64, 1, avio_rb16(pb));
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
72
6b4aa5d @elenril avio: avio_ prefix for url_fseek
elenril authored
73 avio_seek(pb, 0, SEEK_SET);
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
74
75 return 0;
76 }
77
78 static int read_packet(AVFormatContext *s,
79 AVPacket *pkt)
80 {
81 FilmstripDemuxContext *film = s->priv_data;
82 AVStream *st = s->streams[0];
83
66e5b1d @elenril avio: deprecate url_feof
elenril authored
84 if (s->pb->eof_reached)
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
85 return AVERROR(EIO);
a2704c9 @elenril avio: add avio_tell macro as a replacement for url_ftell
elenril authored
86 pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4);
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
87 pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4);
45a8a02 @elenril lavf: replace avio_seek(SEEK_CUR) with avio_skip where it makes sense
elenril authored
88 avio_skip(s->pb, st->codec->width * film->leading * 4);
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
89 if (pkt->size < 0)
90 return pkt->size;
cc947f0 Replace all occurences of PKT_FLAG_KEY with AV_PKT_FLAG_KEY.
Jean-Daniel Dupas authored
91 pkt->flags |= AV_PKT_FLAG_KEY;
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
92 return 0;
93 }
94
95 static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
96 {
97 AVStream *st = s->streams[stream_index];
6b4aa5d @elenril avio: avio_ prefix for url_fseek
elenril authored
98 avio_seek(s->pb, FFMAX(timestamp, 0) * st->codec->width * st->codec->height * 4, SEEK_SET);
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
99 return 0;
100 }
101
c6610a2 @Flameeyes Prefix all _demuxer, _muxer, _protocol from libavformat and libavdevice.
Flameeyes authored
102 AVInputFormat ff_filmstrip_demuxer = {
dfc2c4d @elenril lavf: use designated initialisers for all (de)muxers.
elenril authored
103 .name = "filmstrip",
104 .long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
105 .priv_data_size = sizeof(FilmstripDemuxContext),
106 .read_header = read_header,
107 .read_packet = read_packet,
108 .read_seek = read_seek,
83ab7f1 Adobe Filmstrip muxer and demuxer
Peter Ross authored
109 .extensions = "flm",
110 };
Something went wrong with that request. Please try again.