summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraddr-see-the-website@aetey.se <addr-see-the-website@aetey.se>2014-02-02 16:57:36 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-03 02:04:38 +0100
commit8e36fc0c33566cb6fcb6379595214e7f9b909f88 (patch)
treec35c54499a4938c3fe0d86f0e9a2c4538ecd64d4
parent1bc2fa447c22df09d312a7fba7e95531cfb051f8 (diff)
RoQ encoder: support different integer framerates
Even though the most common framerate for RoQ is 30fps, the format supports other framerates too. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/roqvideoenc.c3
-rw-r--r--libavformat/idroqenc.c30
-rw-r--r--tests/fate/video.mak2
3 files changed, 30 insertions, 5 deletions
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 22ebec67a3..4b96934a65 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -963,7 +963,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
enc->framesSinceKeyframe = 0;
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
av_log(avctx, AV_LOG_ERROR, "Dimensions must be divisible by 16\n");
- return -1;
+ return AVERROR(EINVAL);
}
if (((avctx->width)&(avctx->width-1))||((avctx->height)&(avctx->height-1)))
@@ -1097,7 +1097,6 @@ AVCodec ff_roq_encoder = {
.init = roq_encode_init,
.encode2 = roq_encode_frame,
.close = roq_encode_end,
- .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 50c428046b..28a3aba9d4 100644
--- a/libavformat/idroqenc.c
+++ b/libavformat/idroqenc.c
@@ -25,9 +25,35 @@
static int roq_write_header(struct AVFormatContext *s)
{
- static const uint8_t header[] = {
- 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
+ uint8_t header[] = {
+ 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, /* fps: */ 0x1E, 0x00
};
+ int n;
+ AVCodecContext *avctx;
+
+// set the actual fps
+ for(n=0;n<s->nb_streams;n++) {
+ if ((avctx=s->streams[n]->codec)->codec_type == AVMEDIA_TYPE_VIDEO) {
+ unsigned int fps;
+
+ if (avctx->time_base.num != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Frame rate must be integer\n");
+ return AVERROR(EINVAL);
+ }
+
+ if ((fps=avctx->time_base.den) > 255) {
+ av_log(avctx, AV_LOG_ERROR, "Frame rate may not exceed 255fps\n");
+ return AVERROR(EINVAL);
+ }
+
+ if (fps != 30) {
+ av_log(avctx, AV_LOG_WARNING, "For vintage compatibility fps must be 30\n");
+ }
+
+ header[6] = fps;
+ break;
+ }
+ }
avio_write(s->pb, header, 8);
avio_flush(s->pb);
diff --git a/tests/fate/video.mak b/tests/fate/video.mak
index d00df1e405..f1e549c2d4 100644
--- a/tests/fate/video.mak
+++ b/tests/fate/video.mak
@@ -139,7 +139,7 @@ FATE_VIDEO-$(call DEMDEC, IDCIN, IDCIN) += fate-id-cin-video
fate-id-cin-video: CMD = framecrc -i $(TARGET_SAMPLES)/idcin/idlog-2MB.cin -pix_fmt rgb24
FATE_VIDEO-$(call ENCDEC, ROQ PGMYUV, ROQ IMAGE2) += fate-idroq-video-encode
-fate-idroq-video-encode: CMD = md5 -f image2 -vcodec pgmyuv -i $(TARGET_SAMPLES)/ffmpeg-synthetic/vsynth1/%02d.pgm -sws_flags +bitexact -vf pad=512:512:80:112 -f roq -t 0.2
+fate-idroq-video-encode: CMD = md5 -f image2 -vcodec pgmyuv -i $(TARGET_SAMPLES)/ffmpeg-synthetic/vsynth1/%02d.pgm -r 30 -sws_flags +bitexact -vf pad=512:512:80:112 -f roq -t 0.2
FATE_IFF-$(CONFIG_IFF_BYTERUN1_DECODER) += fate-iff-byterun1
fate-iff-byterun1: CMD = framecrc -i $(TARGET_SAMPLES)/iff/ASH.LBM -pix_fmt rgb24