annotate libmpcodecs/vf_zrmjpeg.c @ 19094:e84360ee61c9

new black frame detection filter by Brian J. Murrell, Julian Hall and me.
author ivo
date Sat, 15 Jul 2006 09:18:44 +0000
parents 20aca9baf5d8
children a83e5b8d2e63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
1 /*
14429
90b4a1345b96 replace almost obsolete email address: snel@phys.uu.nl -> rsnel@cube.dyndns.org
rik
parents: 11961
diff changeset
2 * Copyright (C) 2005 Rik Snel <rsnel@cube.dyndns.org>, license GPL v2
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
3 * - based on vd_lavc.c by A'rpi (C) 2002-2003
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
4 * - parts from ffmpeg Copyright (c) 2000-2003 Fabrice Bellard
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
5 *
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
6 * This files includes a straightforward (to be) optimized JPEG encoder for
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
7 * the YUV422 format, based on mjpeg code from ffmpeg.
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
8 *
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
9 * For an excellent introduction to the JPEG format, see:
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
10 * http://www.ece.purdue.edu/~bouman/grad-labs/lab8/pdf/lab.pdf
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
11 */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
12 #include <stdio.h>
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
13 #include <stdlib.h>
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
14 #include <string.h>
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
15 #include <inttypes.h>
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
16
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15310
diff changeset
17 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15310
diff changeset
18 #include "mp_msg.h"
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
19
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
20 #include "img_format.h"
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
21 #include "mp_image.h"
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
22 #include "vf.h"
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
23
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
24 #ifdef USE_FASTMEMCPY
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15310
diff changeset
25 #include "libvo/fastmemcpy.h"
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
26 #endif
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
27
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
28 /* We need this #define because we need ../libavcodec/common.h to #define
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
29 * 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
30 #define HAVE_AV_CONFIG_H
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15310
diff changeset
31 #include "libavcodec/avcodec.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15310
diff changeset
32 #include "libavcodec/dsputil.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15310
diff changeset
33 #include "libavcodec/mpegvideo.h"
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
34
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
35 #undef malloc
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
36 #undef free
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
37 #undef realloc
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
38
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
39
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
40 /* some convenient #define's, is this portable enough? */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
41 #define VERBOSE(...) mp_msg(MSGT_DECVIDEO, MSGL_V, "vf_zrmjpeg: " __VA_ARGS__)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
42 #define ERROR(...) mp_msg(MSGT_DECVIDEO, MSGL_ERR, "vf_zrmjpeg: " __VA_ARGS__)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
43 #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
44 "vf_zrmjpeg: " __VA_ARGS__)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
45
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
46
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
47 extern int avcodec_inited;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
48
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
49 /* zrmjpeg_encode_mb needs access to these tables for the black & white
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
50 * option */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
51 typedef struct MJpegContext {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
52 uint8_t huff_size_dc_luminance[12];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
53 uint16_t huff_code_dc_luminance[12];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
54 uint8_t huff_size_dc_chrominance[12];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
55 uint16_t huff_code_dc_chrominance[12];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
56
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
57 uint8_t huff_size_ac_luminance[256];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
58 uint16_t huff_code_ac_luminance[256];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
59 uint8_t huff_size_ac_chrominance[256];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
60 uint16_t huff_code_ac_chrominance[256];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
61 } MJpegContext;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
62
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
63 /* Begin excessive code duplication ************************************/
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
64 /* 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
65
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
66 static const unsigned short aanscales[64] = {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
67 /* precomputed values scaled up by 14 bits */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 };
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
77
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
78 static void convert_matrix(MpegEncContext *s, int (*qmat)[64],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
79 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
80 int bias, int qmin, int qmax) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
81 int qscale;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
82
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
83 for(qscale = qmin; qscale <= qmax; qscale++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
84 int i;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
85 if (s->dsp.fdct == ff_jpeg_fdct_islow) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
86 for (i = 0; i < 64; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
87 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
88 /* 16 <= qscale * quant_matrix[i] <= 7905
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
89 * 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
90 * (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i])
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
91 * >= (1<<36)/249205026
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
92 * 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
93 qmat[qscale][i] = (int)((UINT64_C(1) <<
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
94 (QMAT_SHIFT-3))/
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
95 (qscale*quant_matrix[j]));
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
96 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
97 } else if (s->dsp.fdct == fdct_ifast) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
98 for (i = 0; i < 64; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
99 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
100 /* 16 <= qscale * quant_matrix[i] <= 7905
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
101 * 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
102 * (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i])
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
103 * >= (1<<36)/249205026
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
104 * 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
105 qmat[qscale][i] = (int)((UINT64_C(1) <<
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
106 (QMAT_SHIFT + 11))/(aanscales[i]
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
107 *qscale * quant_matrix[j]));
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
108 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
109 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
110 for (i = 0; i < 64; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
111 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
112 /* 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
113 * So 16 <= qscale * quant_matrix[i] <= 7905
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
114 * 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
115 * so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67 */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
116 qmat[qscale][i] = (int)((uint64_t_C(1) <<
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
117 QMAT_SHIFT_MMX) / (qscale
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
118 *quant_matrix[j]));
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
119 qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
120 /(qscale * quant_matrix[j]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
121
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
122 if (qmat16[qscale][0][i] == 0 ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
123 qmat16[qscale][0][i] == 128*256)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
124 qmat16[qscale][0][i]=128*256-1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
125 qmat16[qscale][1][i]=ROUNDED_DIV(bias
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
126 <<(16-QUANT_BIAS_SHIFT),
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
127 qmat16[qscale][0][i]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
128 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
129 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
130 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
131 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
132
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
133 static inline void encode_dc(MpegEncContext *s, int val,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
134 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
135 int mant, nbits;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
136
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
137 if (val == 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
138 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
139 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
140 mant = val;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
141 if (val < 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
142 val = -val;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
143 mant--;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
144 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
145
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
146 /* compute the log (XXX: optimize) */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
147 nbits = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
148 while (val != 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
149 val = val >> 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
150 nbits++;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
151 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
152
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
153 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
154 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
155 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
156 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
157
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
158 static void encode_block(MpegEncContext *s, DCTELEM *block, int n) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
159 int mant, nbits, code, i, j;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
160 int component, dc, run, last_index, val;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
161 MJpegContext *m = s->mjpeg_ctx;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
162 uint8_t *huff_size_ac;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
163 uint16_t *huff_code_ac;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
164
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
165 /* DC coef */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
166 component = (n <= 3 ? 0 : n - 4 + 1);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
167 dc = block[0]; /* overflow is impossible */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
168 val = dc - s->last_dc[component];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
169 if (n < 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
170 encode_dc(s, val, m->huff_size_dc_luminance,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
171 m->huff_code_dc_luminance);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
172 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
173 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
174 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
175 encode_dc(s, val, m->huff_size_dc_chrominance,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
176 m->huff_code_dc_chrominance);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
177 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
178 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
179 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
180 s->last_dc[component] = dc;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
181
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
182 /* AC coefs */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
183
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
184 run = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
185 last_index = s->block_last_index[n];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
186 for (i = 1; i <= last_index; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
187 j = s->intra_scantable.permutated[i];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
188 val = block[j];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
189 if (val == 0) run++;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
190 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
191 while (run >= 16) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
192 put_bits(&s->pb, huff_size_ac[0xf0],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
193 huff_code_ac[0xf0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
194 run -= 16;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
195 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
196 mant = val;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
197 if (val < 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
198 val = -val;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
199 mant--;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
200 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
201
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
202 /* compute the log (XXX: optimize) */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
203 nbits = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
204 while (val != 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
205 val = val >> 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
206 nbits++;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
207 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
208 code = (run << 4) | nbits;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
209
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
210 put_bits(&s->pb, huff_size_ac[code],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
211 huff_code_ac[code]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
212 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
213 run = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
214 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
215 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
216
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
217 /* output EOB only if not already 64 values */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
218 if (last_index < 63 || run != 0)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
219 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
220 }
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 static inline void clip_coeffs(MpegEncContext *s, DCTELEM *block,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
223 int last_index) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
224 int i;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
225 const int maxlevel= s->max_qcoeff;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
226 const int minlevel= s->min_qcoeff;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
227
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
228 for (i = 0; i <= last_index; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
229 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
230 int level = block[j];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
231
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
232 if (level > maxlevel) level=maxlevel;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
233 else if(level < minlevel) level=minlevel;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
234 block[j]= level;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
235 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
236 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
237
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
238 /* End excessive code duplication **************************************/
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
239
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
240 typedef struct {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
241 struct MpegEncContext *s;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
242 int cheap_upsample;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
243 int bw;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
244 int y_ps;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
245 int u_ps;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
246 int v_ps;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
247 int y_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
248 int u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
249 int v_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
250 } jpeg_enc_t;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
251
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
252 /* this function is a reproduction of the one in mjpeg, it includes two
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
253 * 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
254 * macroblocks and it outputs the huffman code for 'no change' (dc) and
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
255 * 'all zero' (ac)) and it takes 4 macroblocks (422) instead of 6 (420) */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
256 static void zr_mjpeg_encode_mb(jpeg_enc_t *j) {
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 MJpegContext *m = j->s->mjpeg_ctx;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
259
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
260 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
261 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
262 if (j->bw) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
263 /* U */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
264 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
265 m->huff_code_dc_chrominance[0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
266 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
267 m->huff_code_ac_chrominance[0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
268 /* V */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
269 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
270 m->huff_code_dc_chrominance[0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
271 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
272 m->huff_code_ac_chrominance[0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
273 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
274 /* we trick encode_block here so that it uses
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
275 * chrominance huffman tables instead of luminance ones
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
276 * (see the effect of second argument of encode_block) */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
277 encode_block(j->s, j->s->block[2], 4);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
278 encode_block(j->s, j->s->block[3], 5);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
279 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
280 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
281
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
282 /* this function can take all kinds of YUV colorspaces
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
283 * YV12, YVYU, UYVY. The necesary parameters must be set up by the caller
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
284 * y_ps means "y pixel size", y_rs means "y row size".
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
285 * For YUYV, for example, is u_buf = y_buf + 1, v_buf = y_buf + 3,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
286 * y_ps = 2, u_ps = 4, v_ps = 4, y_rs = u_rs = v_rs.
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
287 *
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
288 * The actual buffers must be passed with mjpeg_encode_frame, this is
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
289 * to make it possible to call encode on the buffer provided by the
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
290 * codec in draw_frame.
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
291 *
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
292 * The data is straightened out at the moment it is put in DCT
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
293 * blocks, there are therefore no spurious memcopies involved */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
294 /* Notice that w must be a multiple of 16 and h must be a multiple of 8 */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
295 /* We produce YUV422 jpegs, the colors must be subsampled horizontally,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
296 * if the colors are also subsampled vertically, then this function
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
297 * performs cheap upsampling (better solution will be: a DCT that is
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
298 * optimized in the case that every two rows are the same) */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
299 /* cu = 0 means 'No cheap upsampling'
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
300 * cu = 1 means 'perform cheap upsampling' */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
301 /* The encoder doesn't know anything about interlacing, the halve height
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
302 * needs to be passed and the double rowstride. Which field gets encoded
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
303 * is decided by what buffers are passed to mjpeg_encode_frame */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
304 static jpeg_enc_t *jpeg_enc_init(int w, int h, int y_psize, int y_rsize,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
305 int u_psize, int u_rsize, int v_psize, int v_rsize,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
306 int cu, int q, int b) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
307 jpeg_enc_t *j;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
308 int i = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
309 VERBOSE("JPEG encoder init: %dx%d %d %d %d %d %d %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
310 w, h, y_psize, y_rsize, u_psize,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
311 u_rsize, v_psize, v_rsize);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
312
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
313 j = malloc(sizeof(jpeg_enc_t));
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
314 if (j == NULL) return NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
315
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
316 j->s = malloc(sizeof(MpegEncContext));
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
317 memset(j->s,0x00,sizeof(MpegEncContext));
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
318 if (j->s == NULL) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
319 free(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
320 return NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
321 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
322
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
323 /* info on how to access the pixels */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
324 j->y_ps = y_psize;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
325 j->u_ps = u_psize;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
326 j->v_ps = v_psize;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
327 j->y_rs = y_rsize;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
328 j->u_rs = u_rsize;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
329 j->v_rs = v_rsize;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
330
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
331 j->s->width = w;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
332 j->s->height = h;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
333 j->s->qscale = q;
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 j->s->mjpeg_data_only_frames = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
336 j->s->out_format = FMT_MJPEG;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
337 j->s->intra_only = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
338 j->s->encoding = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
339 j->s->pict_type = I_TYPE;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
340 j->s->y_dc_scale = 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
341 j->s->c_dc_scale = 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
342
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
343 j->s->mjpeg_write_tables = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
344 j->s->mjpeg_vsample[0] = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
345 j->s->mjpeg_vsample[1] = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
346 j->s->mjpeg_vsample[2] = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
347 j->s->mjpeg_hsample[0] = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
348 j->s->mjpeg_hsample[1] = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
349 j->s->mjpeg_hsample[2] = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
350
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
351 j->cheap_upsample = cu;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
352 j->bw = b;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
353
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
354 if (mjpeg_init(j->s) < 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
355 free(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
356 free(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
357 return NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
358 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
359
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
360 /* alloc bogus avctx to keep MPV_common_init from segfaulting */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
361 j->s->avctx = calloc(sizeof(*j->s->avctx), 1);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
362
11961
487d1638d161 fixing segfault: libavcodec doesn't allocate some buffers if avctx->thread_count == 0
rik
parents: 11926
diff changeset
363 /* make MPV_common_init allocate important buffers, like s->block */
487d1638d161 fixing segfault: libavcodec doesn't allocate some buffers if avctx->thread_count == 0
rik
parents: 11926
diff changeset
364 j->s->avctx->thread_count = 1;
487d1638d161 fixing segfault: libavcodec doesn't allocate some buffers if avctx->thread_count == 0
rik
parents: 11926
diff changeset
365
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
366 if (MPV_common_init(j->s) < 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
367 free(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
368 free(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
369 return NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
370 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
371
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
372 /* correct the value for sc->mb_height */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
373 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
374 j->s->mb_intra = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
375
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
376 j->s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
377 for (i = 1; i < 64; i++)
15310
b01679500a5e compilation fix (libavcodec sync)
rik
parents: 14429
diff changeset
378 j->s->intra_matrix[i] = clip_uint8(
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
379 (ff_mpeg1_default_intra_matrix[i]*j->s->qscale) >> 3);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
380 convert_matrix(j->s, j->s->q_intra_matrix, j->s->q_intra_matrix16,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
381 j->s->intra_matrix, j->s->intra_quant_bias, 8, 8);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
382 return j;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
383 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
384
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
385 static int jpeg_enc_frame(jpeg_enc_t *j, unsigned char *y_data,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
386 unsigned char *u_data, unsigned char *v_data, char *bufr) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
387 int i, k, mb_x, mb_y, overflow;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
388 short int *dest;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
389 unsigned char *source;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
390 /* initialize the buffer */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
391
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
392 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
393
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
394 mjpeg_picture_header(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
395
11926
243767239228 get_bit_count -> put_bits_count
rik
parents: 11662
diff changeset
396 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
397
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
398 j->s->last_dc[0] = 128;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
399 j->s->last_dc[1] = 128;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
400 j->s->last_dc[2] = 128;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
401
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
402 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
403 for (mb_x = 0; mb_x < j->s->mb_width; mb_x++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
404 /* conversion 8 to 16 bit and filling of blocks
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
405 * must be mmx optimized */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
406 /* fill 2 Y macroblocks and one U and one V */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
407 source = mb_y * 8 * j->y_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
408 16 * j->y_ps * mb_x + y_data;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
409 dest = j->s->block[0];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
410 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
411 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
412 dest[k] = source[k*j->y_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
413 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
414 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
415 source += j->y_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
416 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
417 source = mb_y * 8 * j->y_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
418 (16*mb_x + 8)*j->y_ps + y_data;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
419 dest = j->s->block[1];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
420 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
421 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
422 dest[k] = source[k*j->y_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
423 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
424 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
425 source += j->y_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
426 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
427 if (!j->bw && j->cheap_upsample) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
428 source = mb_y*4*j->u_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
429 8*mb_x*j->u_ps + u_data;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
430 dest = j->s->block[2];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
431 for (i = 0; i < 4; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
432 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
433 dest[k] = source[k*j->u_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
434 dest[k+8] = source[k*j->u_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
435 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
436 dest += 16;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
437 source += j->u_rs;
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 source = mb_y*4*j->v_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
440 8*mb_x*j->v_ps + v_data;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
441 dest = j->s->block[3];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
442 for (i = 0; i < 4; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
443 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
444 dest[k] = source[k*j->v_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
445 dest[k+8] = source[k*j->v_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
446 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
447 dest += 16;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
448 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
449 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
450 } else if (!j->bw && !j->cheap_upsample) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
451 source = mb_y*8*j->u_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
452 8*mb_x*j->u_ps + u_data;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
453 dest = j->s->block[2];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
454 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
455 for (k = 0; k < 8; k++)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
456 dest[k] = source[k*j->u_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
457 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
458 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
459 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
460 source = mb_y*8*j->v_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
461 8*mb_x*j->v_ps + v_data;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
462 dest = j->s->block[3];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
463 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
464 for (k = 0; k < 8; k++)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
465 dest[k] = source[k*j->v_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
466 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
467 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
468 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
469 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
470 emms_c(); /* is this really needed? */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
471
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
472 j->s->block_last_index[0] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
473 j->s->dct_quantize(j->s, j->s->block[0],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
474 0, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
475 if (overflow) clip_coeffs(j->s, j->s->block[0],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
476 j->s->block_last_index[0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
477 j->s->block_last_index[1] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
478 j->s->dct_quantize(j->s, j->s->block[1],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
479 1, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
480 if (overflow) clip_coeffs(j->s, j->s->block[1],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
481 j->s->block_last_index[1]);
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 if (!j->bw) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
484 j->s->block_last_index[4] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
485 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
486 4, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
487 if (overflow) clip_coeffs(j->s, j->s->block[2],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
488 j->s->block_last_index[2]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
489 j->s->block_last_index[5] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
490 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
491 5, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
492 if (overflow) clip_coeffs(j->s, j->s->block[3],
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
493 j->s->block_last_index[3]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
494 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
495 zr_mjpeg_encode_mb(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
496 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
497 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
498 emms_c();
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
499 mjpeg_picture_trailer(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
500 flush_put_bits(&j->s->pb);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
501
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
502 if (j->s->mjpeg_write_tables == 1)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
503 j->s->mjpeg_write_tables = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
504
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
505 return pbBufPtr(&(j->s->pb)) - j->s->pb.buf;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
506 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
507
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
508 static void jpeg_enc_uninit(jpeg_enc_t *j) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
509 mjpeg_close(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
510 free(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
511 free(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
512 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
513
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
514 struct vf_priv_s {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
515 jpeg_enc_t *j;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
516 unsigned char buf[256*1024];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
517 int bw, fd, hdec, vdec;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
518 int fields;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
519 int y_stride;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
520 int c_stride;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
521 int quality;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
522 int maxwidth;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
523 int maxheight;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
524 };
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
525
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
526 static int config(struct vf_instance_s* vf, int width, int height, int d_width,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
527 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
528 struct vf_priv_s *priv = vf->priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
529 float aspect_decision;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
530 int stretchx, stretchy, err = 0, maxstretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
531 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
532
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
533 VERBOSE("config() called\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
534
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
535 if (priv->j) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
536 VERBOSE("re-configuring, resetting JPEG encoder\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
537 jpeg_enc_uninit(priv->j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
538 priv->j = NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
539 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
540
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
541 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
542 ((float)width/(float)height);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
543
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
544 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
545 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
546 if (2*width <= priv->maxwidth) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
547 d_width = 2*width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
548 d_height = height;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
549 maxstretchx = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
550 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
551 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
552 d_width = width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
553 d_height = height;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
554 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
555 /* prestretch movie */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
556 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
557 /* uncorrecting output for now */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
558 d_width = width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
559 d_height = height;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
560 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
561 /* make the scaling decision
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
562 * 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
563 * direction by factors 1, 2 and 4
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
564 * we can stretch the image in the vertical direction by a
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
565 * factor of 1 and 2 AND we must decide about interlacing */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
566 if (d_width > priv->maxwidth/2 || height > priv->maxheight/2
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
567 || maxstretchx == 1) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
568 stretchx = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
569 stretchy = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
570 priv->fields = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
571 if (priv->vdec == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
572 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
573 } else if (priv->vdec == 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
574 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
575 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
576 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
577 if (priv->hdec > maxstretchx) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
578 if (priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
579 WARNING("horizontal decimation too high, changing to %d (use fd to keep hdec=%d)\n", maxstretchx, priv->hdec);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
580 priv->hdec = maxstretchx;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
581 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
582 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
583 stretchx = priv->hdec;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
584 } else if (d_width > priv->maxwidth/4 ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
585 height > priv->maxheight/4 ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
586 maxstretchx == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
587 stretchx = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
588 stretchy = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
589 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
590 if (priv->vdec == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
591 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
592 } else if (priv->vdec == 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
593 if (!priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
594 WARNING("vertical decimation too high, changing to 2 (use fd to keep vdec=4)\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
595 priv->vdec = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
596 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
597 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
598 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
599 if (priv->hdec == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
600 stretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
601 } else if (priv->hdec == 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
602 if (priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
603 WARNING("horizontal decimation too high, changing to 2 (use fd to keep hdec=4)\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
604 priv->hdec = 2;
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 stretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
607 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
608 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
609 /* output image is maximally stretched */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
610 stretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
611 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
612 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
613 if (priv->vdec != 1 && !priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
614 WARNING("vertical decimation too high, changing to 1 (use fd to keep vdec=%d)\n", priv->vdec);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
615 priv->vdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
616 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
617 if (priv->hdec != 1 && !priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
618 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
619 priv->hdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
620 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
621 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
622
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
623 VERBOSE("generated JPEG's %dx%s%d%s, stretched to %dx%d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
624 width/priv->hdec, (priv->fields == 2) ? "(" : "",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
625 height/(priv->vdec*priv->fields),
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
626 (priv->fields == 2) ? "x2)" : "",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
627 (width/priv->hdec)*stretchx,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
628 (height/(priv->vdec*priv->fields))*
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
629 stretchy*priv->fields);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
630
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
631
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
632 if ((width/priv->hdec)*stretchx > priv->maxwidth ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
633 (height/(priv->vdec*priv->fields))*
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
634 stretchy*priv->fields > priv->maxheight) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
635 ERROR("output dimensions too large (%dx%d), max (%dx%d) insert crop to fix\n", (width/priv->hdec)*stretchx, (height/(priv->vdec*priv->fields))*stretchy*priv->fields, priv->maxwidth, priv->maxheight);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
636 err = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
637 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
638
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
639 if (width%(16*priv->hdec) != 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
640 ERROR("width must be a multiple of 16*hdec (%d), use expand\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
641 priv->hdec*16);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
642 err = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
643 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
644
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
645 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
646 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
647 " 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
648 err = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
649 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
650
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
651 if (err) return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
652
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
653 priv->y_stride = width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
654 priv->c_stride = width/2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
655 priv->j = jpeg_enc_init(width, height/priv->fields, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
656 priv->fields*priv->y_stride, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
657 priv->fields*priv->c_stride, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
658 priv->fields*priv->c_stride, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
659 priv->quality, priv->bw);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
660
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
661 if (!priv->j) return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
662 return vf_next_config(vf, width, height, d_width, d_height, flags,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
663 (priv->fields == 2) ? IMGFMT_ZRMJPEGIT : IMGFMT_ZRMJPEGNI);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
664 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
665
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
666 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
667 struct vf_priv_s *priv = vf->priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
668 int size = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
669 int i;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
670 mp_image_t* dmpi;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
671 for (i = 0; i < priv->fields; i++)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
672 size += jpeg_enc_frame(priv->j,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
673 mpi->planes[0] + i*priv->y_stride,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
674 mpi->planes[1] + i*priv->c_stride,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
675 mpi->planes[2] + i*priv->c_stride,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
676 priv->buf + size);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
677
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
678 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
679 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
680 dmpi->planes[0] = (uint8_t*)priv->buf;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
681 dmpi->planes[1] = (uint8_t*)size;
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
682 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
683 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
684
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
685 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
686 VERBOSE("query_format() called\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
687
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
688 switch (fmt) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
689 case IMGFMT_YV12:
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
690 case IMGFMT_YUY2:
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
691 /* strictly speaking the output format of
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
692 * this filter will be known after config(),
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
693 * but everything that supports IMGFMT_ZRMJPEGNI
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
694 * should also support all other IMGFMT_ZRMJPEG* */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
695 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
696 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
697
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
698 return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
699 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
700
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
701 static void uninit(vf_instance_t *vf) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
702 struct vf_priv_s *priv = vf->priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
703 VERBOSE("uninit() called\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
704 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
705 free(priv);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
706 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
707
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
708 static int open(vf_instance_t *vf, char* args){
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
709 struct vf_priv_s *priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
710 VERBOSE("open() called: args=\"%s\"\n", args);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
711
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
712 vf->config = config;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
713 vf->put_image = put_image;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
714 vf->query_format = query_format;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
715 vf->uninit = uninit;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
716
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
717 priv = vf->priv = calloc(sizeof(*priv), 1);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
718 if (!vf->priv) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
719 ERROR("out of memory error\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
720 return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
721 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
722
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
723 /* maximum displayable size by zoran card, these defaults
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
724 * 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
725 * 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
726 * be queried from the vo device itself... */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
727 priv->maxwidth = 768;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
728 priv->maxheight = 576;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
729
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
730 priv->quality = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
731 priv->hdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
732 priv->vdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
733
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
734 /* if libavcodec is already initialized, we must not initialize it
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
735 * again, but if it is not initialized then we mustinitialize it now. */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
736 if (!avcodec_inited) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
737 /* we need to initialize libavcodec */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
738 avcodec_init();
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
739 avcodec_register_all();
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
740 avcodec_inited=1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
741 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
742
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
743 if (args) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
744 char *arg, *tmp, *ptr, junk;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
745 int last = 0, input;
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 /* 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
748 arg = strdup(args);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
749 if (!arg) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
750 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
751 return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
752 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
753
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
754 tmp = ptr = arg;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
755 do {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
756 while (*tmp != ':' && *tmp) tmp++;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
757 if (*tmp == ':') *tmp++ = '\0';
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
758 else last = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
759 VERBOSE("processing filter option \"%s\"\n", ptr);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
760 /* These options deal with the maximum output
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
761 * resolution of the zoran card. These should
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
762 * 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
763 * 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
764 if (!strncmp("maxheight=", ptr, 10)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
765 if (sscanf(ptr+10, "%d%c", &input, &junk) != 1)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
766 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
767 "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
768 , ptr + 10);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
769 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
770 priv->maxheight = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
771 VERBOSE("setting maxheight to %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
772 priv->maxheight);
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 } else if (!strncmp("quality=", ptr, 8)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
775 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
776 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
777 "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
778 , ptr + 8);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
779 else if (input < 1 || input > 20)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
780 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
781 "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
782 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
783 priv->quality = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
784 VERBOSE("setting JPEG quality to %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
785 priv->quality);
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 } else if (!strncmp("maxwidth=", ptr, 9)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
788 if (sscanf(ptr+9, "%d%c", &input, &junk) != 1)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
789 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
790 "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
791 , ptr + 9);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
792 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
793 priv->maxwidth = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
794 VERBOSE("setting maxwidth to %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
795 priv->maxwidth);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
796 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
797 } else if (!strncmp("hdec=", ptr, 5)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
798 if (sscanf(ptr+5, "%d%c", &input, &junk) != 1)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
799 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
800 "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
801 , ptr + 9);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
802 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
803 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
804 "illegal parameter to \"hdec=\", %d, should be 1, 2 or 4",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
805 input);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
806 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
807 priv->hdec = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
808 VERBOSE(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
809 "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
810 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
811 } else if (!strncmp("vdec=", ptr, 5)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
812 if (sscanf(ptr+5, "%d%c", &input, &junk) != 1)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
813 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
814 "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
815 , ptr + 9);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
816 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
817 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
818 "illegal parameter to \"vdec=\", %d, should be 1, 2 or 4",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
819 input);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
820 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
821 priv->vdec = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
822 VERBOSE(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
823 "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
824 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
825 } else if (!strcasecmp("dc10+-PAL", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
826 !strcasecmp("dc10-PAL", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
827 priv->maxwidth = 768;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
828 priv->maxheight = 576;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
829 VERBOSE("setting DC10(+) PAL profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
830 } else if (!strcasecmp("fd", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
831 priv->fd = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
832 VERBOSE("forcing decimation\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
833 } else if (!strcasecmp("nofd", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
834 priv->fd = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
835 VERBOSE("decimate only if beautiful\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
836 } else if (!strcasecmp("bw", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
837 priv->bw = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
838 VERBOSE("setting black and white encoding\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
839 } else if (!strcasecmp("color", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
840 priv->bw = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
841 VERBOSE("setting color encoding\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
842 } else if (!strcasecmp("dc10+-NTSC", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
843 !strcasecmp("dc10-NTSC", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
844 priv->maxwidth = 640;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
845 priv->maxheight = 480;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
846 VERBOSE("setting DC10(+) NTSC profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
847 } else if (!strcasecmp("buz-PAL", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
848 !strcasecmp("lml33-PAL", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
849 priv->maxwidth = 720;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
850 priv->maxheight = 576;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
851 VERBOSE("setting buz/lml33 PAL profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
852 } else if (!strcasecmp("buz-NTSC", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
853 !strcasecmp("lml33-NTSC", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
854 priv->maxwidth = 720;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
855 priv->maxheight = 480;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
856 VERBOSE("setting buz/lml33 NTSC profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
857 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
858 WARNING("ignoring unknown filter option "
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
859 "\"%s\", or missing argument\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
860 ptr);
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 ptr = tmp;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
863 } while (!last);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
864
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
865 free(arg);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
866 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
867
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
868
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
869 return 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
870 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
871
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
872 vf_info_t vf_info_zrmjpeg = {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
873 "realtime zoran MJPEG encoding",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
874 "zrmjpeg",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
875 "Rik Snel",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
876 "",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
877 open,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
878 NULL
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
879 };
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
880