Mercurial > libavcodec.hg
comparison mjpegenc.c @ 5029:dbaa06366c3c libavcodec
add a proper prefix to all mjpeg encoder exported functions
author | aurel |
---|---|
date | Fri, 18 May 2007 22:54:54 +0000 |
parents | 3d8a813666e4 |
children | 9ce0052d533a |
comparison
equal
deleted
inserted
replaced
5028:3d8a813666e4 | 5029:dbaa06366c3c |
---|---|
42 /* use two quantizer tables (one for luminance and one for chrominance) */ | 42 /* use two quantizer tables (one for luminance and one for chrominance) */ |
43 /* not yet working */ | 43 /* not yet working */ |
44 #undef TWOMATRIXES | 44 #undef TWOMATRIXES |
45 | 45 |
46 | 46 |
47 int mjpeg_init(MpegEncContext *s) | 47 int ff_mjpeg_encode_init(MpegEncContext *s) |
48 { | 48 { |
49 MJpegContext *m; | 49 MJpegContext *m; |
50 | 50 |
51 m = av_malloc(sizeof(MJpegContext)); | 51 m = av_malloc(sizeof(MJpegContext)); |
52 if (!m) | 52 if (!m) |
75 | 75 |
76 s->mjpeg_ctx = m; | 76 s->mjpeg_ctx = m; |
77 return 0; | 77 return 0; |
78 } | 78 } |
79 | 79 |
80 void mjpeg_close(MpegEncContext *s) | 80 void ff_mjpeg_encode_close(MpegEncContext *s) |
81 { | 81 { |
82 av_free(s->mjpeg_ctx); | 82 av_free(s->mjpeg_ctx); |
83 } | 83 } |
84 | 84 |
85 /* table_class: 0 = DC coef, 1 = AC coefs */ | 85 /* table_class: 0 = DC coef, 1 = AC coefs */ |
195 ptr[0] = size >> 8; | 195 ptr[0] = size >> 8; |
196 ptr[1] = size; | 196 ptr[1] = size; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 void mjpeg_picture_header(MpegEncContext *s) | 200 void ff_mjpeg_encode_picture_header(MpegEncContext *s) |
201 { | 201 { |
202 const int lossless= s->avctx->codec_id != CODEC_ID_MJPEG; | 202 const int lossless= s->avctx->codec_id != CODEC_ID_MJPEG; |
203 | 203 |
204 put_marker(&s->pb, SOI); | 204 put_marker(&s->pb, SOI); |
205 | 205 |
333 | 333 |
334 buf[i+ff_count]= v; | 334 buf[i+ff_count]= v; |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 void ff_mjpeg_stuffing(PutBitContext * pbc) | 338 void ff_mjpeg_encode_stuffing(PutBitContext * pbc) |
339 { | 339 { |
340 int length; | 340 int length; |
341 length= (-put_bits_count(pbc))&7; | 341 length= (-put_bits_count(pbc))&7; |
342 if(length) put_bits(pbc, length, (1<<length)-1); | 342 if(length) put_bits(pbc, length, (1<<length)-1); |
343 } | 343 } |
344 | 344 |
345 void mjpeg_picture_trailer(MpegEncContext *s) | 345 void ff_mjpeg_encode_picture_trailer(MpegEncContext *s) |
346 { | 346 { |
347 ff_mjpeg_stuffing(&s->pb); | 347 ff_mjpeg_encode_stuffing(&s->pb); |
348 flush_put_bits(&s->pb); | 348 flush_put_bits(&s->pb); |
349 | 349 |
350 assert((s->header_bits&7)==0); | 350 assert((s->header_bits&7)==0); |
351 | 351 |
352 escape_FF(s, s->header_bits>>3); | 352 escape_FF(s, s->header_bits>>3); |
353 | 353 |
354 put_marker(&s->pb, EOI); | 354 put_marker(&s->pb, EOI); |
355 } | 355 } |
356 | 356 |
357 void mjpeg_encode_dc(MpegEncContext *s, int val, | 357 void ff_mjpeg_encode_dc(MpegEncContext *s, int val, |
358 uint8_t *huff_size, uint16_t *huff_code) | 358 uint8_t *huff_size, uint16_t *huff_code) |
359 { | 359 { |
360 int mant, nbits; | 360 int mant, nbits; |
361 | 361 |
362 if (val == 0) { | 362 if (val == 0) { |
363 put_bits(&s->pb, huff_size[0], huff_code[0]); | 363 put_bits(&s->pb, huff_size[0], huff_code[0]); |
387 /* DC coef */ | 387 /* DC coef */ |
388 component = (n <= 3 ? 0 : (n&1) + 1); | 388 component = (n <= 3 ? 0 : (n&1) + 1); |
389 dc = block[0]; /* overflow is impossible */ | 389 dc = block[0]; /* overflow is impossible */ |
390 val = dc - s->last_dc[component]; | 390 val = dc - s->last_dc[component]; |
391 if (n < 4) { | 391 if (n < 4) { |
392 mjpeg_encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance); | 392 ff_mjpeg_encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance); |
393 huff_size_ac = m->huff_size_ac_luminance; | 393 huff_size_ac = m->huff_size_ac_luminance; |
394 huff_code_ac = m->huff_code_ac_luminance; | 394 huff_code_ac = m->huff_code_ac_luminance; |
395 } else { | 395 } else { |
396 mjpeg_encode_dc(s, val, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); | 396 ff_mjpeg_encode_dc(s, val, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); |
397 huff_size_ac = m->huff_size_ac_chrominance; | 397 huff_size_ac = m->huff_size_ac_chrominance; |
398 huff_code_ac = m->huff_code_ac_chrominance; | 398 huff_code_ac = m->huff_code_ac_chrominance; |
399 } | 399 } |
400 s->last_dc[component] = dc; | 400 s->last_dc[component] = dc; |
401 | 401 |
432 /* output EOB only if not already 64 values */ | 432 /* output EOB only if not already 64 values */ |
433 if (last_index < 63 || run != 0) | 433 if (last_index < 63 || run != 0) |
434 put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]); | 434 put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]); |
435 } | 435 } |
436 | 436 |
437 void mjpeg_encode_mb(MpegEncContext *s, | 437 void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64]) |
438 DCTELEM block[6][64]) | |
439 { | 438 { |
440 int i; | 439 int i; |
441 for(i=0;i<5;i++) { | 440 for(i=0;i<5;i++) { |
442 encode_block(s, block[i], i); | 441 encode_block(s, block[i], i); |
443 } | 442 } |