[Ffmpeg-devel] Specifying codec restrictions

Måns Rullgård mru
Sat Mar 4 14:28:15 CET 2006


I've been thinking about this a bit, and I've come up with an idea:

typedef struct AVCodecRestriction {
    AVRational framerate;
    PixelFormat pixfmt;
    int width;
    int height;
    int flags;
} AVCodecRestriction;

#define FRAMERATE_ALL {0,0}
#define FRAMERATE_ANY {1,0}
#define RESOLUTION_ALL 0
#define RESOLUTION_ANY -1
#define PIXELFORMAT_ALL PIX_FMT_NONE
#define PIXELFORMAT_ANY (PIX_FMT_NONE-1)

#define RESTRICTION_FLAG_WIDTH_MULTIPLE     1
#define RESTRICTION_FLAG_HEIGHT_MULTIPLE    2
#define RESTRICTION_FLAG_FRAMERATE_MULTIPLE 4

AVCodecRestriction mpeg2_restrictions[] = {
    { {24000, 1001}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {   24,    1}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {   25,    1}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {30000, 1001}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {   30,    1}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {   50,    1}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {60000, 1001}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { {   60,    1}, PIXELFORMAT_ANY, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
    { FRAMERATE_ANY, PIX_FMT_YUV420P, RESOLUTION_ALL, RESOLUTION_ALL, 0 },
};

AVCodecRestriction h263_restrictions[] = {
    { FRAME_RATE_ALL, PIX_FMT_YUV420P, 4, 4,
      RESTRICTION_FLAG_WIDTH_MULTIPLE | RESTRICTION_FLAG_HEIGHT_MULTIPLE }
};

AVCodecRestriction dv_restrictions[] = {
    { {30000, 1001}, PIX_FMT_YUV411P, 720, 480, 0 },
    { {   25,    1}, PIX_FMT_YUV420P, 720, 576, 0 },
};

Does this make any sense at all?  Some more parameters should probably
be added (SAR, audio stuff), and the constant names could be abbreviated.

Comments welcome.

-- 
M?ns Rullg?rd
mru at inprovide.com





More information about the ffmpeg-devel mailing list