1 /* lav_common - some general utility functionality used by multiple
2 	lavtool utilities. */
3 
4 /* Copyright (C) 2000, Rainer Johanni, Andrew Stevens */
5 /* - added scene change detection code 2001, pHilipp Zabel */
6 /* - broke some code out to lav_common.h and lav_common.c
7  *   July 2001, Shawn Sulma <lavtools@athos.cx>.  Part of these changes were
8  *   to replace the large number of globals with a handful of structs that
9  *   get passed in to the relevant functions.  Some of this may be
10  *   inefficient, subtly broken, or Wrong.  Helpful feedback is certainly
11  *   welcome.
12  */
13 /* - removed a lot of subsumed functionality and unnecessary cruft
14  *   March 2002, Matthew Marjanovic <maddog@mir.com>.
15  */
16 
17 /*
18    This program is free software; you can redistribute it and/or modify
19    it under the terms of the GNU General Public License as published by
20    the Free Software Foundation; either version 2 of the License, or
21    (at your option) any later version.
22 
23    This program is distributed in the hope that it will be useful,
24    but WITHOUT ANY WARRANTY; without even the implied warranty of
25    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26    GNU General Public License for more details.
27 
28    You should have received a copy of the GNU General Public License
29    along with this program; if not, write to the Free Software
30    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32 
33 #include "editlist.h"
34 #include "yuv4mpeg.h"
35 
36 
37 
38 #include "mjpeg_logging.h"
39 
40 
41 #define MAX_EDIT_LIST_FILES 256
42 #define MAX_JPEG_LEN (3*576*768/2)
43 
44 #define BUFFER_ALIGN 16
45 
46 /**
47  * (SS 2001-July-13)
48  * The split of the globals into three structs is somewhat arbitrary, but
49  * I've tried to do them based on role as used in lav2yuv and (my own)
50  * lav2divx.
51  * - LavParam handles data that is generally per-run dependent
52  *   (e.g. from the command line).
53  * - LavBounds contains data about bounds used in processing.  It is generally
54  *   not dependent on command line alteration.
55  * - LavBuffer contains buffers used to perform various tasks.
56  *
57  **/
58 
59 typedef struct {
60    int offset;
61    int frames;
62    int mono;
63    char *scenefile;
64    int delta_lum_threshold; /* = 4; */
65    unsigned int scene_detection_decimation; /* = 2; */
66    int output_width;
67    int output_height;
68    int interlace;
69    y4m_ratio_t sar; /* sample aspect ratio (default 0:0 == unspecified) */
70    y4m_ratio_t dar; /* 'suggested' display aspect ratio */
71    int chroma;
72 
73   int chroma_width;
74   int chroma_height;
75   int luma_size;
76   int chroma_size;
77 } LavParam;
78 
79 
80 int luminance_mean(uint8_t *frame[], int w, int h);
81 
82 int readframe(int numframe, uint8_t *frame[],
83 	      LavParam *param, EditList el);
84 
85 void writeoutYUV4MPEGheader(int out_fd, LavParam *param, EditList el,
86 			    y4m_stream_info_t *streaminfo);
87 
88 void init(LavParam *param, uint8_t *frame[]);
89 
90 
91 #ifdef HAVE_LIBDV
92 
93 #include <libdv/dv.h>
94 
95 void frame_YUV422_to_planar(uint8_t **output, uint8_t *input,
96 			    int width, int height, int chroma);
97 void lav_init_dv_decoder(void);
98 #endif
99