102 uint16_t intra_matrix[64])
175 size = strlen(
"CS=ITU601")+3;
182 uint16_t intra_matrix[64])
184 int chroma_h_shift, chroma_v_shift;
186 int hsample[3], vsample[3];
193 vsample[0] = hsample[0] =
194 vsample[1] = hsample[1] =
195 vsample[2] = hsample[2] = 1;
198 vsample[1] = 2 >> chroma_v_shift;
199 vsample[2] = 2 >> chroma_v_shift;
201 hsample[1] = 2 >> chroma_h_shift;
202 hsample[2] = 2 >> chroma_h_shift;
280 int align= (-(size_t)(buf))&3;
282 assert((size&7) == 0);
286 for(i=0; i<size && i<align; i++){
287 if(buf[i]==0xFF) ff_count++;
289 for(; i<size-15; i+=16){
292 v= *(uint32_t*)(&buf[i]);
293 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
294 v= *(uint32_t*)(&buf[i+4]);
295 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
296 v= *(uint32_t*)(&buf[i+8]);
297 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
298 v= *(uint32_t*)(&buf[i+12]);
299 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
307 if(buf[i]==0xFF) ff_count++;
310 if(ff_count==0)
return;
315 for(i=size-1; ff_count; i--){
331 if(length)
put_bits(pbc, length, (1<<length)-1);
339 assert((header_bits & 7) == 0);
347 uint8_t *huff_size, uint16_t *huff_code)
352 put_bits(pb, huff_size[0], huff_code[0]);
362 put_bits(pb, huff_size[nbits], huff_code[nbits]);
370 int mant, nbits, code, i, j;
371 int component,
dc,
run, last_index, val;
374 uint16_t *huff_code_ac;
377 component = (n <= 3 ? 0 : (n&1) + 1);
379 val = dc - s->
last_dc[component];
395 for(i=1;i<=last_index;i++) {
402 put_bits(&s->
pb, huff_size_ac[0xf0], huff_code_ac[0xf0]);
412 code = (run << 4) | nbits;
414 put_bits(&s->
pb, huff_size_ac[code], huff_code_ac[code]);
422 if (last_index < 63 || run != 0)
423 put_bits(&s->
pb, huff_size_ac[0], huff_code_ac[0]);
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64])
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)
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
int ff_MPV_encode_end(AVCodecContext *avctx)
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 min_qcoeff
minimum encodable coefficient
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
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]
static void encode_block(MpegEncContext *s, int16_t *block, int n)
static void escape_FF(PutBitContext *pb, int start)
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
uint8_t huff_size_dc_chrominance[12]
static void jpeg_table_header(PutBitContext *p, ScanTable *intra_scantable, uint16_t intra_matrix[64])
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int max_qcoeff
maximum encodable coefficient
int ff_MPV_encode_init(AVCodecContext *avctx)
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
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.
static int put_bits_count(PutBitContext *s)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, ScanTable *intra_scantable, uint16_t intra_matrix[64])
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int width
picture width / height.
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
const uint8_t avpriv_mjpeg_val_dc[12]
int block_last_index[12]
last non zero coefficient in block
packed RGB 8:8:8, 24bpp, BGRBGR...
struct MJpegContext * mjpeg_ctx
Libavcodec external API header.
void ff_mjpeg_encode_close(MpegEncContext *s)
main external API structure.
static void close(AVCodecParserContext *s)
ScanTable intra_scantable
void ff_mjpeg_encode_stuffing(PutBitContext *pbc)
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
const uint8_t avpriv_mjpeg_val_ac_luminance[]
uint16_t huff_code_dc_luminance[12]
PutBitContext pb
bit output
uint8_t huff_size_dc_luminance[12]
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.
int prediction_method
prediction method (needed for huffyuv)
FF_ENABLE_DEPRECATION_WARNINGS 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 jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
static av_cold int init(AVCodecParserContext *s)
static void put_marker(PutBitContext *p, int code)
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
AVPixelFormat
Pixel format.
static int put_huffman_table(PutBitContext *p, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)