87 const uint8_t *bits_table,
const uint8_t *value_table)
192 size = strlen(
"CS=ITU601")+3;
283 uint8_t *buf= s->
pb.
buf + start;
284 int align= (-(size_t)(buf))&3;
286 assert((size&7) == 0);
290 for(i=0; i<size && i<align; i++){
291 if(buf[i]==0xFF) ff_count++;
293 for(; i<size-15; i+=16){
296 v= *(uint32_t*)(&buf[i]);
297 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
298 v= *(uint32_t*)(&buf[i+4]);
299 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
300 v= *(uint32_t*)(&buf[i+8]);
301 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
302 v= *(uint32_t*)(&buf[i+12]);
303 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
311 if(buf[i]==0xFF) ff_count++;
314 if(ff_count==0)
return;
319 for(i=size-1; ff_count; i--){
336 if(length)
put_bits(pbc, length, (1<<length)-1);
352 uint8_t *huff_size, uint16_t *huff_code)
365 nbits= av_log2_16bit(val) + 1;
367 put_bits(&s->
pb, huff_size[nbits], huff_code[nbits]);
375 int mant, nbits, code, i, j;
376 int component, dc,
run, last_index, val;
378 uint8_t *huff_size_ac;
379 uint16_t *huff_code_ac;
382 component = (n <= 3 ? 0 : (n&1) + 1);
384 val = dc - s->
last_dc[component];
400 for(i=1;i<=last_index;i++) {
407 put_bits(&s->
pb, huff_size_ac[0xf0], huff_code_ac[0xf0]);
416 nbits= av_log2(val) + 1;
417 code = (run << 4) | nbits;
419 put_bits(&s->
pb, huff_size_ac[code], huff_code_ac[code]);
427 if (last_index < 63 || run != 0)
428 put_bits(&s->
pb, huff_size_ac[0], huff_code_ac[0]);
const uint8_t ff_mjpeg_bits_dc_chrominance[17]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
const uint8_t ff_mjpeg_bits_ac_chrominance[17]
struct MpegEncContext MpegEncContext
MpegEncContext.
static void put_sbits(PutBitContext *pb, int n, int32_t value)
const uint8_t ff_mjpeg_val_ac_chrominance[]
uint16_t chroma_intra_matrix[64]
int MPV_encode_init(AVCodecContext *avctx)
int mjpeg_hsample[3]
horizontal sampling factors, default = {2, 1, 1}
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
int min_qcoeff
minimum encodable coefficient
av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
MJPEG encoder and decoder.
uint16_t huff_code_dc_chrominance[12]
uint16_t huff_code_ac_luminance[256]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
uint8_t huff_size_dc_chrominance[12]
int max_qcoeff
maximum encodable coefficient
static int init(AVCodecParserContext *s)
static int get_bits_diff(MpegEncContext *s)
uint16_t huff_code_ac_chrominance[256]
uint8_t huff_size_ac_luminance[256]
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int last_dc[3]
last DC values for MPEG1
int MPV_encode_end(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int MPV_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
uint8_t huff_size_ac_chrominance[256]
const char * name
Name of the codec implementation.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int put_bits_count(PutBitContext *s)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
void ff_mjpeg_encode_picture_header(MpegEncContext *s)
static void jpeg_put_comments(MpegEncContext *s)
void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64])
int block_last_index[12]
last non zero coefficient in block
struct MJpegContext * mjpeg_ctx
int mjpeg_vsample[3]
vertical sampling factors, default = {2, 1, 1}
const uint8_t ff_mjpeg_bits_dc_luminance[17]
void ff_mjpeg_encode_close(MpegEncContext *s)
static void close(AVCodecParserContext *s)
ScanTable intra_scantable
int height
picture size. must be a multiple of 16
static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
void ff_mjpeg_encode_stuffing(PutBitContext *pbc)
void ff_mjpeg_encode_picture_trailer(MpegEncContext *s)
static void jpeg_table_header(MpegEncContext *s)
const uint8_t ff_mjpeg_bits_ac_luminance[17]
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const uint8_t ff_mjpeg_val_dc[12]
static int put_huffman_table(MpegEncContext *s, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)
const uint8_t ff_mjpeg_val_ac_luminance[]
struct AVCodecContext * avctx
uint16_t huff_code_dc_luminance[12]
PutBitContext pb
bit output
uint8_t huff_size_dc_luminance[12]
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
int prediction_method
prediction method (needed for huffyuv)
static void put_marker(PutBitContext *p, int code)
void ff_mjpeg_encode_dc(MpegEncContext *s, int val, uint8_t *huff_size, uint16_t *huff_code)
int flags
AVCodecContext.flags (HQ, MV4, ...)
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
static void escape_FF(MpegEncContext *s, int start)
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).