annotate ljpegenc.c @ 11498:8e889ce0d616 libavcodec

100L, revert r22560, already present
author bcoudurier
date Mon, 15 Mar 2010 23:40:51 +0000
parents 6eefb31b1bfc
children 8a4984c5cacc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
1 /*
5028
3d8a813666e4 split ljpeg encoder out of mjpeg.c
aurel
parents: 5021
diff changeset
2 * lossless JPEG encoder
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 7744
diff changeset
3 * Copyright (c) 2000, 2001 Fabrice Bellard
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
4 * Copyright (c) 2003 Alex Beregszaszi
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
5 * Copyright (c) 2003-2004 Michael Niedermayer
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
6 *
5214
470601203f44 Group all copyright and author notices together.
diego
parents: 5127
diff changeset
7 * Support for external huffman table, various fixes (AVID workaround),
470601203f44 Group all copyright and author notices together.
diego
parents: 5127
diff changeset
8 * aspecting, new decode_frame mechanism and apple mjpeg-b support
470601203f44 Group all copyright and author notices together.
diego
parents: 5127
diff changeset
9 * by Alex Beregszaszi
470601203f44 Group all copyright and author notices together.
diego
parents: 5127
diff changeset
10 *
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
11 * This file is part of FFmpeg.
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
12 *
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
13 * FFmpeg is free software; you can redistribute it and/or
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
14 * modify it under the terms of the GNU Lesser General Public
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
15 * License as published by the Free Software Foundation; either
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
16 * version 2.1 of the License, or (at your option) any later version.
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
17 *
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
18 * FFmpeg is distributed in the hope that it will be useful,
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
21 * Lesser General Public License for more details.
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
22 *
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
23 * You should have received a copy of the GNU Lesser General Public
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
24 * License along with FFmpeg; if not, write to the Free Software
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
26 */
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
27
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
28 /**
8718
e9d9d946f213 Use full internal pathname in doxygen @file directives.
diego
parents: 8629
diff changeset
29 * @file libavcodec/ljpegenc.c
5028
3d8a813666e4 split ljpeg encoder out of mjpeg.c
aurel
parents: 5021
diff changeset
30 * lossless JPEG encoder.
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
31 */
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
32
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
33 #include "avcodec.h"
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
34 #include "dsputil.h"
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
35 #include "mpegvideo.h"
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
36 #include "mjpeg.h"
5028
3d8a813666e4 split ljpeg encoder out of mjpeg.c
aurel
parents: 5021
diff changeset
37 #include "mjpegenc.h"
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
38
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
39
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
40 static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
41 MpegEncContext * const s = avctx->priv_data;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
42 MJpegContext * const m = s->mjpeg_ctx;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
43 AVFrame *pict = data;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
44 const int width= s->width;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
45 const int height= s->height;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
46 AVFrame * const p= (AVFrame*)&s->current_picture;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
47 const int predictor= avctx->prediction_method+1;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
48
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
49 init_put_bits(&s->pb, buf, buf_size);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
50
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
51 *p = *pict;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
52 p->pict_type= FF_I_TYPE;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
53 p->key_frame= 1;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
54
5029
dbaa06366c3c add a proper prefix to all mjpeg encoder exported functions
aurel
parents: 5028
diff changeset
55 ff_mjpeg_encode_picture_header(s);
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
56
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
57 s->header_bits= put_bits_count(&s->pb);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
58
10668
6eefb31b1bfc Correct a forgotten RGB32.
michael
parents: 9431
diff changeset
59 if(avctx->pix_fmt == PIX_FMT_BGRA){
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
60 int x, y, i;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
61 const int linesize= p->linesize[0];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
62 uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
63 int left[3], top[3], topleft[3];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
64
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
65 for(i=0; i<3; i++){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
66 buffer[0][i]= 1 << (9 - 1);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
67 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
68
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
69 for(y = 0; y < height; y++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
70 const int modified_predictor= y ? predictor : 1;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
71 uint8_t *ptr = p->data[0] + (linesize * y);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
72
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
73 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < width*3*4){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
74 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
75 return -1;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
76 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
77
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
78 for(i=0; i<3; i++){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
79 top[i]= left[i]= topleft[i]= buffer[0][i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
80 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
81 for(x = 0; x < width; x++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
82 buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
83 buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
84 buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
85
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
86 for(i=0;i<3;i++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
87 int pred, diff;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
88
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
89 PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
90
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
91 topleft[i]= top[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
92 top[i]= buffer[x+1][i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
93
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
94 left[i]= buffer[x][i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
95
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
96 diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
97
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
98 if(i==0)
5029
dbaa06366c3c add a proper prefix to all mjpeg encoder exported functions
aurel
parents: 5028
diff changeset
99 ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
100 else
5029
dbaa06366c3c add a proper prefix to all mjpeg encoder exported functions
aurel
parents: 5028
diff changeset
101 ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
102 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
103 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
104 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
105 }else{
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
106 int mb_x, mb_y, i;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
107 const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
108 const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
109
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
110 for(mb_y = 0; mb_y < mb_height; mb_y++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
111 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < mb_width * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
112 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
113 return -1;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
114 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
115 for(mb_x = 0; mb_x < mb_width; mb_x++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
116 if(mb_x==0 || mb_y==0){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
117 for(i=0;i<3;i++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
118 uint8_t *ptr;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
119 int x, y, h, v, linesize;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
120 h = s->mjpeg_hsample[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
121 v = s->mjpeg_vsample[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
122 linesize= p->linesize[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
123
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
124 for(y=0; y<v; y++){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
125 for(x=0; x<h; x++){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
126 int pred;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
127
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
128 ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
129 if(y==0 && mb_y==0){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
130 if(x==0 && mb_x==0){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
131 pred= 128;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
132 }else{
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
133 pred= ptr[-1];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
134 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
135 }else{
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
136 if(x==0 && mb_x==0){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
137 pred= ptr[-linesize];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
138 }else{
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
139 PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
140 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
141 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
142
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
143 if(i==0)
7744
7477cbdacb20 Fix lossless jpeg encoder to comply to spec and store full redundant
michael
parents: 7040
diff changeset
144 ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
145 else
7744
7477cbdacb20 Fix lossless jpeg encoder to comply to spec and store full redundant
michael
parents: 7040
diff changeset
146 ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
147 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
148 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
149 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
150 }else{
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
151 for(i=0;i<3;i++) {
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
152 uint8_t *ptr;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
153 int x, y, h, v, linesize;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
154 h = s->mjpeg_hsample[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
155 v = s->mjpeg_vsample[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
156 linesize= p->linesize[i];
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
157
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
158 for(y=0; y<v; y++){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
159 for(x=0; x<h; x++){
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
160 int pred;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
161
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
162 ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
163 //printf("%d %d %d %d %8X\n", mb_x, mb_y, x, y, ptr);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
164 PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
165
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
166 if(i==0)
7744
7477cbdacb20 Fix lossless jpeg encoder to comply to spec and store full redundant
michael
parents: 7040
diff changeset
167 ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
168 else
7744
7477cbdacb20 Fix lossless jpeg encoder to comply to spec and store full redundant
michael
parents: 7040
diff changeset
169 ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
170 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
171 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
172 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
173 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
174 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
175 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
176 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
177
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
178 emms_c();
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
179
5029
dbaa06366c3c add a proper prefix to all mjpeg encoder exported functions
aurel
parents: 5028
diff changeset
180 ff_mjpeg_encode_picture_trailer(s);
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
181 s->picture_number++;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
182
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
183 flush_put_bits(&s->pb);
9431
932543edc1d2 Rename pbBufPtr() to put_bits_ptr().
stefano
parents: 8718
diff changeset
184 return put_bits_ptr(&s->pb) - s->pb.buf;
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
185 // return (put_bits_count(&f->pb)+7)/8;
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
186 }
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
187
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
188
5127
4dbe6578f811 misc spelling fixes
diego
parents: 5029
diff changeset
189 AVCodec ljpeg_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
190 "ljpeg",
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
191 CODEC_TYPE_VIDEO,
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
192 CODEC_ID_LJPEG,
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
193 sizeof(MpegEncContext),
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
194 MPV_encode_init,
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
195 encode_picture_lossless,
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
196 MPV_encode_end,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6717
diff changeset
197 .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
5020
eb0ad6423405 split mjpeg.c into an encoder and a decoder file
aurel
parents:
diff changeset
198 };