79 #define CVID_HEADER_SIZE 10
80 #define STRIP_HEADER_SIZE 12
81 #define CHUNK_HEADER_SIZE 4
83 #define MB_SIZE 4 //4x4 MBs
84 #define MB_AREA (MB_SIZE*MB_SIZE)
86 #define VECTOR_MAX 6 //six or four entries per vector depending on format
87 #define CODEBOOK_MAX 256 //size of a codebook
89 #define MAX_STRIPS 32 //Note: having fewer choices regarding the number of strips speeds up encoding (obviously)
90 #define MIN_STRIPS 1 //Note: having more strips speeds up encoding the frame (this is less obvious)
152 #ifdef CINEPAKENC_DEBUG
154 int num_v1_mode, num_v4_mode, num_mc_mode;
155 int num_v1_encs, num_v4_encs, num_skips;
165 #define OFFSET(x) offsetof(CinepakEncContext, x)
166 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
168 {
"max_extra_cb_iterations",
"Max extra codebook recalculation passes, more is better and slower",
OFFSET(max_extra_cb_iterations),
AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX,
VE },
169 {
"skip_empty_cb",
"Avoid wasting bytes, ignore vintage MacOS decoder",
OFFSET(skip_empty_cb),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
170 {
"max_strips",
"Limit strips/frame, vintage compatible is 1..3, otherwise the more the better",
OFFSET(max_max_strips),
AV_OPT_TYPE_INT, { .i64 = 3 },
MIN_STRIPS,
MAX_STRIPS,
VE },
171 {
"min_strips",
"Enforce min strips/frame, more is worse and faster, must be <= max_strips",
OFFSET(min_min_strips),
AV_OPT_TYPE_INT, { .i64 =
MIN_STRIPS },
MIN_STRIPS,
MAX_STRIPS,
VE },
172 {
"strip_number_adaptivity",
"How fast the strip number adapts, more is slightly better, much slower",
OFFSET(strip_number_delta_range),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0,
MAX_STRIPS-
MIN_STRIPS,
VE },
186 int x, mb_count, strip_buf_size, frame_buf_size;
189 av_log(avctx,
AV_LOG_ERROR,
"width and height must be multiples of four (got %ix%i)\n",
195 av_log(avctx,
AV_LOG_ERROR,
"minimal number of strips can not exceed maximal (got %i and %i)\n",
239 #ifdef CINEPAKENC_DEBUG
284 #ifdef CINEPAKENC_DEBUG
285 s->num_v1_mode = s->num_v4_mode = s->num_mc_mode = s->num_v1_encs = s->num_v4_encs = s->num_skips = 0;
301 #ifdef CINEPAKENC_DEBUG
312 #ifdef CINEPAK_REPORT_SERR
322 int64_t score1, score2, score3;
329 #ifdef CINEPAK_REPORT_SERR
336 ret += s->
lambda * 8 * mb_count;
339 for(x = 0; x < mb_count; x++) {
342 #ifdef CINEPAK_REPORT_SERR
355 *training_set_v1_shrunk = *training_set_v4_shrunk = 0;
356 for(x = 0; x < mb_count; x++) {
364 #ifdef CINEPAK_REPORT_SERR
369 for(x = 0; x < mb_count; x++) {
374 if(score1 <= score2) {
376 #ifdef CINEPAK_REPORT_SERR
382 #ifdef CINEPAK_REPORT_SERR
394 int v1_shrunk = 0, v4_shrunk = 0;
395 for(x = 0; x < mb_count; x++) {
402 #ifdef CINEPAK_REPORT_SERR
410 #ifdef CINEPAK_REPORT_SERR
415 #ifdef CINEPAK_REPORT_SERR
424 #ifdef CINEPAK_REPORT_SERR
429 #ifdef CINEPAK_REPORT_SERR
435 *training_set_v1_shrunk = v1_shrunk;
436 *training_set_v4_shrunk = v4_shrunk;
438 for(x = 0; x < mb_count; x++) {
444 if(score1 <= score2 && score1 <= score3) {
446 #ifdef CINEPAK_REPORT_SERR
450 }
else if(score2 <= score3) {
452 #ifdef CINEPAK_REPORT_SERR
458 #ifdef CINEPAK_REPORT_SERR
482 int incremental_codebook_replacement_mode = 0;
487 chunk_type_yuv+(incremental_codebook_replacement_mode?1:0) :
488 chunk_type_gray+(incremental_codebook_replacement_mode?1:0),
490 + (incremental_codebook_replacement_mode?(size+31)/32*4:0) );
497 if(incremental_codebook_replacement_mode) {
500 for(x = 0; x <
size; x++) {
506 flags = ((flags>>1) | 0x80000000);
507 for(y = 0; y < entry_size; y++)
508 buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);
509 if((flags&0xffffffff) == 0xffffffff) {
510 AV_WB32(&buf[flagsind], flags);
515 AV_WB32(&buf[flagsind], flags);
517 for(x = 0; x <
size; x++)
518 for(y = 0; y < entry_size; y++)
519 buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);
526 uint8_t * in_data[4],
int in_linesize[4],
527 uint8_t *out_data[4],
int out_linesize[4])
529 out_data[0] = in_data[0] + x + y * in_linesize[0];
530 out_linesize[0] = in_linesize[0];
533 out_data[1] = in_data[1] + (x >> 1) + (y >> 1) * in_linesize[1];
534 out_linesize[1] = in_linesize[1];
536 out_data[2] = in_data[2] + (x >> 1) + (y >> 1) * in_linesize[2];
537 out_linesize[2] = in_linesize[2];
543 int linesize[4],
int v1_vector,
strip_info *info)
549 data[0][ linesize[0]] =
550 data[0][1+ linesize[0]] = info->
v1_codebook[v1_vector*entry_size];
554 data[0][2+ linesize[0]] =
555 data[0][3+ linesize[0]] = info->
v1_codebook[v1_vector*entry_size+1];
557 data[0][2*linesize[0]] =
558 data[0][1+2*linesize[0]] =
559 data[0][ 3*linesize[0]] =
560 data[0][1+3*linesize[0]] = info->
v1_codebook[v1_vector*entry_size+2];
562 data[0][2+2*linesize[0]] =
563 data[0][3+2*linesize[0]] =
564 data[0][2+3*linesize[0]] =
565 data[0][3+3*linesize[0]] = info->
v1_codebook[v1_vector*entry_size+3];
570 data[1][ linesize[1]] =
571 data[1][1+ linesize[1]] = info->
v1_codebook[v1_vector*entry_size+4];
575 data[2][ linesize[2]] =
576 data[2][1+ linesize[2]] = info->
v1_codebook[v1_vector*entry_size+5];
582 int linesize[4],
int *v4_vector,
strip_info *info)
586 for(i = y = 0; y < 4; y += 2) {
587 for(x = 0; x < 4; x += 2, i++) {
588 data[0][x + y*linesize[0]] = info->
v4_codebook[v4_vector[i]*entry_size];
589 data[0][x+1 + y*linesize[0]] = info->
v4_codebook[v4_vector[i]*entry_size+1];
590 data[0][x + (y+1)*linesize[0]] = info->
v4_codebook[v4_vector[i]*entry_size+2];
591 data[0][x+1 + (y+1)*linesize[0]] = info->
v4_codebook[v4_vector[i]*entry_size+3];
594 data[1][(x>>1) + (y>>1)*linesize[1]] = info->
v4_codebook[v4_vector[i]*entry_size+4];
595 data[2][(x>>1) + (y>>1)*linesize[2]] = info->
v4_codebook[v4_vector[i]*entry_size+5];
602 uint8_t *a_data[4],
int a_linesize[4],
603 uint8_t *b_data[4],
int b_linesize[4])
608 memcpy(a_data[0]+y*a_linesize[0], b_data[0]+y*b_linesize[0],
613 for(p = 1; p <= 2; p++) {
614 for(y = 0; y < MB_SIZE/2; y++) {
615 memcpy(a_data[p] + y*a_linesize[p],
616 b_data[p] + y*b_linesize[p],
624 uint8_t *scratch_data[4],
int scratch_linesize[4],
625 uint8_t *last_data[4],
int last_linesize[4],
628 int x, y, z,
flags,
bits, temp_size, header_ofs, ret = 0, mb_count = s->
w * h /
MB_AREA;
629 int needs_extra_bit, should_write_temp;
630 unsigned char temp[64];
632 uint8_t *sub_scratch_data[4] = {0}, *sub_last_data[4] = {0};
633 int sub_scratch_linesize[4] = {0}, sub_last_linesize[4] = {0};
646 for(z = y = 0; y <
h; y +=
MB_SIZE) {
647 for(x = 0; x < s->
w; x +=
MB_SIZE, z++) {
651 sub_scratch_data, sub_scratch_linesize);
655 last_data, last_linesize,
656 sub_last_data, sub_last_linesize);
657 copy_mb(s, sub_scratch_data, sub_scratch_linesize,
658 sub_last_data, sub_last_linesize);
673 for(x = 0; x < mb_count; x++)
682 for(x = 0; x < mb_count; x += 32) {
684 for(y = x; y <
FFMIN(x+32, mb_count); y++)
686 flags |= 1 << (31 - y + x);
691 for(y = x; y <
FFMIN(x+32, mb_count); y++) {
697 for(z = 0; z < 4; z++)
709 flags = bits = temp_size = 0;
711 for(x = 0; x < mb_count; x++) {
715 should_write_temp = 0;
730 memcpy(&buf[ret], temp, temp_size);
734 should_write_temp = 1;
737 if(needs_extra_bit) {
745 for(z = 0; z < 4; z++)
748 if(should_write_temp) {
749 memcpy(&buf[ret], temp, temp_size);
758 memcpy(&buf[ret], temp, temp_size);
772 uint8_t *a_data[4],
int a_linesize[4],
773 uint8_t *b_data[4],
int b_linesize[4])
775 int x, y, p, d, ret = 0;
779 d = a_data[0][x + y*a_linesize[0]] - b_data[0][x + y*b_linesize[0]];
785 for(p = 1; p <= 2; p++) {
786 for(y = 0; y < MB_SIZE/2; y++) {
787 for(x = 0; x < MB_SIZE/2; x++) {
788 d = a_data[p][x + y*a_linesize[p]] - b_data[p][x + y*b_linesize[p]];
799 #define CERTAIN(x) ((x)!=ENC_UNCERTAIN)
805 int x, y, i, j, k, x2, y2, x3, y3,
plane,
shift, mbn;
809 int64_t total_error = 0;
811 uint8_t *sub_data [4], *vq_data [4];
812 int sub_linesize[4], vq_linesize[4];
814 for(mbn = i = y = 0; y <
h; y +=
MB_SIZE) {
815 for(x = 0; x < s->
w; x +=
MB_SIZE, ++mbn) {
826 for(j = y2 = 0; y2 < entry_size; y2 += 2) {
827 for(x2 = 0; x2 < 4; x2 += 2, j++) {
828 plane = y2 < 4 ? 0 : 1 + (x2 >> 1);
829 shift = y2 < 4 ? 0 : 1;
832 base[j] = (data[
plane][((x+x3) >> shift) + ((y+y3) >> shift) * linesize[
plane]] +
833 data[
plane][((x+x3) >> shift) + 1 + ((y+y3) >> shift) * linesize[
plane]] +
834 data[
plane][((x+x3) >> shift) + (((y+y3) >> shift) + 1) * linesize[plane]] +
835 data[plane][((x+x3) >>
shift) + 1 + (((y+y3) >>
shift) + 1) * linesize[
plane]]) >> 2;
840 for(j = y2 = 0; y2 <
MB_SIZE; y2 += 2) {
841 for(x2 = 0; x2 <
MB_SIZE; x2 += 2) {
842 for(k = 0; k < entry_size; k++, j++) {
843 plane = k >= 4 ? k - 3 : 0;
849 x3 = x + x2 + (k & 1);
850 y3 = y + y2 + (k >> 1);
853 base[j] = data[
plane][x3 + y3*linesize[
plane]];
876 vq_data[0] = vq_pict_buf;
878 vq_data[1] = &vq_pict_buf[
MB_AREA];
879 vq_data[2] = vq_data[1] + (
MB_AREA >> 2);
880 vq_linesize[1] = vq_linesize[2] =
MB_SIZE >> 1;
883 for(i = j = y = 0; y <
h; y +=
MB_SIZE) {
884 for(x = 0; x < s->
w; x +=
MB_SIZE, j++) {
900 vq_data, vq_linesize);
903 for(k = 0; k < 4; k++)
910 vq_data, vq_linesize);
925 uint8_t *last_data[4],
int last_linesize[4],
930 uint8_t *sub_last_data [4], *sub_pict_data [4];
931 int sub_last_linesize[4], sub_pict_linesize[4];
933 for(i = y = 0; y <
h; y +=
MB_SIZE) {
934 for(x = 0; x < s->
w; x +=
MB_SIZE, i++) {
936 sub_last_data, sub_last_linesize);
938 sub_pict_data, sub_pict_linesize);
941 sub_last_data, sub_last_linesize,
942 sub_pict_data, sub_pict_linesize);
954 buf[0] = keyframe ? 0x10: 0x11;
966 uint8_t *last_data[4],
int last_linesize[4],
968 uint8_t *scratch_data[4],
int scratch_linesize[4],
969 unsigned char *
buf, int64_t *best_score
970 #ifdef CINEPAK_REPORT_SERR
976 #ifdef CINEPAK_REPORT_SERR
982 int v1enough, v1_size, v4enough, v4_size;
983 int new_v1_size, new_v4_size;
984 int v1shrunk, v4shrunk;
994 #define SMALLEST_CODEBOOK 1
996 for(v4enough = 0, v4_size = 0; v4_size <= v1_size && !v4enough; v4_size = v4_size ? v4_size << 2 : v1_size >= SMALLEST_CODEBOOK << 2 ? v1_size >> 2 :
SMALLEST_CODEBOOK) {
1031 &v1shrunk, &v4shrunk
1032 #ifdef CINEPAK_REPORT_SERR
1043 if(new_v1_size < info.
v1_size){
1050 if(new_v4_size < info.
v4_size) {
1060 &v1shrunk, &v4shrunk
1061 #ifdef CINEPAK_REPORT_SERR
1066 if((!v1shrunk && !v4shrunk) || !extra_iterations_limit--)
break;
1071 if(new_v1_size < info.
v1_size){
1079 if(new_v4_size < info.
v4_size) {
1089 if(best_size == 0 || score < *best_score) {
1091 *best_score = score;
1092 #ifdef CINEPAK_REPORT_SERR
1096 scratch_data, scratch_linesize,
1097 last_data, last_linesize, &info,
1102 #ifdef CINEPAK_REPORT_SERR
1106 #ifdef CINEPAKENC_DEBUG
1108 memcpy(s->best_mb, s->
mb, mb_count*
sizeof(
mb_info));
1119 #ifdef CINEPAKENC_DEBUG
1131 for(x = 0; x < s->
w*h/
MB_AREA; x++)
1132 if(s->best_mb[x].best_encoding ==
ENC_V1)
1134 else if(s->best_mb[x].best_encoding ==
ENC_V4)
1149 buf[0] = isakeyframe ? 0 : 1;
1159 int isakeyframe,
unsigned char *
buf,
int buf_size)
1161 int num_strips, strip, i, y, nexty,
size, temp_size;
1162 uint8_t *last_data [4], *
data [4], *scratch_data [4];
1163 int last_linesize[4], linesize[4], scratch_linesize[4];
1164 int64_t best_score = 0, score, score_temp;
1165 #ifdef CINEPAK_REPORT_SERR
1166 int64_t best_serr = 0, serr, serr_temp;
1169 int best_nstrips = -1, best_size = -1;
1174 for(y = 0; y < s->
h; y += 2) {
1175 for(x = 0; x < s->
w; x += 2) {
1178 ir[1] = ir[0] + frame->
linesize[0];
1181 scratch_data, scratch_linesize);
1183 for(i=0; i<4; ++i) {
1185 i1 = (i&1); i2 = (i>=2);
1186 rr = ir[i2][i1*3+0];
1187 gg = ir[i2][i1*3+1];
1188 bb = ir[i2][i1*3+2];
1189 r += rr; g += gg; b += bb;
1193 rr = (2396625*rr + 4793251*gg + 1198732*bb) >> 23;
1195 else if (rr > 255) rr = 255;
1196 scratch_data[0][i1 + i2*scratch_linesize[0]] = rr;
1202 rr = (-299683*r - 599156*g + 898839*
b) >> 23;
1203 if( rr < -128) rr = -128;
1204 else if (rr > 127) rr = 127;
1205 scratch_data[1][0] = rr + 128;
1208 rr = (748893*r - 599156*g - 149737*
b) >> 23;
1209 if( rr < -128) rr = -128;
1210 else if (rr > 127) rr = 127;
1211 scratch_data[2][0] = rr + 128;
1218 for(num_strips = s->
min_strips; num_strips <= s->max_strips && num_strips <= s->
h /
MB_SIZE; num_strips++) {
1221 #ifdef CINEPAK_REPORT_SERR
1225 for(y = 0, strip = 1; y < s->
h; strip++, y = nexty) {
1228 nexty = strip * s->
h / num_strips;
1231 nexty += 4 - (nexty & 3);
1233 strip_height = nexty - y;
1234 if(strip_height <= 0) {
1249 last_data, last_linesize);
1252 scratch_data, scratch_linesize);
1254 if((temp_size =
rd_strip(s, y, strip_height, isakeyframe,
1255 last_data, last_linesize, data, linesize,
1256 scratch_data, scratch_linesize,
1258 #ifdef CINEPAK_REPORT_SERR
1264 score += score_temp;
1265 #ifdef CINEPAK_REPORT_SERR
1273 if(best_score == 0 || score < best_score) {
1275 #ifdef CINEPAK_REPORT_SERR
1280 #ifdef CINEPAK_REPORT_SERR
1281 av_log(s->
avctx,
AV_LOG_INFO,
"best number of strips so far: %2i, %12"PRId64
", %i B\n", num_strips, serr, best_size);
1286 best_nstrips = num_strips;
1290 if(num_strips - best_nstrips > 4)
1294 av_assert0(best_nstrips >= 0 && best_size >= 0);
1361 #ifdef CINEPAKENC_DEBUG
1368 #ifdef CINEPAKENC_DEBUG
1369 av_log(avctx,
AV_LOG_INFO,
"strip coding stats: %i V1 mode, %i V4 mode, %i MC mode (%i V1 encs, %i V4 encs, %i skips)\n",
1370 s->num_v1_mode, s->num_v4_mode, s->num_mc_mode, s->num_v1_encs, s->num_v4_encs, s->num_skips);
static enum AVPixelFormat pix_fmt
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static void calculate_skip_errors(CinepakEncContext *s, int h, uint8_t *last_data[4], int last_linesize[4], uint8_t *data[4], int linesize[4], strip_info *info)
#define LIBAVUTIL_VERSION_INT
packed RGB 8:8:8, 24bpp, RGBRGB...
static av_cold int init(AVCodecContext *avctx)
static int cinepak_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static void write_strip_header(CinepakEncContext *s, int y, int h, int keyframe, unsigned char *buf, int strip_size)
int strip_number_delta_range
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void get_sub_picture(CinepakEncContext *s, int x, int y, uint8_t *in_data[4], int in_linesize[4], uint8_t *out_data[4], int out_linesize[4])
int v1_codebook[CODEBOOK_MAX *VECTOR_MAX]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static int compute_mb_distortion(CinepakEncContext *s, uint8_t *a_data[4], int a_linesize[4], uint8_t *b_data[4], int b_linesize[4])
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define CHUNK_HEADER_SIZE
static int rd_strip(CinepakEncContext *s, int y, int h, int keyframe, uint8_t *last_data[4], int last_linesize[4], uint8_t *data[4], int linesize[4], uint8_t *scratch_data[4], int scratch_linesize[4], unsigned char *buf, int64_t *best_score)
int avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state)
Implementation of the Enhanced LBG Algorithm Based on the paper "Neural Networks 14:1219-1237" that c...
#define SMALLEST_CODEBOOK
int v4_codebook[CODEBOOK_MAX *VECTOR_MAX]
static const AVOption options[]
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned char * frame_buf
static void copy_mb(CinepakEncContext *s, uint8_t *a_data[4], int a_linesize[4], uint8_t *b_data[4], int b_linesize[4])
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static void decode_v1_vector(CinepakEncContext *s, uint8_t *data[4], int linesize[4], int v1_vector, strip_info *info)
int flags
A combination of AV_PKT_FLAG values.
static av_cold int cinepak_encode_init(AVCodecContext *avctx)
int width
picture width / height.
static int write_chunk_header(unsigned char *buf, int chunk_type, int chunk_size)
static void decode_v4_vector(CinepakEncContext *s, uint8_t *data[4], int linesize[4], int *v4_vector, strip_info *info)
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
#define AV_LOG_INFO
Standard information.
mb_encoding best_encoding
int avpriv_init_elbg(int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state)
Initialize the **codebook vector for the elbg algorithm.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
AVCodec ff_cinepak_encoder
Describe the class of an AVClass context structure.
#define STRIP_HEADER_SIZE
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static int encode_codebook(CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf)
static int encode_mode(CinepakEncContext *s, int h, uint8_t *scratch_data[4], int scratch_linesize[4], uint8_t *last_data[4], int last_linesize[4], strip_info *info, unsigned char *buf)
static const AVClass cinepak_class
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int max_extra_cb_iterations
common internal api header.
static int quantize(CinepakEncContext *s, int h, uint8_t *data[4], int linesize[4], int v1mode, strip_info *info, mb_encoding encoding)
unsigned char * strip_buf
unsigned char * pict_bufs[4]
static int rd_frame(CinepakEncContext *s, const AVFrame *frame, int isakeyframe, unsigned char *buf, int buf_size)
static int64_t calculate_mode_score(CinepakEncContext *s, int h, strip_info *info, int report, int *training_set_v1_shrunk, int *training_set_v4_shrunk)
#define av_malloc_array(a, b)
#define FFSWAP(type, a, b)
AVPixelFormat
Pixel format.
This structure stores compressed data.
enum AVPixelFormat pix_fmt
mode
Use these values in ebur128_init (or'ed).
static av_cold int cinepak_encode_end(AVCodecContext *avctx)
static int write_cvid_header(CinepakEncContext *s, unsigned char *buf, int num_strips, int data_size, int isakeyframe)
int keyint_min
minimum GOP size