History

avformat/apvdec: add framerate option

Dawid Kozinski committed 1 year ago

Commit 6e8bd5d1 parent 59a66602 files · +26 −3Browse files

Unified · Split

2 files
  1. libavformat/apvdec.c +25 −2
  2. libavformat/version.h +1 −1
libavformat/apvdec.c+25−2
@@ -16,6 +16,8 @@ · 15 unmodified lines
1616 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717 */
1818
19+#include "libavutil/opt.h"
20+
1921 #include "libavcodec/apv.h"
2022 #include "libavcodec/bytestream.h"
2123
@@ -24,6 +26,10 @@ · 2 unmodified lines
2426 #include "demux.h"
2527 #include "internal.h"
2628
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;
2733
2834 typedef struct APVHeaderInfo {
2935 uint8_t pbu_type;
@@ -145,6 +151,7 @@ static int apv_probe(const AVProbeData *p) · 115 unmodified lines
145151
146152 static int apv_read_header(AVFormatContext *s)
147153 {
154+ APVDemuxerContext *apv = s->priv_data;
148155 AVStream *st;
149156 GetByteContext gbc;
150157 uint8_t buffer[12];
@@ -184,8 +191,8 @@ static int apv_read_header(AVFormatContext *s) · 33 unmodified lines
184191 st->codecpar->codec_id = AV_CODEC_ID_APV;
185192
186193 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);
189196
190197 avio_seek(s->pb, -size, SEEK_CUR);
191198
@@ -221,11 +228,27 @@ static int apv_read_packet(AVFormatContext *s, AVPacket *pkt) · 29 unmodified lines
221228 return 0;
222229 }
223230
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+
224245 const FFInputFormat ff_apv_demuxer = {
225246 .p.name = "apv",
226247 .p.long_name = NULL_IF_CONFIG_SMALL("APV raw bitstream"),
227248 .p.extensions = "apv",
228249 .p.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
250+ .p.priv_class = &apv_demuxer_class,
251+ .priv_data_size = sizeof(APVDemuxerContext),
229252 .read_probe = apv_probe,
230253 .read_header = apv_read_header,
231254 .read_packet = apv_read_packet,
libavformat/version.h+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
3232 #include "version_major.h"
3333
3434 #define LIBAVFORMAT_VERSION_MINOR 1
35−#define LIBAVFORMAT_VERSION_MICRO 100
35+#define LIBAVFORMAT_VERSION_MICRO 101
3636
3737 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3838 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t