[FFmpeg-devel] [PATCH] RoQ encoder: support different integer framerates
u-owvm at aetey.se
u-owvm at aetey.se
Fri Jan 31 21:12:12 CET 2014
Even though the most common framerate for RoQ is 30fps,
the format supports other framerates too.
Attaching the patch.
Regards,
Rl
-------------- next part --------------
>From 7f5b836388da158cb8d3c8e244009c1f4a88e5ab Mon Sep 17 00:00:00 2001
From: Rl <addr-see-the-website at aetey.se>
Date: Fri, 31 Jan 2014 21:09:06 +0100
Subject: [PATCH 3/3] RoQ encoder: support different integer framerates
Reply-To:
Even though the most common framerate for RoQ is 30fps,
the format supports other framerates too.
---
libavcodec/roqvideoenc.c | 17 ++++++++++++++++-
libavformat/idroqenc.c | 13 +++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 07a4767..eced73f 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -961,6 +961,21 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
av_lfg_init(&enc->randctx, 1);
enc->framesSinceKeyframe = 0;
+
+ if (avctx->time_base.num != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Frame rate must be an integer\n");
+ return -1;
+ }
+
+ if (avctx->time_base.den > 255) {
+ av_log(avctx, AV_LOG_ERROR, "Frame rate may not exceed 255fps\n");
+ return -1;
+ }
+
+ if (avctx->time_base.den != 30) {
+ av_log(avctx, AV_LOG_ERROR, "Warning, for vintage compatibility fps must be 30\n");
+ }
+
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
av_log(avctx, AV_LOG_ERROR, "Dimensions must be divisible by 16\n");
return -1;
@@ -1097,7 +1112,7 @@ AVCodec ff_roq_encoder = {
.init = roq_encode_init,
.encode2 = roq_encode_frame,
.close = roq_encode_end,
- .supported_framerates = (const AVRational[]){ {30,1}, {0,0} },
+// .supported_framerates = (const AVRational[]){ {30,1}, {0,0} },
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE },
.priv_class = &roq_class,
diff --git a/libavformat/idroqenc.c b/libavformat/idroqenc.c
index 50c4280..d91fa52 100644
--- a/libavformat/idroqenc.c
+++ b/libavformat/idroqenc.c
@@ -25,9 +25,18 @@
static int roq_write_header(struct AVFormatContext *s)
{
- static const uint8_t header[] = {
- 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
+ static uint8_t header[] = {
+ 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, /* fps: */ 0x1E, 0x00
};
+ int n;
+
+// set the actual fps
+ for(n=0;n<s->nb_streams;n++) {
+ if (s->streams[n]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ header[6] = s->streams[n]->codec->time_base.den;
+ break;
+ }
+ }
avio_write(s->pb, header, 8);
avio_flush(s->pb);
--
1.6.1
More information about the ffmpeg-devel
mailing list