annotate libmpcodecs/vf_zrmjpeg.c @ 19760:c55b49cd67ba

fix broken term_osd output in update_osd_msg() Patch by Andrew Savchenko Bircoph A list P ru Original thread: 03.09.2006 13:22 [MPlayer-dev-eng] [PACTH] mplayer.c: broken term_osd output in update_osd_msg()
author gpoirier
date Sat, 09 Sep 2006 11:57:43 +0000
parents a83e5b8d2e63
children e99cd69dd08e
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);
19619
a83e5b8d2e63 Patch from Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents: 17906
diff changeset
362 /* Set up to encode mjpeg */
a83e5b8d2e63 Patch from Karolina Lindqvist <karolina.lindqvist@kramnet.se>
rik
parents: 17906
diff changeset
363 j->s->avctx->codec_id = CODEC_ID_MJPEG;
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
364
11961
487d1638d161 fixing segfault: libavcodec doesn't allocate some buffers if avctx->thread_count == 0
rik
parents: 11926
diff changeset
365 /* 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
366 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
367
11662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
368 if (MPV_common_init(j->s) < 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
369 free(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
370 free(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
371 return NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
372 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
373
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
374 /* correct the value for sc->mb_height */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
375 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
376 j->s->mb_intra = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
377
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
378 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
379 for (i = 1; i < 64; i++)
15310
b01679500a5e compilation fix (libavcodec sync)
rik
parents: 14429
diff changeset
380 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
381 (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
382 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
383 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
384 return j;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
385 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
386
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
387 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
388 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
389 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
390 short int *dest;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
391 unsigned char *source;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
392 /* initialize the buffer */
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 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
395
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
396 mjpeg_picture_header(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
397
11926
243767239228 get_bit_count -> put_bits_count
rik
parents: 11662
diff changeset
398 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
399
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
400 j->s->last_dc[0] = 128;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
401 j->s->last_dc[1] = 128;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
402 j->s->last_dc[2] = 128;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
403
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
404 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
405 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
406 /* 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
407 * must be mmx optimized */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
408 /* 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
409 source = mb_y * 8 * j->y_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
410 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
411 dest = j->s->block[0];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
412 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
413 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
414 dest[k] = source[k*j->y_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
415 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
416 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
417 source += j->y_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
418 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
419 source = mb_y * 8 * j->y_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
420 (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
421 dest = j->s->block[1];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
422 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
423 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
424 dest[k] = source[k*j->y_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
425 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
426 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
427 source += j->y_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
428 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
429 if (!j->bw && j->cheap_upsample) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
430 source = mb_y*4*j->u_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
431 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
432 dest = j->s->block[2];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
433 for (i = 0; i < 4; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
434 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
435 dest[k] = source[k*j->u_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
436 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
437 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
438 dest += 16;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
439 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
440 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
441 source = mb_y*4*j->v_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
442 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
443 dest = j->s->block[3];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
444 for (i = 0; i < 4; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
445 for (k = 0; k < 8; k++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
446 dest[k] = source[k*j->v_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
447 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
448 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
449 dest += 16;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
450 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
451 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
452 } else if (!j->bw && !j->cheap_upsample) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
453 source = mb_y*8*j->u_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
454 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
455 dest = j->s->block[2];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
456 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
457 for (k = 0; k < 8; k++)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
458 dest[k] = source[k*j->u_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
459 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
460 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
461 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
462 source = mb_y*8*j->v_rs +
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
463 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
464 dest = j->s->block[3];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
465 for (i = 0; i < 8; i++) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
466 for (k = 0; k < 8; k++)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
467 dest[k] = source[k*j->v_ps];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
468 dest += 8;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
469 source += j->u_rs;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
470 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
471 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
472 emms_c(); /* is this really needed? */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
473
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
474 j->s->block_last_index[0] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
475 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
476 0, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
477 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
478 j->s->block_last_index[0]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
479 j->s->block_last_index[1] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
480 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
481 1, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
482 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
483 j->s->block_last_index[1]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
484
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
485 if (!j->bw) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
486 j->s->block_last_index[4] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
487 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
488 4, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
489 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
490 j->s->block_last_index[2]);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
491 j->s->block_last_index[5] =
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
492 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
493 5, 8, &overflow);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
494 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
495 j->s->block_last_index[3]);
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 zr_mjpeg_encode_mb(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
498 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
499 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
500 emms_c();
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
501 mjpeg_picture_trailer(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
502 flush_put_bits(&j->s->pb);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
503
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
504 if (j->s->mjpeg_write_tables == 1)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
505 j->s->mjpeg_write_tables = 0;
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 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
508 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
509
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
510 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
511 mjpeg_close(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
512 free(j->s);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
513 free(j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
514 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
515
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
516 struct vf_priv_s {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
517 jpeg_enc_t *j;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
518 unsigned char buf[256*1024];
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
519 int bw, fd, hdec, vdec;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
520 int fields;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
521 int y_stride;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
522 int c_stride;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
523 int quality;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
524 int maxwidth;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
525 int maxheight;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
526 };
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
527
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
528 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
529 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
530 struct vf_priv_s *priv = vf->priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
531 float aspect_decision;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
532 int stretchx, stretchy, err = 0, maxstretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
533 priv->fields = 1;
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 VERBOSE("config() called\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
536
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
537 if (priv->j) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
538 VERBOSE("re-configuring, resetting JPEG encoder\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
539 jpeg_enc_uninit(priv->j);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
540 priv->j = NULL;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
541 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
542
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
543 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
544 ((float)width/(float)height);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
545
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
546 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
547 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
548 if (2*width <= priv->maxwidth) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
549 d_width = 2*width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
550 d_height = height;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
551 maxstretchx = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
552 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
553 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
554 d_width = width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
555 d_height = height;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
556 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
557 /* prestretch movie */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
558 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
559 /* uncorrecting output for now */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
560 d_width = width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
561 d_height = height;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
562 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
563 /* make the scaling decision
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
564 * 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
565 * direction by factors 1, 2 and 4
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
566 * 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
567 * 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
568 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
569 || maxstretchx == 1) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
570 stretchx = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
571 stretchy = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
572 priv->fields = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
573 if (priv->vdec == 2) {
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 } else if (priv->vdec == 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
576 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
577 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
578 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
579 if (priv->hdec > maxstretchx) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
580 if (priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
581 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
582 priv->hdec = maxstretchx;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
583 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
584 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
585 stretchx = priv->hdec;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
586 } else if (d_width > priv->maxwidth/4 ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
587 height > priv->maxheight/4 ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
588 maxstretchx == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
589 stretchx = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
590 stretchy = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
591 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
592 if (priv->vdec == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
593 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
594 } else if (priv->vdec == 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
595 if (!priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
596 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
597 priv->vdec = 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 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
600 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
601 if (priv->hdec == 2) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
602 stretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
603 } else if (priv->hdec == 4) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
604 if (priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
605 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
606 priv->hdec = 2;
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 stretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
609 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
610 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
611 /* output image is maximally stretched */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
612 stretchx = 4;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
613 stretchy = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
614 priv->fields = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
615 if (priv->vdec != 1 && !priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
616 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
617 priv->vdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
618 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
619 if (priv->hdec != 1 && !priv->fd) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
620 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
621 priv->hdec = 1;
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 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
624
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
625 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
626 width/priv->hdec, (priv->fields == 2) ? "(" : "",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
627 height/(priv->vdec*priv->fields),
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
628 (priv->fields == 2) ? "x2)" : "",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
629 (width/priv->hdec)*stretchx,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
630 (height/(priv->vdec*priv->fields))*
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
631 stretchy*priv->fields);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
632
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
633
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
634 if ((width/priv->hdec)*stretchx > priv->maxwidth ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
635 (height/(priv->vdec*priv->fields))*
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
636 stretchy*priv->fields > priv->maxheight) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
637 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
638 err = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
639 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
640
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
641 if (width%(16*priv->hdec) != 0) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
642 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
643 priv->hdec*16);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
644 err = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
645 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
646
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
647 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
648 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
649 " 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
650 err = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
651 }
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 if (err) return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
654
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
655 priv->y_stride = width;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
656 priv->c_stride = width/2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
657 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
658 priv->fields*priv->y_stride, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
659 priv->fields*priv->c_stride, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
660 priv->fields*priv->c_stride, 1,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
661 priv->quality, priv->bw);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
662
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
663 if (!priv->j) return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
664 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
665 (priv->fields == 2) ? IMGFMT_ZRMJPEGIT : IMGFMT_ZRMJPEGNI);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
666 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
667
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
668 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
669 struct vf_priv_s *priv = vf->priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
670 int size = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
671 int i;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
672 mp_image_t* dmpi;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
673 for (i = 0; i < priv->fields; i++)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
674 size += jpeg_enc_frame(priv->j,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
675 mpi->planes[0] + i*priv->y_stride,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
676 mpi->planes[1] + i*priv->c_stride,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
677 mpi->planes[2] + i*priv->c_stride,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
678 priv->buf + size);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
679
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
680 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
681 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
682 dmpi->planes[0] = (uint8_t*)priv->buf;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
683 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
684 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
685 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
686
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
687 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
688 VERBOSE("query_format() called\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
689
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
690 switch (fmt) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
691 case IMGFMT_YV12:
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
692 case IMGFMT_YUY2:
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
693 /* strictly speaking the output format of
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
694 * this filter will be known after config(),
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
695 * but everything that supports IMGFMT_ZRMJPEGNI
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
696 * should also support all other IMGFMT_ZRMJPEG* */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
697 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
698 }
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 return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
701 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
702
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
703 static void uninit(vf_instance_t *vf) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
704 struct vf_priv_s *priv = vf->priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
705 VERBOSE("uninit() called\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
706 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
707 free(priv);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
708 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
709
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
710 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
711 struct vf_priv_s *priv;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
712 VERBOSE("open() called: args=\"%s\"\n", args);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
713
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
714 vf->config = config;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
715 vf->put_image = put_image;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
716 vf->query_format = query_format;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
717 vf->uninit = uninit;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
718
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
719 priv = vf->priv = calloc(sizeof(*priv), 1);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
720 if (!vf->priv) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
721 ERROR("out of memory error\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
722 return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
723 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
724
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
725 /* 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
726 * 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
727 * 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
728 * be queried from the vo device itself... */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
729 priv->maxwidth = 768;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
730 priv->maxheight = 576;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
731
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
732 priv->quality = 2;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
733 priv->hdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
734 priv->vdec = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
735
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
736 /* 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
737 * 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
738 if (!avcodec_inited) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
739 /* we need to initialize libavcodec */
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
740 avcodec_init();
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
741 avcodec_register_all();
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
742 avcodec_inited=1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
743 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
744
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
745 if (args) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
746 char *arg, *tmp, *ptr, junk;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
747 int last = 0, input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
748
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
749 /* 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
750 arg = strdup(args);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
751 if (!arg) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
752 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
753 return 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
754 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
755
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
756 tmp = ptr = arg;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
757 do {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
758 while (*tmp != ':' && *tmp) tmp++;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
759 if (*tmp == ':') *tmp++ = '\0';
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
760 else last = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
761 VERBOSE("processing filter option \"%s\"\n", ptr);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
762 /* These options deal with the maximum output
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
763 * resolution of the zoran card. These should
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
764 * 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
765 * 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
766 if (!strncmp("maxheight=", ptr, 10)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
767 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
768 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
769 "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
770 , ptr + 10);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
771 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
772 priv->maxheight = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
773 VERBOSE("setting maxheight to %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
774 priv->maxheight);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
775 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
776 } else if (!strncmp("quality=", ptr, 8)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
777 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
778 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
779 "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
780 , ptr + 8);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
781 else if (input < 1 || input > 20)
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
782 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
783 "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
784 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
785 priv->quality = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
786 VERBOSE("setting JPEG quality to %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
787 priv->quality);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
788 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
789 } else if (!strncmp("maxwidth=", ptr, 9)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
790 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
791 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
792 "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
793 , ptr + 9);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
794 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
795 priv->maxwidth = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
796 VERBOSE("setting maxwidth to %d\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
797 priv->maxwidth);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
798 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
799 } else if (!strncmp("hdec=", ptr, 5)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
800 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
801 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
802 "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
803 , ptr + 9);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
804 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
805 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
806 "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
807 input);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
808 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
809 priv->hdec = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
810 VERBOSE(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
811 "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
812 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
813 } else if (!strncmp("vdec=", ptr, 5)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
814 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
815 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
816 "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
817 , ptr + 9);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
818 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
819 ERROR(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
820 "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
821 input);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
822 else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
823 priv->vdec = input;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
824 VERBOSE(
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
825 "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
826 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
827 } else if (!strcasecmp("dc10+-PAL", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
828 !strcasecmp("dc10-PAL", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
829 priv->maxwidth = 768;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
830 priv->maxheight = 576;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
831 VERBOSE("setting DC10(+) PAL profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
832 } else if (!strcasecmp("fd", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
833 priv->fd = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
834 VERBOSE("forcing decimation\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
835 } else if (!strcasecmp("nofd", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
836 priv->fd = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
837 VERBOSE("decimate only if beautiful\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
838 } else if (!strcasecmp("bw", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
839 priv->bw = 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
840 VERBOSE("setting black and white encoding\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
841 } else if (!strcasecmp("color", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
842 priv->bw = 0;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
843 VERBOSE("setting color encoding\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
844 } else if (!strcasecmp("dc10+-NTSC", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
845 !strcasecmp("dc10-NTSC", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
846 priv->maxwidth = 640;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
847 priv->maxheight = 480;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
848 VERBOSE("setting DC10(+) NTSC profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
849 } else if (!strcasecmp("buz-PAL", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
850 !strcasecmp("lml33-PAL", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
851 priv->maxwidth = 720;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
852 priv->maxheight = 576;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
853 VERBOSE("setting buz/lml33 PAL profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
854 } else if (!strcasecmp("buz-NTSC", ptr) ||
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
855 !strcasecmp("lml33-NTSC", ptr)) {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
856 priv->maxwidth = 720;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
857 priv->maxheight = 480;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
858 VERBOSE("setting buz/lml33 NTSC profile\n");
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
859 } else {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
860 WARNING("ignoring unknown filter option "
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
861 "\"%s\", or missing argument\n",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
862 ptr);
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
863 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
864 ptr = tmp;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
865 } while (!last);
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 free(arg);
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
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 return 1;
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
872 }
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
873
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
874 vf_info_t vf_info_zrmjpeg = {
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
875 "realtime zoran MJPEG encoding",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
876 "zrmjpeg",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
877 "Rik Snel",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
878 "",
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
879 open,
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
880 NULL
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
881 };
173f22eb0505 vf_zrmjpeg MJPEG encoding filter, works together with vo_zr2. Only YV12
rik
parents:
diff changeset
882