Mercurial > mplayer.hg
annotate libmpcodecs/vf_zrmjpeg.c @ 27445:9dce785d9ba6
Remove unused and untested function. It is only part of our local patchset.
author | diego |
---|---|
date | Fri, 22 Aug 2008 21:35:38 +0000 |
parents | e353b6f0dad5 |
children | d97a607821f1 |
rev | line source |
---|---|
19951 | 1 /** |
2 * \file vf_zrmjpeg.c | |
3 * | |
4 * \brief Does mjpeg encoding as required by the zrmjpeg filter as well | |
5 * as by the zr video driver. | |
6 */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
7 /* |
25426
288d00a5c11e
change license from GPLv2 to 'GPL v2 or later', requested by Diego, I can do that since I wrote the files (based on other stuff from MPlayer (and some external things under GPL v2 or later))
rik
parents:
25221
diff
changeset
|
8 * Copyright (C) 2005 Rik Snel <rsnel@cube.dyndns.org>, license GPL v2 or later |
19951 | 9 * - based on vd_lavc.c by A'rpi (C) 2002-2003 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
10 * - parts from ffmpeg Copyright (c) 2000-2003 Fabrice Bellard |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
11 * |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
12 * This files includes a straightforward (to be) optimized JPEG encoder for |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
13 * the YUV422 format, based on mjpeg code from ffmpeg. |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
14 * |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
15 * For an excellent introduction to the JPEG format, see: |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
16 * http://www.ece.purdue.edu/~bouman/grad-labs/lab8/pdf/lab.pdf |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
17 */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
18 #include <stdio.h> |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
19 #include <stdlib.h> |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
20 #include <string.h> |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
21 #include <inttypes.h> |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
22 |
17012 | 23 #include "config.h" |
24 #include "mp_msg.h" | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
25 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
26 #include "img_format.h" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
27 #include "mp_image.h" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
28 #include "vf.h" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
29 |
19951 | 30 /* We need this #define because we need ../libavcodec/common.h to #define |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
31 * be2me_32, otherwise the linker will complain that it doesn't exist */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
32 #define HAVE_AV_CONFIG_H |
17012 | 33 #include "libavcodec/avcodec.h" |
34 #include "libavcodec/dsputil.h" | |
35 #include "libavcodec/mpegvideo.h" | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
36 //#include "jpeg_enc.h" /* this file is not present yet */ |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
37 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
38 #undef malloc |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
39 #undef free |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
40 #undef realloc |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
41 |
25962 | 42 extern int avcodec_initialized; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
43 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
44 /* some convenient #define's, is this portable enough? */ |
19951 | 45 /// Printout with vf_zrmjpeg: prefix at VERBOSE level |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
46 #define VERBOSE(...) mp_msg(MSGT_DECVIDEO, MSGL_V, "vf_zrmjpeg: " __VA_ARGS__) |
19951 | 47 /// Printout with vf_zrmjpeg: prefix at ERROR level |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
48 #define ERROR(...) mp_msg(MSGT_DECVIDEO, MSGL_ERR, "vf_zrmjpeg: " __VA_ARGS__) |
19951 | 49 /// Printout with vf_zrmjpeg: prefix at WARNING level |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
50 #define WARNING(...) mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
51 "vf_zrmjpeg: " __VA_ARGS__) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
52 |
19951 | 53 // "local" flag in vd_ffmpeg.c. If not set, avcodec_init() et. al. need to be called |
54 // set when init is done, so that initialization is not done twice. | |
25962 | 55 extern int avcodec_initialized; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
56 |
19951 | 57 /// structure copied from mjpeg.c |
58 /* zrmjpeg_encode_mb needs access to these tables for the black & white | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
59 * option */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
60 typedef struct MJpegContext { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
61 uint8_t huff_size_dc_luminance[12]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
62 uint16_t huff_code_dc_luminance[12]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
63 uint8_t huff_size_dc_chrominance[12]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
64 uint16_t huff_code_dc_chrominance[12]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
65 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
66 uint8_t huff_size_ac_luminance[256]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
67 uint16_t huff_code_ac_luminance[256]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
68 uint8_t huff_size_ac_chrominance[256]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
69 uint16_t huff_code_ac_chrominance[256]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
70 } MJpegContext; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
71 |
19951 | 72 /// The get_pixels() routine to use. The real routine comes from dsputil |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
73 static void (*get_pixels)(DCTELEM *restrict block, const uint8_t *pixels, int line_size); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
74 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
75 /* Begin excessive code duplication ************************************/ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
76 /* Code coming from mpegvideo.c and mjpeg.c in ../libavcodec ***********/ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
77 |
19951 | 78 /// copy of the table in mpegvideo.c |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
79 static const unsigned short aanscales[64] = { |
19951 | 80 /**< precomputed values scaled up by 14 bits */ |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
81 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
82 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
83 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
84 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
85 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
86 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
87 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
88 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
89 }; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
90 |
19951 | 91 /// Precompute DCT quantizing matrix |
92 /** | |
93 * This routine will precompute the combined DCT matrix with qscale | |
94 * and DCT renorm needed by the MPEG encoder here. It is basically the | |
95 * same as the routine with the same name in mpegvideo.c, except for | |
96 * some coefficient changes. The matrix will be computed in two variations, | |
97 * depending on the DCT version used. The second used by the MMX version of DCT. | |
98 * | |
99 * \param s MpegEncContext pointer | |
100 * \param qmat[OUT] pointer to where the matrix is stored | |
101 * \param qmat16[OUT] pointer to where matrix for MMX is stored. | |
102 * This matrix is not permutated | |
103 * and second 64 entries are bias | |
104 * \param quant_matrix[IN] the quantizion matrix to use | |
105 * \param bias bias for the quantizer | |
106 * \param qmin minimum qscale value to set up for | |
107 * \param qmax maximum qscale value to set up for | |
108 * | |
109 * Only rows between qmin and qmax will be populated in the matrix. | |
110 * In this MJPEG encoder, only the value 8 for qscale is used. | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
111 */ |
19951 | 112 static void convert_matrix(MpegEncContext *s, int (*qmat)[64], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
113 uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
114 int bias, int qmin, int qmax) { |
19951 | 115 int qscale; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
116 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
117 for(qscale = qmin; qscale <= qmax; qscale++) { |
19951 | 118 int i; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
119 if (s->dsp.fdct == ff_jpeg_fdct_islow) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
120 for (i = 0; i < 64; i++) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
121 const int j = s->dsp.idct_permutation[i]; |
19951 | 122 /* 16 <= qscale * quant_matrix[i] <= 7905 |
123 * 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 | |
124 * (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
125 * >= (1<<36)/249205026 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
126 * 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ |
19951 | 127 qmat[qscale][i] = (int)((UINT64_C(1) << |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
128 (QMAT_SHIFT-3))/ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
129 (qscale*quant_matrix[j])); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
130 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
131 } else if (s->dsp.fdct == fdct_ifast) { |
19951 | 132 for (i = 0; i < 64; i++) { |
133 const int j = s->dsp.idct_permutation[i]; | |
134 /* 16 <= qscale * quant_matrix[i] <= 7905 | |
135 * 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 | |
136 * (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
137 * >= (1<<36)/249205026 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
138 * 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ |
19951 | 139 qmat[qscale][i] = (int)((UINT64_C(1) << |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
140 (QMAT_SHIFT + 11))/(aanscales[i] |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
141 *qscale * quant_matrix[j])); |
19951 | 142 } |
143 } else { | |
144 for (i = 0; i < 64; i++) { | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
145 const int j = s->dsp.idct_permutation[i]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
146 /* We can safely assume that 16 <= quant_matrix[i] <= 255 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
147 * So 16 <= qscale * quant_matrix[i] <= 7905 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
148 * so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
149 * so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67 */ |
21724
019171a44e19
compilation fixes: define always_inline and don't use uint64_t_C
rik
parents:
19951
diff
changeset
|
150 qmat[qscale][i] = (int)((UINT64_C(1) << |
19951 | 151 QMAT_SHIFT_MMX) / (qscale |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
152 *quant_matrix[j])); |
19951 | 153 qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
154 /(qscale * quant_matrix[j]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
155 |
19951 | 156 if (qmat16[qscale][0][i] == 0 || |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
157 qmat16[qscale][0][i] == 128*256) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
158 qmat16[qscale][0][i]=128*256-1; |
19951 | 159 qmat16[qscale][1][i]=ROUNDED_DIV(bias |
160 <<(16-QUANT_BIAS_SHIFT), | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
161 qmat16[qscale][0][i]); |
19951 | 162 } |
163 } | |
164 } | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
165 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
166 |
19951 | 167 /// Emit the DC value into a MJPEG code sream |
168 /** | |
169 * This routine is only intended to be used from encode_block | |
170 * | |
171 * \param s pointer to MpegEncContext structure | |
172 * \param val the DC value to emit | |
173 * \param huff_size pointer to huffman code size array | |
174 * \param huff_code pointer to the code array corresponding to \a huff_size | |
175 * | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
176 * This routine is a clone of mjpeg_encode_dc |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
177 */ |
19951 | 178 static inline void encode_dc(MpegEncContext *s, int val, |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
179 uint8_t *huff_size, uint16_t *huff_code) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
180 int mant, nbits; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
181 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
182 if (val == 0) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
183 put_bits(&s->pb, huff_size[0], huff_code[0]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
184 } else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
185 mant = val; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
186 if (val < 0) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
187 val = -val; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
188 mant--; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
189 } |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
190 nbits= av_log2_16bit(val) + 1; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
191 put_bits(&s->pb, huff_size[nbits], huff_code[nbits]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
192 put_bits(&s->pb, nbits, mant & ((1 << nbits) - 1)); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
193 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
194 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
195 |
19951 | 196 /// Huffman encode and emit one DCT block into the MJPEG code stream |
197 /** | |
198 * \param s pointer to MpegEncContext structure | |
199 * \param block pointer to the DCT block to emit | |
200 * \param n | |
201 * | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
202 * This routine is a duplicate of encode_block in mjpeg.c |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
203 */ |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
204 static void encode_block(MpegEncContext *s, DCTELEM *block, int n) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
205 int mant, nbits, code, i, j; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
206 int component, dc, run, last_index, val; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
207 MJpegContext *m = s->mjpeg_ctx; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
208 uint8_t *huff_size_ac; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
209 uint16_t *huff_code_ac; |
19951 | 210 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
211 /* DC coef */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
212 component = (n <= 3 ? 0 : n - 4 + 1); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
213 dc = block[0]; /* overflow is impossible */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
214 val = dc - s->last_dc[component]; |
19951 | 215 if (n < 4) { |
216 encode_dc(s, val, m->huff_size_dc_luminance, | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
217 m->huff_code_dc_luminance); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
218 huff_size_ac = m->huff_size_ac_luminance; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
219 huff_code_ac = m->huff_code_ac_luminance; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
220 } else { |
19951 | 221 encode_dc(s, val, m->huff_size_dc_chrominance, |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
222 m->huff_code_dc_chrominance); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
223 huff_size_ac = m->huff_size_ac_chrominance; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
224 huff_code_ac = m->huff_code_ac_chrominance; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
225 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
226 s->last_dc[component] = dc; |
19951 | 227 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
228 /* AC coefs */ |
19951 | 229 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
230 run = 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
231 last_index = s->block_last_index[n]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
232 for (i = 1; i <= last_index; i++) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
233 j = s->intra_scantable.permutated[i]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
234 val = block[j]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
235 if (val == 0) run++; |
19951 | 236 else { |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
237 while (run >= 16) { |
19951 | 238 put_bits(&s->pb, huff_size_ac[0xf0], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
239 huff_code_ac[0xf0]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
240 run -= 16; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
241 } |
19951 | 242 mant = val; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
243 if (val < 0) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
244 val = -val; |
19951 | 245 mant--; |
246 } | |
247 | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
248 nbits= av_log2_16bit(val) + 1; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
249 code = (run << 4) | nbits; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
250 |
19951 | 251 put_bits(&s->pb, huff_size_ac[code], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
252 huff_code_ac[code]); |
19951 | 253 put_bits(&s->pb, nbits, mant & ((1 << nbits) - 1)); |
254 run = 0; | |
255 } | |
256 } | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
257 |
19951 | 258 /* output EOB only if not already 64 values */ |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
259 if (last_index < 63 || run != 0) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
260 put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
261 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
262 |
19951 | 263 /// clip overflowing DCT coefficients |
264 /** | |
265 * If the computed DCT coefficients in a block overflow, this routine | |
266 * will go through them and clip them to be in the valid range. | |
267 * | |
268 * \param s pointer to MpegEncContext | |
269 * \param block pointer to DCT block to process | |
270 * \param last_index index of the last non-zero coefficient in block | |
271 * | |
272 * The max and min level, which are clipped to, are stored in | |
273 * s->min_qcoeff and s->max_qcoeff respectively. | |
274 */ | |
275 static inline void clip_coeffs(MpegEncContext *s, DCTELEM *block, | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
276 int last_index) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
277 int i; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
278 const int maxlevel= s->max_qcoeff; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
279 const int minlevel= s->min_qcoeff; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
280 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
281 for (i = 0; i <= last_index; i++) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
282 const int j = s->intra_scantable.permutated[i]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
283 int level = block[j]; |
19951 | 284 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
285 if (level > maxlevel) level=maxlevel; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
286 else if(level < minlevel) level=minlevel; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
287 block[j]= level; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
288 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
289 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
290 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
291 /* End excessive code duplication **************************************/ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
292 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
293 typedef struct { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
294 struct MpegEncContext *s; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
295 int cheap_upsample; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
296 int bw; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
297 int y_rs; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
298 int u_rs; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
299 int v_rs; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
300 } jpeg_enc_t; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
301 |
19951 | 302 // Huffman encode and emit one MCU of MJPEG code |
303 /** | |
304 * \param j pointer to jpeg_enc_t structure | |
305 * | |
306 * This function huffman encodes one MCU, and emits the | |
307 * resulting bitstream into the MJPEG code that is currently worked on. | |
308 * | |
309 * this function is a reproduction of the one in mjpeg, it includes two | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
310 * changes, it allows for black&white encoding (it skips the U and V |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
311 * macroblocks and it outputs the huffman code for 'no change' (dc) and |
19951 | 312 * 'all zero' (ac)) and it takes 4 macroblocks (422) instead of 6 (420) |
313 */ | |
21730 | 314 static av_always_inline void zr_mjpeg_encode_mb(jpeg_enc_t *j) { |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
315 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
316 MJpegContext *m = j->s->mjpeg_ctx; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
317 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
318 encode_block(j->s, j->s->block[0], 0); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
319 encode_block(j->s, j->s->block[1], 1); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
320 if (j->bw) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
321 /* U */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
322 put_bits(&j->s->pb, m->huff_size_dc_chrominance[0], |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
323 m->huff_code_dc_chrominance[0]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
324 put_bits(&j->s->pb, m->huff_size_ac_chrominance[0], |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
325 m->huff_code_ac_chrominance[0]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
326 /* V */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
327 put_bits(&j->s->pb, m->huff_size_dc_chrominance[0], |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
328 m->huff_code_dc_chrominance[0]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
329 put_bits(&j->s->pb, m->huff_size_ac_chrominance[0], |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
330 m->huff_code_ac_chrominance[0]); |
19951 | 331 } else { |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
332 /* we trick encode_block here so that it uses |
19951 | 333 * chrominance huffman tables instead of luminance ones |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
334 * (see the effect of second argument of encode_block) */ |
19951 | 335 encode_block(j->s, j->s->block[2], 4); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
336 encode_block(j->s, j->s->block[3], 5); |
19951 | 337 } |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
338 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
339 |
19951 | 340 /// Fill one DCT MCU from planar storage |
341 /** | |
342 * This routine will convert one MCU from YUYV planar storage into 4 | |
343 * DCT macro blocks, converting from 8-bit format in the planar | |
344 * storage to 16-bit format used in the DCT. | |
345 * | |
346 * \param j pointer to jpeg_enc structure, and also storage for DCT macro blocks | |
347 * \param x pixel x-coordinate for the first pixel | |
348 * \param y pixel y-coordinate for the first pixel | |
349 * \param y_data pointer to the Y plane | |
350 * \param u_data pointer to the U plane | |
351 * \param v_data pointer to the V plane | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
352 */ |
21730 | 353 static av_always_inline void fill_block(jpeg_enc_t *j, int x, int y, |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
354 unsigned char *y_data, unsigned char *u_data, |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
355 unsigned char *v_data) |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
356 { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
357 int i, k; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
358 short int *dest; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
359 unsigned char *source; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
360 |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
361 // The first Y, Y0 |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
362 get_pixels(j->s->block[0], y*8*j->y_rs + 16*x + y_data, j->y_rs); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
363 // The second Y, Y1 |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
364 get_pixels(j->s->block[1], y*8*j->y_rs + 16*x + 8 + y_data, j->y_rs); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
365 |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
366 if (!j->bw && j->cheap_upsample) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
367 source = y * 4 * j->u_rs + 8*x + u_data; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
368 dest = j->s->block[2]; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
369 for (i = 0; i < 4; i++) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
370 for (k = 0; k < 8; k++) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
371 dest[k] = source[k]; // First row |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
372 dest[k+8] = source[k]; // Duplicate to next row |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
373 |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
374 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
375 dest += 16; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
376 source += j->u_rs; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
377 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
378 source = y * 4 * j->v_rs + 8*x + v_data; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
379 dest = j->s->block[3]; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
380 for (i = 0; i < 4; i++) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
381 for (k = 0; k < 8; k++) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
382 dest[k] = source[k]; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
383 dest[k+8] = source[k]; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
384 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
385 dest += 16; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
386 source += j->u_rs; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
387 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
388 } else if (!j->bw && !j->cheap_upsample) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
389 // U |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
390 get_pixels(j->s->block[2], y*8*j->u_rs + 8*x + u_data, j->u_rs); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
391 // V |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
392 get_pixels(j->s->block[3], y*8*j->v_rs + 8*x + v_data, j->v_rs); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
393 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
394 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
395 |
19951 | 396 /** |
397 * \brief initialize mjpeg encoder | |
398 * | |
399 * This routine is to set up the parameters and initialize the mjpeg encoder. | |
400 * It does all the initializations needed of lower level routines. | |
401 * The formats accepted by this encoder is YUV422P and YUV420 | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
402 * |
19951 | 403 * \param w width in pixels of the image to encode, must be a multiple of 16 |
404 * \param h height in pixels of the image to encode, must be a multiple of 8 | |
405 * \param y_rsize size of each plane row Y component | |
406 * \param y_rsize size of each plane row U component | |
407 * \param v_rsize size of each plane row V component | |
408 * \param cu "cheap upsample". Set to 0 for YUV422 format, 1 for YUV420 format | |
409 * when set to 1, the encoder will assume that there is only half th | |
410 * number of rows of chroma information, and every chroma row is | |
411 * duplicated. | |
412 * \param q quality parameter for the mjpeg encode. Between 1 and 20 where 1 | |
413 * is best quality and 20 is the worst quality. | |
414 * \param b monochrome flag. When set to 1, the mjpeg output is monochrome. | |
415 * In that case, the colour information is omitted, and actually the | |
416 * colour planes are not touched. | |
417 * | |
418 * \returns an appropriately set up jpeg_enc_t structure | |
419 * | |
420 * The actual plane buffer addreses are passed by jpeg_enc_frame(). | |
421 * | |
422 * The encoder doesn't know anything about interlacing, the halve height | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
423 * needs to be passed and the double rowstride. Which field gets encoded |
19951 | 424 * is decided by what buffers are passed to mjpeg_encode_frame() |
425 */ | |
426 static jpeg_enc_t *jpeg_enc_init(int w, int h, int y_rsize, | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
427 int u_rsize, int v_rsize, |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
428 int cu, int q, int b) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
429 jpeg_enc_t *j; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
430 int i = 0; |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
431 VERBOSE("JPEG encoder init: %dx%d %d %d %d cu=%d q=%d bw=%d\n", |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
432 w, h, y_rsize, u_rsize, v_rsize, cu, q, b); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
433 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
434 j = av_mallocz(sizeof(jpeg_enc_t)); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
435 if (j == NULL) return NULL; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
436 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
437 j->s = av_mallocz(sizeof(MpegEncContext)); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
438 if (j->s == NULL) { |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
439 av_free(j); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
440 return NULL; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
441 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
442 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
443 /* info on how to access the pixels */ |
19951 | 444 j->y_rs = y_rsize; |
445 j->u_rs = u_rsize; | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
446 j->v_rs = v_rsize; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
447 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
448 j->s->width = w; // image width and height |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
449 j->s->height = h; |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
450 j->s->qscale = q; // Encoding quality |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
451 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
452 j->s->out_format = FMT_MJPEG; |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
453 j->s->intra_only = 1; // Generate only intra pictures for jpeg |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
454 j->s->encoding = 1; // Set mode to encode |
26291 | 455 j->s->pict_type = FF_I_TYPE; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
456 j->s->y_dc_scale = 8; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
457 j->s->c_dc_scale = 8; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
458 |
19951 | 459 /* |
460 * This sets up the MCU (Minimal Code Unit) number | |
461 * of appearances of the various component | |
462 * for the SOF0 table in the generated MJPEG. | |
463 * The values are not used for anything else. | |
464 * The current setup is simply YUV422, with two horizontal Y components | |
465 * for every UV component. | |
466 */ | |
23369
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
467 //FIXME j->s->mjpeg_write_tables = 1; // setup to write tables |
19951 | 468 j->s->mjpeg_vsample[0] = 1; // 1 appearance of Y vertically |
469 j->s->mjpeg_vsample[1] = 1; // 1 appearance of U vertically | |
470 j->s->mjpeg_vsample[2] = 1; // 1 appearance of V vertically | |
471 j->s->mjpeg_hsample[0] = 2; // 2 appearances of Y horizontally | |
472 j->s->mjpeg_hsample[1] = 1; // 1 appearance of U horizontally | |
473 j->s->mjpeg_hsample[2] = 1; // 1 appearance of V horizontally | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
474 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
475 j->cheap_upsample = cu; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
476 j->bw = b; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
477 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
478 // Is this needed? |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
479 /* if libavcodec is used by the decoder then we must not |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
480 * initialize again, but if it is not initialized then we must |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
481 * initialize it here. */ |
25962 | 482 if (!avcodec_initialized) { |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
483 avcodec_init(); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
484 avcodec_register_all(); |
25962 | 485 avcodec_initialized=1; |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
486 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
487 |
19951 | 488 // Build mjpeg huffman code tables, setting up j->s->mjpeg_ctx |
23369
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
489 if (ff_mjpeg_encode_init(j->s) < 0) { |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
490 av_free(j->s); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
491 av_free(j); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
492 return NULL; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
493 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
494 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
495 /* alloc bogus avctx to keep MPV_common_init from segfaulting */ |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
496 j->s->avctx = avcodec_alloc_context(); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
497 if (j->s->avctx == NULL) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
498 av_free(j->s); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
499 av_free(j); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
500 return NULL; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
501 } |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
502 |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
503 // Set some a minimum amount of default values that are needed |
19951 | 504 // Indicates that we should generated normal MJPEG |
19619
a83e5b8d2e63
Patch from Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
17906
diff
changeset
|
505 j->s->avctx->codec_id = CODEC_ID_MJPEG; |
19951 | 506 // Which DCT method to use. AUTO will select the fastest one |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
507 j->s->avctx->dct_algo = FF_DCT_AUTO; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
508 j->s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x |
19951 | 509 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
510 j->s->avctx->thread_count = 1; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
511 |
19951 | 512 /* make MPV_common_init allocate important buffers, like s->block |
513 * Also initializes dsputil */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
514 if (MPV_common_init(j->s) < 0) { |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
515 av_free(j->s); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
516 av_free(j); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
517 return NULL; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
518 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
519 |
19951 | 520 /* correct the value for sc->mb_height. MPV_common_init put other |
521 * values there */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
522 j->s->mb_height = j->s->height/8; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
523 j->s->mb_intra = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
524 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
525 // Init q matrix |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
526 j->s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0]; |
19951 | 527 for (i = 1; i < 64; i++) |
22339 | 528 j->s->intra_matrix[i] = av_clip_uint8( |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
529 (ff_mpeg1_default_intra_matrix[i]*j->s->qscale) >> 3); |
19951 | 530 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
531 // precompute matrix |
19951 | 532 convert_matrix(j->s, j->s->q_intra_matrix, j->s->q_intra_matrix16, |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
533 j->s->intra_matrix, j->s->intra_quant_bias, 8, 8); |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
534 |
19951 | 535 /* Pick up the selection of the optimal get_pixels() routine |
536 * to use, which was done in MPV_common_init() */ | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
537 get_pixels = j->s->dsp.get_pixels; |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
538 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
539 return j; |
19951 | 540 } |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
541 |
19951 | 542 /** |
543 * \brief mjpeg encode an image | |
544 * | |
545 * This routine will take a 3-plane YUV422 image and encoded it with MJPEG | |
546 * base line format, as suitable as input for the Zoran hardare MJPEG chips. | |
547 * | |
548 * It requires that the \a j parameter points the structure set up by the | |
549 * jpeg_enc_init() routine. | |
550 * | |
551 * \param j pointer to jpeg_enc_t structure as created by jpeg_enc_init() | |
552 * \param y_data pointer to Y component plane, packed one byte/pixel | |
553 * \param u_data pointer to U component plane, packed one byte per every | |
554 * other pixel | |
555 * \param v_data pointer to V component plane, packed one byte per every | |
556 * other pixel | |
557 * \param bufr pointer to the buffer where the mjpeg encoded code is stored | |
558 * | |
559 * \returns the number of bytes stored into \a bufr | |
560 * | |
561 * If \a j->s->mjpeg_write_tables is set, it will also emit the mjpeg tables, | |
562 * otherwise it will just emit the data. The \a j->s->mjpeg_write_tables | |
563 * variable will be reset to 0 by the routine. | |
564 */ | |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
565 static int jpeg_enc_frame(jpeg_enc_t *j, uint8_t *y_data, |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
566 uint8_t *u_data, uint8_t *v_data, uint8_t *bufr) { |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
567 int mb_x, mb_y, overflow; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
568 /* initialize the buffer */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
569 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
570 init_put_bits(&j->s->pb, bufr, 1024*256); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
571 |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
572 // Emit the mjpeg header blocks |
23369
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
573 ff_mjpeg_encode_picture_header(j->s); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
574 |
11926 | 575 j->s->header_bits = put_bits_count(&j->s->pb); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
576 |
19951 | 577 j->s->last_dc[0] = 128; |
578 j->s->last_dc[1] = 128; | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
579 j->s->last_dc[2] = 128; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
580 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
581 for (mb_y = 0; mb_y < j->s->mb_height; mb_y++) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
582 for (mb_x = 0; mb_x < j->s->mb_width; mb_x++) { |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
583 /* |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
584 * Fill one DCT block (8x8 pixels) from |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
585 * 2 Y macroblocks and one U and one V |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
586 */ |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
587 fill_block(j, mb_x, mb_y, y_data, u_data, v_data); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
588 emms_c(); /* is this really needed? */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
589 |
19951 | 590 j->s->block_last_index[0] = |
591 j->s->dct_quantize(j->s, j->s->block[0], | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
592 0, 8, &overflow); |
19951 | 593 if (overflow) clip_coeffs(j->s, j->s->block[0], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
594 j->s->block_last_index[0]); |
19951 | 595 j->s->block_last_index[1] = |
596 j->s->dct_quantize(j->s, j->s->block[1], | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
597 1, 8, &overflow); |
19951 | 598 if (overflow) clip_coeffs(j->s, j->s->block[1], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
599 j->s->block_last_index[1]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
600 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
601 if (!j->bw) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
602 j->s->block_last_index[4] = |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
603 j->s->dct_quantize(j->s, j->s->block[2], |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
604 4, 8, &overflow); |
19951 | 605 if (overflow) clip_coeffs(j->s, j->s->block[2], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
606 j->s->block_last_index[2]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
607 j->s->block_last_index[5] = |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
608 j->s->dct_quantize(j->s, j->s->block[3], |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
609 5, 8, &overflow); |
19951 | 610 if (overflow) clip_coeffs(j->s, j->s->block[3], |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
611 j->s->block_last_index[3]); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
612 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
613 zr_mjpeg_encode_mb(j); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
614 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
615 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
616 emms_c(); |
23369
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
617 ff_mjpeg_encode_picture_trailer(j->s); |
19951 | 618 flush_put_bits(&j->s->pb); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
619 |
23369
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
620 //FIXME |
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
621 //if (j->s->mjpeg_write_tables == 1) |
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
622 // j->s->mjpeg_write_tables = 0; |
19951 | 623 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
624 return pbBufPtr(&(j->s->pb)) - j->s->pb.buf; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
625 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
626 |
19951 | 627 /// the real uninit routine |
628 /** | |
629 * This is the real routine that does the uninit of the ZRMJPEG filter | |
630 * | |
631 * \param j pointer to jpeg_enc structure | |
632 */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
633 static void jpeg_enc_uninit(jpeg_enc_t *j) { |
23369
700408f4cb51
compilation fix: ff_ _encode added and temporarily disabled mjpeg_write_tables
rik
parents:
22339
diff
changeset
|
634 ff_mjpeg_encode_close(j->s); |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
635 av_free(j->s); |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
636 av_free(j); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
637 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
638 |
19951 | 639 /// Private structure for ZRMJPEG filter |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
640 struct vf_priv_s { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
641 jpeg_enc_t *j; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
642 unsigned char buf[256*1024]; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
643 int bw, fd, hdec, vdec; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
644 int fields; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
645 int y_stride; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
646 int c_stride; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
647 int quality; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
648 int maxwidth; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
649 int maxheight; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
650 }; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
651 |
19951 | 652 /// vf CONFIGURE entry point for the ZRMJPEG filter |
653 /** | |
654 * \param vf video filter instance pointer | |
655 * \param width image source width in pixels | |
656 * \param height image source height in pixels | |
657 * \param d_width width of requested window, just a hint | |
658 * \param d_height height of requested window, just a hint | |
659 * \param flags vf filter flags | |
660 * \param outfmt | |
661 * | |
662 * \returns returns 0 on error | |
663 * | |
664 * This routine will make the necessary hardware-related decisions for | |
665 * the ZRMJPEG filter, do the initialization of the MJPEG encoder, and | |
666 * then select one of the ZRJMJPEGIT or ZRMJPEGNI filters and then | |
667 * arrange to dispatch to the config() entry pointer for the one | |
668 * selected. | |
669 */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
670 static int config(struct vf_instance_s* vf, int width, int height, int d_width, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
671 int d_height, unsigned int flags, unsigned int outfmt){ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
672 struct vf_priv_s *priv = vf->priv; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
673 float aspect_decision; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
674 int stretchx, stretchy, err = 0, maxstretchx = 4; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
675 priv->fields = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
676 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
677 VERBOSE("config() called\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
678 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
679 if (priv->j) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
680 VERBOSE("re-configuring, resetting JPEG encoder\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
681 jpeg_enc_uninit(priv->j); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
682 priv->j = NULL; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
683 } |
19951 | 684 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
685 aspect_decision = ((float)d_width/(float)d_height)/ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
686 ((float)width/(float)height); |
19951 | 687 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
688 if (aspect_decision > 1.8 && aspect_decision < 2.2) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
689 VERBOSE("should correct aspect by stretching x times 2, %d %d\n", 2*width, priv->maxwidth); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
690 if (2*width <= priv->maxwidth) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
691 d_width = 2*width; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
692 d_height = height; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
693 maxstretchx = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
694 } else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
695 WARNING("unable to correct aspect by stretching, because resulting X will be too large, aspect correction by decimating y not yet implemented\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
696 d_width = width; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
697 d_height = height; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
698 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
699 /* prestretch movie */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
700 } else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
701 /* uncorrecting output for now */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
702 d_width = width; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
703 d_height = height; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
704 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
705 /* make the scaling decision |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
706 * we are capable of stretching the image in the horizontal |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
707 * direction by factors 1, 2 and 4 |
19951 | 708 * we can stretch the image in the vertical direction by a |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
709 * factor of 1 and 2 AND we must decide about interlacing */ |
19951 | 710 if (d_width > priv->maxwidth/2 || height > priv->maxheight/2 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
711 || maxstretchx == 1) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
712 stretchx = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
713 stretchy = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
714 priv->fields = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
715 if (priv->vdec == 2) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
716 priv->fields = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
717 } else if (priv->vdec == 4) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
718 priv->fields = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
719 stretchy = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
720 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
721 if (priv->hdec > maxstretchx) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
722 if (priv->fd) { |
19951 | 723 WARNING("horizontal decimation too high, " |
724 "changing to %d (use fd to keep" | |
725 " hdec=%d)\n", | |
726 maxstretchx, priv->hdec); | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
727 priv->hdec = maxstretchx; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
728 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
729 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
730 stretchx = priv->hdec; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
731 } else if (d_width > priv->maxwidth/4 || |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
732 height > priv->maxheight/4 || |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
733 maxstretchx == 2) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
734 stretchx = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
735 stretchy = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
736 priv->fields = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
737 if (priv->vdec == 2) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
738 stretchy = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
739 } else if (priv->vdec == 4) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
740 if (!priv->fd) { |
19951 | 741 WARNING("vertical decimation too high, " |
742 "changing to 2 (use fd to keep " | |
743 "vdec=4)\n"); | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
744 priv->vdec = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
745 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
746 stretchy = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
747 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
748 if (priv->hdec == 2) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
749 stretchx = 4; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
750 } else if (priv->hdec == 4) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
751 if (priv->fd) { |
19951 | 752 WARNING("horizontal decimation too high, " |
753 "changing to 2 (use fd to keep " | |
754 "hdec=4)\n"); | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
755 priv->hdec = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
756 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
757 stretchx = 4; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
758 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
759 } else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
760 /* output image is maximally stretched */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
761 stretchx = 4; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
762 stretchy = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
763 priv->fields = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
764 if (priv->vdec != 1 && !priv->fd) { |
19951 | 765 WARNING("vertical decimation too high, changing to 1 " |
766 "(use fd to keep vdec=%d)\n", | |
767 priv->vdec); | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
768 priv->vdec = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
769 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
770 if (priv->hdec != 1 && !priv->fd) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
771 WARNING("horizontal decimation too high, changing to 1 (use fd to keep hdec=%d)\n", priv->hdec); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
772 priv->hdec = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
773 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
774 } |
19951 | 775 |
776 VERBOSE("generated JPEG's %dx%s%d%s, stretched to %dx%d\n", | |
777 width/priv->hdec, (priv->fields == 2) ? "(" : "", | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
778 height/(priv->vdec*priv->fields), |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
779 (priv->fields == 2) ? "x2)" : "", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
780 (width/priv->hdec)*stretchx, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
781 (height/(priv->vdec*priv->fields))* |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
782 stretchy*priv->fields); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
783 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
784 |
19951 | 785 if ((width/priv->hdec)*stretchx > priv->maxwidth || |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
786 (height/(priv->vdec*priv->fields))* |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
787 stretchy*priv->fields > priv->maxheight) { |
19951 | 788 ERROR("output dimensions too large (%dx%d), max (%dx%d) " |
789 "insert crop to fix\n", | |
790 (width/priv->hdec)*stretchx, | |
791 (height/(priv->vdec*priv->fields))* | |
792 stretchy*priv->fields, | |
793 priv->maxwidth, priv->maxheight); | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
794 err = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
795 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
796 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
797 if (width%(16*priv->hdec) != 0) { |
19951 | 798 ERROR("width must be a multiple of 16*hdec (%d), use expand\n", |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
799 priv->hdec*16); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
800 err = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
801 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
802 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
803 if (height%(8*priv->fields*priv->vdec) != 0) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
804 ERROR("height must be a multiple of 8*fields*vdec (%d)," |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
805 " use expand\n", priv->vdec*priv->fields*8); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
806 err = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
807 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
808 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
809 if (err) return 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
810 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
811 priv->y_stride = width; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
812 priv->c_stride = width/2; |
19950
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
813 priv->j = jpeg_enc_init(width, height/priv->fields, |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
814 priv->fields*priv->y_stride, |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
815 priv->fields*priv->c_stride, |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
816 priv->fields*priv->c_stride, |
e99cd69dd08e
Patch by Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents:
19619
diff
changeset
|
817 1, priv->quality, priv->bw); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
818 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
819 if (!priv->j) return 0; |
19951 | 820 return vf_next_config(vf, width, height, d_width, d_height, flags, |
821 (priv->fields == 2) ? IMGFMT_ZRMJPEGIT : IMGFMT_ZRMJPEGNI); | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
822 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
823 |
19951 | 824 /// put_image entrypoint for the ZRMJPEG vf filter |
825 /*** | |
826 * \param vf pointer to vf_instance | |
827 * \param mpi pointer to mp_image_t structure | |
828 * \param pts | |
829 */ | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
830 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
831 struct vf_priv_s *priv = vf->priv; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
832 int size = 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
833 int i; |
19951 | 834 mp_image_t* dmpi; |
835 for (i = 0; i < priv->fields; i++) | |
836 size += jpeg_enc_frame(priv->j, | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
837 mpi->planes[0] + i*priv->y_stride, |
19951 | 838 mpi->planes[1] + i*priv->c_stride, |
839 mpi->planes[2] + i*priv->c_stride, | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
840 priv->buf + size); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
841 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
842 dmpi = vf_get_image(vf->next, IMGFMT_ZRMJPEGNI, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
843 MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
844 dmpi->planes[0] = (uint8_t*)priv->buf; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
845 dmpi->planes[1] = (uint8_t*)size; |
19951 | 846 return vf_next_put_image(vf,dmpi, pts); |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
847 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
848 |
19951 | 849 /// query_format entrypoint for the ZRMJPEG vf filter |
850 /*** | |
851 * \param vf pointer to vf_instance | |
852 * \param fmt image format to query for | |
853 * | |
854 * \returns 0 if image format in fmt is not supported | |
855 * | |
856 * Given the image format specified by \a fmt, this routine is called | |
857 * to ask if the format is supported or not. | |
858 */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
859 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
860 VERBOSE("query_format() called\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
861 |
19951 | 862 switch (fmt) { |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
863 case IMGFMT_YV12: |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
864 case IMGFMT_YUY2: |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
865 /* strictly speaking the output format of |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
866 * this filter will be known after config(), |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
867 * but everything that supports IMGFMT_ZRMJPEGNI |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
868 * should also support all other IMGFMT_ZRMJPEG* */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
869 return vf_next_query_format(vf, IMGFMT_ZRMJPEGNI); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
870 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
871 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
872 return 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
873 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
874 |
19951 | 875 /// vf UNINIT entry point for the ZRMJPEG filter |
876 /** | |
877 * \param vf pointer to the vf instance structure | |
878 */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
879 static void uninit(vf_instance_t *vf) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
880 struct vf_priv_s *priv = vf->priv; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
881 VERBOSE("uninit() called\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
882 if (priv->j) jpeg_enc_uninit(priv->j); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
883 free(priv); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
884 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
885 |
19951 | 886 /// vf OPEN entry point for the ZRMJPEG filter |
887 /** | |
888 * \param vf pointer to the vf instance structure | |
889 * \param args the argument list string for the -vf zrmjpeg command | |
890 * | |
891 * \returns 0 for error, 1 for success | |
892 * | |
893 * This routine will do some basic initialization of local structures etc., | |
894 * and then parse the command line arguments specific for the ZRMJPEG filter. | |
895 */ | |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
896 static int open(vf_instance_t *vf, char* args){ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
897 struct vf_priv_s *priv; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
898 VERBOSE("open() called: args=\"%s\"\n", args); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
899 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
900 vf->config = config; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
901 vf->put_image = put_image; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
902 vf->query_format = query_format; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
903 vf->uninit = uninit; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
904 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
905 priv = vf->priv = calloc(sizeof(*priv), 1); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
906 if (!vf->priv) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
907 ERROR("out of memory error\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
908 return 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
909 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
910 |
19951 | 911 /* maximum displayable size by zoran card, these defaults |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
912 * are for my own zoran card in PAL mode, these can be changed |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
913 * by filter options. But... in an ideal world these values would |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
914 * be queried from the vo device itself... */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
915 priv->maxwidth = 768; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
916 priv->maxheight = 576; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
917 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
918 priv->quality = 2; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
919 priv->hdec = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
920 priv->vdec = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
921 |
19951 | 922 /* if libavcodec is already initialized, we must not initialize it |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
923 * again, but if it is not initialized then we mustinitialize it now. */ |
25962 | 924 if (!avcodec_initialized) { |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
925 /* we need to initialize libavcodec */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
926 avcodec_init(); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
927 avcodec_register_all(); |
25962 | 928 avcodec_initialized=1; |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
929 } |
19951 | 930 |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
931 if (args) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
932 char *arg, *tmp, *ptr, junk; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
933 int last = 0, input; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
934 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
935 /* save arguments, to be able to safely modify them */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
936 arg = strdup(args); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
937 if (!arg) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
938 ERROR("out of memory, this is bad\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
939 return 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
940 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
941 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
942 tmp = ptr = arg; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
943 do { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
944 while (*tmp != ':' && *tmp) tmp++; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
945 if (*tmp == ':') *tmp++ = '\0'; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
946 else last = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
947 VERBOSE("processing filter option \"%s\"\n", ptr); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
948 /* These options deal with the maximum output |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
949 * resolution of the zoran card. These should |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
950 * be queried from the vo device, but it is currently |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
951 * too difficult, so the user should tell the filter */ |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
952 if (!strncmp("maxheight=", ptr, 10)) { |
19951 | 953 if (sscanf(ptr+10, "%d%c", &input, &junk) != 1) |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
954 ERROR( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
955 "error parsing parameter to \"maxheight=\", \"%s\", ignoring\n" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
956 , ptr + 10); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
957 else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
958 priv->maxheight = input; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
959 VERBOSE("setting maxheight to %d\n", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
960 priv->maxheight); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
961 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
962 } else if (!strncmp("quality=", ptr, 8)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
963 if (sscanf(ptr+8, "%d%c", &input, &junk) != 1) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
964 ERROR( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
965 "error parsing parameter to \"quality=\", \"%s\", ignoring\n" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
966 , ptr + 8); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
967 else if (input < 1 || input > 20) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
968 ERROR( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
969 "parameter to \"quality=\" out of range (1..20), %d\n", input); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
970 else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
971 priv->quality = input; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
972 VERBOSE("setting JPEG quality to %d\n", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
973 priv->quality); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
974 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
975 } else if (!strncmp("maxwidth=", ptr, 9)) { |
19951 | 976 if (sscanf(ptr+9, "%d%c", &input, &junk) != 1) |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
977 ERROR( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
978 "error parsing parameter to \"maxwidth=\", \"%s\", ignoring\n" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
979 , ptr + 9); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
980 else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
981 priv->maxwidth = input; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
982 VERBOSE("setting maxwidth to %d\n", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
983 priv->maxwidth); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
984 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
985 } else if (!strncmp("hdec=", ptr, 5)) { |
19951 | 986 if (sscanf(ptr+5, "%d%c", &input, &junk) != 1) |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
987 ERROR( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
988 "error parsing parameter to \"hdec=\", \"%s\", ignoring\n" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
989 , ptr + 9); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
990 else if (input != 1 && input != 2 && input != 4) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
991 ERROR( |
19951 | 992 "illegal parameter to \"hdec=\", %d, should be 1, 2 or 4", |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
993 input); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
994 else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
995 priv->hdec = input; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
996 VERBOSE( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
997 "setting horizontal decimation to %d\n", priv->maxwidth); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
998 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
999 } else if (!strncmp("vdec=", ptr, 5)) { |
19951 | 1000 if (sscanf(ptr+5, "%d%c", &input, &junk) != 1) |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1001 ERROR( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1002 "error parsing parameter to \"vdec=\", \"%s\", ignoring\n" |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1003 , ptr + 9); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1004 else if (input != 1 && input != 2 && input != 4) |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1005 ERROR( |
19951 | 1006 "illegal parameter to \"vdec=\", %d, should be 1, 2 or 4", |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1007 input); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1008 else { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1009 priv->vdec = input; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1010 VERBOSE( |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1011 "setting vertical decimation to %d\n", priv->maxwidth); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1012 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1013 } else if (!strcasecmp("dc10+-PAL", ptr) || |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1014 !strcasecmp("dc10-PAL", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1015 priv->maxwidth = 768; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1016 priv->maxheight = 576; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1017 VERBOSE("setting DC10(+) PAL profile\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1018 } else if (!strcasecmp("fd", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1019 priv->fd = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1020 VERBOSE("forcing decimation\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1021 } else if (!strcasecmp("nofd", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1022 priv->fd = 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1023 VERBOSE("decimate only if beautiful\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1024 } else if (!strcasecmp("bw", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1025 priv->bw = 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1026 VERBOSE("setting black and white encoding\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1027 } else if (!strcasecmp("color", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1028 priv->bw = 0; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1029 VERBOSE("setting color encoding\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1030 } else if (!strcasecmp("dc10+-NTSC", ptr) || |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1031 !strcasecmp("dc10-NTSC", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1032 priv->maxwidth = 640; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1033 priv->maxheight = 480; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1034 VERBOSE("setting DC10(+) NTSC profile\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1035 } else if (!strcasecmp("buz-PAL", ptr) || |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1036 !strcasecmp("lml33-PAL", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1037 priv->maxwidth = 720; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1038 priv->maxheight = 576; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1039 VERBOSE("setting buz/lml33 PAL profile\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1040 } else if (!strcasecmp("buz-NTSC", ptr) || |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1041 !strcasecmp("lml33-NTSC", ptr)) { |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1042 priv->maxwidth = 720; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1043 priv->maxheight = 480; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1044 VERBOSE("setting buz/lml33 NTSC profile\n"); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1045 } else { |
19951 | 1046 WARNING("ignoring unknown filter option " |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1047 "\"%s\", or missing argument\n", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1048 ptr); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1049 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1050 ptr = tmp; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1051 } while (!last); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1052 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1053 free(arg); |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1054 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1055 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1056 |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1057 return 1; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1058 } |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1059 |
25221 | 1060 const vf_info_t vf_info_zrmjpeg = { |
11662
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1061 "realtime zoran MJPEG encoding", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1062 "zrmjpeg", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1063 "Rik Snel", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1064 "", |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1065 open, |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1066 NULL |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1067 }; |
173f22eb0505
vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff
changeset
|
1068 |