Go to the documentation of this file.
60 uint16_t luma_intra_matrix[64],
61 uint16_t chroma_intra_matrix[64],
73 int matrix_count = 1 + !!memcmp(luma_intra_matrix,
75 sizeof(luma_intra_matrix[0]) * 64);
76 if (
s &&
s->force_duplicated_matrix)
80 put_bits(p, 16, 2 + matrix_count * (1 + 64));
85 put_bits(p, 8, luma_intra_matrix[j]);
88 if (matrix_count > 1) {
93 put_bits(p, 8, chroma_intra_matrix[j]);
115 s->mjpeg_ctx->val_dc_luminance);
117 s->mjpeg_ctx->val_dc_chrominance);
120 s->mjpeg_ctx->val_ac_luminance);
122 s->mjpeg_ctx->val_ac_chrominance);
145 if (sar.
num > 65535 || sar.
den > 65535) {
148 "Cannot store exact aspect ratio %d:%d\n",
188 size = strlen(
"CS=ITU601")+3;
195 int chroma_h_shift, chroma_v_shift;
203 vsample[0] = hsample[0] =
204 vsample[1] = hsample[1] =
205 vsample[2] = hsample[2] =
206 vsample[3] = hsample[3] = 1;
208 vsample[0] = vsample[1] = vsample[2] = 2;
209 hsample[0] = hsample[1] = hsample[2] = 1;
212 vsample[1] = 2 >> chroma_v_shift;
213 vsample[2] = 2 >> chroma_v_shift;
215 hsample[1] = 2 >> chroma_h_shift;
216 hsample[2] = 2 >> chroma_h_shift;
222 uint16_t luma_intra_matrix[64],
223 uint16_t chroma_intra_matrix[64])
226 int hsample[4], vsample[4];
229 int chroma_matrix = !!memcmp(luma_intra_matrix,
231 sizeof(luma_intra_matrix[0])*64);
242 jpeg_table_header(avctx, pb, intra_scantable, luma_intra_matrix, chroma_intra_matrix, hsample);
271 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
277 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
279 if (components == 4) {
306 if (components == 4) {
329 for(
i=1;
i<
s->slice_context_count;
i++)
330 s->thread_context[
i]->esc_pos = 0;
339 int align= (-(size_t)(buf))&3;
353 if(buf[
i]==0xFF) ff_count++;
358 v= *(uint32_t*)(&buf[
i]);
359 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
360 v= *(uint32_t*)(&buf[
i+4]);
361 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
362 v= *(uint32_t*)(&buf[
i+8]);
363 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
364 v= *(uint32_t*)(&buf[
i+12]);
365 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
373 if(buf[
i]==0xFF) ff_count++;
376 if(ff_count==0)
return;
381 for(
i=
size-1; ff_count;
i--){
402 for (
int i = 1;
i <= 16;
i++) {
403 int nb = bits_table[
i];
404 for (
int j = 0; j < nb; j++) {
405 int sym = val_table[k++];
407 huff_code[sym] =
code;
422 uint8_t *huff_size, uint16_t *huff_code)
427 put_bits(pb, huff_size[0], huff_code[0]);
437 put_bits(pb, huff_size[nbits], huff_code[nbits]);
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, ScanTable *intra_scantable, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64], int hsample[3])
static void put_sbits(PutBitContext *pb, int n, int32_t value)
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, ScanTable *intra_scantable, int pred, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64])
int av_log2_16bit(unsigned v)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
const uint8_t avpriv_mjpeg_val_ac_luminance[]
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static int put_huffman_table(PutBitContext *p, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
const struct AVCodec * codec
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
const uint8_t avpriv_mjpeg_val_dc[12]
@ HUFFMAN_TABLE_OPTIMAL
Compute and use optimal Huffman tables.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Rational number (pair of numerator and denominator).
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int put_bits_count(PutBitContext *s)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
static const float pred[4]
main external API structure.
int active_thread_type
Which multithreading methods are in use by the codec.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static void put_marker(PutBitContext *p, enum JpegMarker code)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
int width
picture width / height.
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.