[FFmpeg-devel] added variable framerates to RoQ
Benjamin Quintero
bquintero at inlandstudios.com
Sat Mar 10 01:43:37 CET 2012
I don't normally work in ffmpeg but I recently had to dive in to add missing
support to the RoQ encoder. Instead of it disappearing with me I thought
I'd submit it to the list, though I'm not sure exactly where it should be
submitted by infrequent contributors..
---------------
| idroqenc.c
---------------
// NOTES: -Ben Quintero
// Added support for RoQ to export frame rates other than 30 since some RoQ
can be 15, 24, or even 60.
static int roq_write_header(struct AVFormatContext *s)
{
/*
static const uint8_t header[] = {
0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
};
avio_write(s->pb, header, 8);
avio_flush(s->pb);
*/
AVCodecContext *enc;
short framerate;
int i;
framerate = 30;
for (i = 0; i < s->nb_streams; i++)
{
enc = s->streams[i]->codec;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
{
framerate = (int)floor((1/av_q2d(enc->time_base)) + 0.5);
break;
}
}
av_log(s, AV_LOG_INFO, "RoQ using %d as frame rate\n", framerate);
avio_w8(s->pb, 0x84);
avio_w8(s->pb, 0x10);
avio_wl32(s->pb, 0xFFFFFFFF);
avio_wl16(s->pb, framerate);
avio_flush(s->pb);
return 0;
}
---------------
| roqvideoenc.c
---------------
// NOTES: -Ben Quintero
// Removed 'supported_framerates' restriction on RoQ since that is only a
limitation of Quake3 but not other idTech games.
AVCodec ff_roq_encoder = {
.name = "roqvideo",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_ROQ,
.priv_data_size = sizeof(RoqContext),
.init = roq_encode_init,
.encode2 = roq_encode_frame,
.close = roq_encode_end,
//.supported_framerates = (const AVRational[]){{30,1}, {0,0}},
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV444P,
PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("id RoQ video"),
};
Thanks,
Ben
More information about the ffmpeg-devel
mailing list