24 #include "libavutil/common.h"
25 #include "libavutil/pixdesc.h"
26 #include "libavutil/pixfmt.h"
56 uint16_t intra_matrix[64])
126 size = strlen(
"CS=ITU601")+3;
133 uint16_t intra_matrix[64])
135 int chroma_h_shift, chroma_v_shift;
137 int hsample[3], vsample[3];
144 vsample[0] = hsample[0] =
145 vsample[1] = hsample[1] =
146 vsample[2] = hsample[2] = 1;
149 vsample[1] = 2 >> chroma_v_shift;
150 vsample[2] = 2 >> chroma_v_shift;
152 hsample[1] = 2 >> chroma_h_shift;
153 hsample[2] = 2 >> chroma_h_shift;
231 int align= (-(size_t)(buf))&3;
233 assert((size&7) == 0);
237 for(i=0; i<size && i<align; i++){
238 if(buf[i]==0xFF) ff_count++;
240 for(; i<size-15; i+=16){
243 v= *(uint32_t*)(&buf[i]);
244 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
245 v= *(uint32_t*)(&buf[i+4]);
246 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
247 v= *(uint32_t*)(&buf[i+8]);
248 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
249 v= *(uint32_t*)(&buf[i+12]);
250 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
258 if(buf[i]==0xFF) ff_count++;
261 if(ff_count==0)
return;
266 for(i=size-1; ff_count; i--){
282 if(length)
put_bits(pbc, length, (1<<length)-1);
290 assert((header_bits & 7) == 0);
298 uint8_t *huff_size, uint16_t *huff_code)
303 put_bits(pb, huff_size[0], huff_code[0]);
313 put_bits(pb, huff_size[nbits], huff_code[nbits]);
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void put_sbits(PutBitContext *pb, int n, int32_t value)
const uint8_t avpriv_mjpeg_bits_ac_luminance[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...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
MJPEG encoder and decoder.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static void jpeg_table_header(PutBitContext *p, ScanTable *intra_scantable, uint16_t intra_matrix[64])
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, ScanTable *intra_scantable, uint16_t intra_matrix[64])
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
Libavcodec external API header.
static int put_bits_count(PutBitContext *s)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
int width
picture width / height.
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
const uint8_t avpriv_mjpeg_val_dc[12]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
static void escape_FF(PutBitContext *pb, int start)
main external API structure.
packed RGB 8:8:8, 24bpp, BGRBGR...
const uint8_t avpriv_mjpeg_val_ac_luminance[]
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.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
int prediction_method
prediction method (needed for huffyuv)
const struct AVCodec * codec
static void put_marker(PutBitContext *p, int code)
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
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)
void ff_mjpeg_encode_stuffing(PutBitContext *pbc)