| @@ -16,6 +16,8 @@ · 15 unmodified lines |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ | 17 | */ |
| 18 | | 18 | |
| | 19 | #include "libavutil/opt.h" |
| | 20 | |
| 19 | #include "libavcodec/apv.h" | 21 | #include "libavcodec/apv.h" |
| 20 | #include "libavcodec/bytestream.h" | 22 | #include "libavcodec/bytestream.h" |
| 21 | | 23 | |
| @@ -24,6 +26,10 @@ · 2 unmodified lines |
| 24 | #include "demux.h" | 26 | #include "demux.h" |
| 25 | #include "internal.h" | 27 | #include "internal.h" |
| 26 | | 28 | |
| | 29 | typedef struct APVDemuxerContext { |
| | 30 | const AVClass *class; /**< Class for private options. */ |
| | 31 | AVRational framerate; /**< AVRational describing framerate, set by a private option. */ |
| | 32 | } APVDemuxerContext; |
| 27 | | 33 | |
| 28 | typedef struct APVHeaderInfo { | 34 | typedef struct APVHeaderInfo { |
| 29 | uint8_t pbu_type; | 35 | uint8_t pbu_type; |
| @@ -145,6 +151,7 @@ static int apv_probe(const AVProbeData *p) · 115 unmodified lines |
| 145 | | 151 | |
| 146 | static int apv_read_header(AVFormatContext *s) | 152 | static int apv_read_header(AVFormatContext *s) |
| 147 | { | 153 | { |
| | 154 | APVDemuxerContext *apv = s->priv_data; |
| 148 | AVStream *st; | 155 | AVStream *st; |
| 149 | GetByteContext gbc; | 156 | GetByteContext gbc; |
| 150 | uint8_t buffer[12]; | 157 | uint8_t buffer[12]; |
| @@ -184,8 +191,8 @@ static int apv_read_header(AVFormatContext *s) · 33 unmodified lines |
| 184 | st->codecpar->codec_id = AV_CODEC_ID_APV; | 191 | st->codecpar->codec_id = AV_CODEC_ID_APV; |
| 185 | | 192 | |
| 186 | ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS; | 193 | ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS; |
| 187 | st->avg_frame_rate = (AVRational){ 30, 1 }; | 194 | st->avg_frame_rate = apv->framerate; |
| 188 | avpriv_set_pts_info(st, 64, 1, 30); | 195 | avpriv_set_pts_info(st, 64, apv->framerate.den, apv->framerate.num); |
| 189 | | 196 | |
| 190 | avio_seek(s->pb, -size, SEEK_CUR); | 197 | avio_seek(s->pb, -size, SEEK_CUR); |
| 191 | | 198 | |
| @@ -221,11 +228,27 @@ static int apv_read_packet(AVFormatContext *s, AVPacket *pkt) · 29 unmodified lines |
| 221 | return 0; | 228 | return 0; |
| 222 | } | 229 | } |
| 223 | | 230 | |
| | 231 | #define OFFSET(x) offsetof(APVDemuxerContext, x) |
| | 232 | #define DEC AV_OPT_FLAG_DECODING_PARAM |
| | 233 | static const AVOption apv_options[] = { |
| | 234 | { "framerate", "set frame rate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "30" }, 0, INT_MAX, DEC }, |
| | 235 | { NULL }, |
| | 236 | }; |
| | 237 | |
| | 238 | static const AVClass apv_demuxer_class = { |
| | 239 | .class_name = "apv demuxer", |
| | 240 | .item_name = av_default_item_name, |
| | 241 | .option = apv_options, |
| | 242 | .version = LIBAVUTIL_VERSION_INT, |
| | 243 | }; |
| | 244 | |
| 224 | const FFInputFormat ff_apv_demuxer = { | 245 | const FFInputFormat ff_apv_demuxer = { |
| 225 | .p.name = "apv", | 246 | .p.name = "apv", |
| 226 | .p.long_name = NULL_IF_CONFIG_SMALL("APV raw bitstream"), | 247 | .p.long_name = NULL_IF_CONFIG_SMALL("APV raw bitstream"), |
| 227 | .p.extensions = "apv", | 248 | .p.extensions = "apv", |
| 228 | .p.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS, | 249 | .p.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS, |
| | 250 | .p.priv_class = &apv_demuxer_class, |
| | 251 | .priv_data_size = sizeof(APVDemuxerContext), |
| 229 | .read_probe = apv_probe, | 252 | .read_probe = apv_probe, |
| 230 | .read_header = apv_read_header, | 253 | .read_header = apv_read_header, |
| 231 | .read_packet = apv_read_packet, | 254 | .read_packet = apv_read_packet, |