61 uint16_t luma_intra_matrix[64],
62 uint16_t chroma_intra_matrix[64],
70 int matrix_count = 1 + !!memcmp(luma_intra_matrix,
72 sizeof(luma_intra_matrix[0]) * 64);
77 put_bits(p, 16, 2 + matrix_count * (1 + 64));
82 put_bits(p, 8, luma_intra_matrix[j]);
85 if (matrix_count > 1) {
90 put_bits(p, 8, chroma_intra_matrix[j]);
160 size = strlen(
"CS=ITU601")+3;
167 int chroma_h_shift, chroma_v_shift;
175 vsample[0] = hsample[0] =
176 vsample[1] = hsample[1] =
177 vsample[2] = hsample[2] =
178 vsample[3] = hsample[3] = 1;
180 vsample[0] = vsample[1] = vsample[2] = 2;
181 hsample[0] = hsample[1] = hsample[2] = 1;
184 vsample[1] = 2 >> chroma_v_shift;
185 vsample[2] = 2 >> chroma_v_shift;
187 hsample[1] = 2 >> chroma_h_shift;
188 hsample[2] = 2 >> chroma_h_shift;
194 uint16_t luma_intra_matrix[64],
195 uint16_t chroma_intra_matrix[64])
198 int hsample[4], vsample[4];
201 int chroma_matrix = !!memcmp(luma_intra_matrix,
203 sizeof(luma_intra_matrix[0])*64);
214 jpeg_table_header(avctx, pb, intra_scantable, luma_intra_matrix, chroma_intra_matrix, hsample);
243 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
249 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
251 if (components == 4) {
278 if (components == 4) {
285 put_bits(pb, 8, lossless ? pred : 0);
311 int align= (-(size_t)(buf))&3;
324 for(i=0; i<size && i<
align; i++){
325 if(buf[i]==0xFF) ff_count++;
327 for(; i<size-15; i+=16){
330 v= *(uint32_t*)(&buf[i]);
331 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
332 v= *(uint32_t*)(&buf[i+4]);
333 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
334 v= *(uint32_t*)(&buf[i+8]);
335 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
336 v= *(uint32_t*)(&buf[i+12]);
337 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
345 if(buf[i]==0xFF) ff_count++;
348 if(ff_count==0)
return;
353 for(i=size-1; ff_count; i--){
399 uint8_t *huff_size, uint16_t *huff_code)
404 put_bits(pb, huff_size[0], huff_code[0]);
414 put_bits(pb, huff_size[nbits], huff_code[nbits]);
const struct AVCodec * codec
const char const char void * val
static void put_sbits(PutBitContext *pb, int n, int32_t value)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int av_log2_16bit(unsigned v)
MJPEG encoder and decoder.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_cold int end(AVCodecContext *avctx)
int force_duplicated_matrix
Force duplication of mjpeg matrices, useful for rtp streaming.
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
int slice_context_count
number of used thread_contexts
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
int last_dc[3]
last DC values for MPEG1
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
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 active_thread_type
Which multithreading methods are in use by the codec.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int flags
AV_CODEC_FLAG_*.
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
static int put_bits_count(PutBitContext *s)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase)
static void put_marker(PutBitContext *p, enum JpegMarker code)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int width
picture width / height.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
packed RGB 8:8:8, 24bpp, BGRBGR...
the normal 2^n-1 "JPEG" YUV ranges
static const float pred[4]
const AVS_VideoInfo int align
struct MpegEncContext * thread_context[MAX_THREADS]
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
Libavcodec external API header.
main external API structure.
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])
const uint8_t avpriv_mjpeg_val_dc[12]
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
int ff_mjpeg_encode_stuffing(MpegEncContext *s)
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
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])
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
the normal 219*2^(n-8) "MPEG" YUV ranges
struct AVCodecContext * avctx
PutBitContext pb
bit output
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
common internal and external API header
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
const uint8_t avpriv_mjpeg_val_ac_luminance[]
static int put_huffman_table(PutBitContext *p, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)