{
put_marker(&s->pb, SOI);
- jpeg_table_header(s);
+ if (s->mjpeg_write_tables) jpeg_table_header(s);
put_marker(&s->pb, SOF0);
/* Y component */
put_bits(&s->pb, 8, 1); /* component number */
- put_bits(&s->pb, 4, 2); /* H factor */
- put_bits(&s->pb, 4, 2); /* V factor */
+ put_bits(&s->pb, 4, s->mjpeg_hsample[0]); /* H factor */
+ put_bits(&s->pb, 4, s->mjpeg_vsample[0]); /* V factor */
put_bits(&s->pb, 8, 0); /* select matrix */
/* Cb component */
put_bits(&s->pb, 8, 2); /* component number */
- put_bits(&s->pb, 4, 1); /* H factor */
- put_bits(&s->pb, 4, 1); /* V factor */
+ put_bits(&s->pb, 4, s->mjpeg_hsample[1]); /* H factor */
+ put_bits(&s->pb, 4, s->mjpeg_vsample[1]); /* V factor */
put_bits(&s->pb, 8, 0); /* select matrix */
/* Cr component */
put_bits(&s->pb, 8, 3); /* component number */
- put_bits(&s->pb, 4, 1); /* H factor */
- put_bits(&s->pb, 4, 1); /* V factor */
+ put_bits(&s->pb, 4, s->mjpeg_hsample[2]); /* H factor */
+ put_bits(&s->pb, 4, s->mjpeg_vsample[2]); /* V factor */
put_bits(&s->pb, 8, 0); /* select matrix */
/* scan header */
case CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
s->intra_only = 1; /* force intra only for jpeg */
+ s->mjpeg_write_tables = 1; /* write all tables */
+ s->mjpeg_vsample[0] = 2; /* set up default sampling factors */
+ s->mjpeg_vsample[1] = 1; /* the only currently supported values */
+ s->mjpeg_vsample[2] = 1;
+ s->mjpeg_hsample[0] = 2;
+ s->mjpeg_hsample[1] = 1;
+ s->mjpeg_hsample[2] = 1;
if (mjpeg_init(s) < 0)
return -1;
break;
/* MJPEG specific */
struct MJpegContext *mjpeg_ctx;
+ int mjpeg_vsample[3]; /* vertical sampling factors, default = {2, 1, 1} */
+ int mjpeg_hsample[3]; /* horizontal sampling factors, default = {2, 1, 1} */
+ int mjpeg_write_tables; /* do we want to have quantisation- and
+ huffmantables in the jpeg file ? */
/* MSMPEG4 specific */
int mv_table_index;