| @@ -16,6 +16,8 @@ · 15 unmodified lines |
| 16 | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | +#include "libavutil/opt.h" |
| 20 | + |
| 19 | 21 | #include "libavcodec/apv.h" |
| 20 | 22 | #include "libavcodec/bytestream.h" |
| 21 | 23 | |
| @@ -24,6 +26,10 @@ · 2 unmodified lines |
| 24 | 26 | #include "demux.h" |
| 25 | 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 | 34 | typedef struct APVHeaderInfo { |
| 29 | 35 | uint8_t pbu_type; |
| @@ -145,6 +151,7 @@ static int apv_probe(const AVProbeData *p) · 115 unmodified lines |
| 145 | 151 | |
| 146 | 152 | static int apv_read_header(AVFormatContext *s) |
| 147 | 153 | { |
| 154 | + APVDemuxerContext *apv = s->priv_data; |
| 148 | 155 | AVStream *st; |
| 149 | 156 | GetByteContext gbc; |
| 150 | 157 | uint8_t buffer[12]; |
| @@ -184,8 +191,8 @@ static int apv_read_header(AVFormatContext *s) · 33 unmodified lines |
| 184 | 191 | st->codecpar->codec_id = AV_CODEC_ID_APV; |
| 185 | 192 | |
| 186 | 193 | ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS; |
| 187 | | − st->avg_frame_rate = (AVRational){ 30, 1 }; |
| 188 | | − avpriv_set_pts_info(st, 64, 1, 30); |
| 194 | + st->avg_frame_rate = apv->framerate; |
| 195 | + avpriv_set_pts_info(st, 64, apv->framerate.den, apv->framerate.num); |
| 189 | 196 | |
| 190 | 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 | 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 | 245 | const FFInputFormat ff_apv_demuxer = { |
| 225 | 246 | .p.name = "apv", |
| 226 | 247 | .p.long_name = NULL_IF_CONFIG_SMALL("APV raw bitstream"), |
| 227 | 248 | .p.extensions = "apv", |
| 228 | 249 | .p.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS, |
| 250 | + .p.priv_class = &apv_demuxer_class, |
| 251 | + .priv_data_size = sizeof(APVDemuxerContext), |
| 229 | 252 | .read_probe = apv_probe, |
| 230 | 253 | .read_header = apv_read_header, |
| 231 | 254 | .read_packet = apv_read_packet, |