[FFmpeg-devel] [PATCH] Fixing computation of number of B frames for GXF muxer
Thierry Foucu
tfoucu
Thu Feb 12 00:35:53 CET 2009
For GXF muxer, the code to compute the number of B frames in a GOP is wrong.
For example:
if you have I frames: 75, P frames: 449, B frames: 374
Here is the GOP was 12 and 1 B frame between I and P
the current code will compute 0 frames per GOP.
With the patch, it will compute 5
-------------- next part --------------
Index: libavformat/gxfenc.c
===================================================================
--- libavformat/gxfenc.c (revision 17163)
+++ libavformat/gxfenc.c (working copy)
@@ -169,14 +169,19 @@
static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
{
char buffer[1024];
- int size, starting_line;
+ int size, starting_line, gop_size, nb_frames;
if (ctx->iframes) {
ctx->p_per_gop = ctx->pframes / ctx->iframes;
if (ctx->pframes % ctx->iframes)
ctx->p_per_gop++;
- if (ctx->pframes)
- ctx->b_per_gop = ctx->bframes / ctx->pframes;
+ if (ctx->pframes) {
+ nb_frames = ctx->iframes + ctx->pframes + ctx->bframes;
+ gop_size = nb_frames / ctx->iframes;
+ if (nb_frames % ctx->iframes)
+ gop_size++;
+ ctx->b_per_gop = gop_size - ctx->p_per_gop - 1;
+ }
if (ctx->p_per_gop > 9)
ctx->p_per_gop = 9; /* ensure value won't take more than one char */
if (ctx->b_per_gop > 9)
More information about the ffmpeg-devel
mailing list