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