annotate libmpcodecs/vf_zrmjpeg.c @ 22925:a8f534c4e071

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