changeset 229:f418b5c5ff67 libavcodec

PATCH by Rik Snel <rsnel@cube.dyndns.org> this patch enhances the jpeg header writer. It can be asked to omit quantisation and huffman tables and it can write different horizontal and vertical sampling factors. (the last thing is useless for libavcodec itself (because libavcodec only handles YUV420P at ecoder level), but the values are initialized so that operation of libavcodec is not impaired)
author arpi_esp
date Sat, 09 Feb 2002 01:23:41 +0000
parents 3c2bad70a196
children ba9cd6fb6f0e
files mjpeg.c mpegvideo.c mpegvideo.h
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mjpeg.c	Sat Feb 09 00:38:44 2002 +0000
+++ b/mjpeg.c	Sat Feb 09 01:23:41 2002 +0000
@@ -259,7 +259,7 @@
 {
     put_marker(&s->pb, SOI);
 
-    jpeg_table_header(s);
+    if (s->mjpeg_write_tables) jpeg_table_header(s);
 
     put_marker(&s->pb, SOF0);
 
@@ -271,20 +271,20 @@
     
     /* 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 */
--- a/mpegvideo.c	Sat Feb 09 00:38:44 2002 +0000
+++ b/mpegvideo.c	Sat Feb 09 01:23:41 2002 +0000
@@ -283,6 +283,13 @@
     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;
--- a/mpegvideo.h	Sat Feb 09 00:38:44 2002 +0000
+++ b/mpegvideo.h	Sat Feb 09 01:23:41 2002 +0000
@@ -157,6 +157,10 @@
     
     /* 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;