201 size = strlen(
"CS=ITU601")+3;
304 int align= (-(size_t)(buf))&3;
310 for(i=0; i<size && i<
align; i++){
311 if(buf[i]==0xFF) ff_count++;
313 for(; i<size-15; i+=16){
316 v= *(uint32_t*)(&buf[i]);
317 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
318 v= *(uint32_t*)(&buf[i+4]);
319 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
320 v= *(uint32_t*)(&buf[i+8]);
321 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
322 v= *(uint32_t*)(&buf[i+12]);
323 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
331 if(buf[i]==0xFF) ff_count++;
334 if(ff_count==0)
return;
339 for(i=size-1; ff_count; i--){
357 if(length)
put_bits(pbc, length, (1<<length)-1);
380 uint8_t *huff_size, uint16_t *huff_code)
395 put_bits(&s->
pb, huff_size[nbits], huff_code[nbits]);
403 int mant, nbits, code, i, j;
404 int component,
dc,
run, last_index,
val;
407 uint16_t *huff_code_ac;
410 component = (n <= 3 ? 0 : (n&1) + 1);
412 val = dc - s->
last_dc[component];
428 for(i=1;i<=last_index;i++) {
435 put_bits(&s->
pb, huff_size_ac[0xf0], huff_code_ac[0xf0]);
445 code = (run << 4) | nbits;
447 put_bits(&s->
pb, huff_size_ac[code], huff_code_ac[code]);
455 if (last_index < 63 || run != 0)
456 put_bits(&s->
pb, huff_size_ac[0], huff_code_ac[0]);
497 const AVFrame *pic_arg,
int *got_packet)
509 for(i=0; i < 3; i++) {
516 #if CONFIG_MJPEG_ENCODER
532 #if CONFIG_AMV_ENCODER
const char const char void * val
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64])
This structure describes decoded (raw) audio or video data.
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static av_cold int init(AVCodecContext *avctx)
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
uint16_t chroma_intra_matrix[64]
int ff_MPV_encode_end(AVCodecContext *avctx)
int mjpeg_hsample[3]
horizontal sampling factors, default = {2, 1, 1}
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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]
packed RGB 8:8:8, 24bpp, BGRBGR...
uint16_t huff_code_ac_luminance[256]
#define CODEC_CAP_INTRA_ONLY
Codec is intra only.
static void encode_block(MpegEncContext *s, int16_t *block, int n)
static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
static av_cold int end(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
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]
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int mb_height
number of MBs horizontally & vertically
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]
int slice_context_count
number of used thread_contexts
uint8_t huff_size_ac_luminance[256]
#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.
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
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){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));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);ff_audio_convert_init_arm(ac);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
packed BGR 8:8:8, 32bpp, BGR0BGR0...
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
int active_thread_type
Which multithreading methods are in use by the codec.
uint8_t huff_size_ac_chrominance[256]
Libavcodec external API header.
AVPixelFormat
Pixel format.
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)
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const uint8_t avpriv_mjpeg_val_dc[12]
int block_last_index[12]
last non zero coefficient in block
struct MJpegContext * mjpeg_ctx
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int mjpeg_vsample[3]
vertical sampling factors, default = {2, 1, 1}
const AVS_VideoInfo int align
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
struct MpegEncContext * thread_context[MAX_THREADS]
void ff_mjpeg_encode_close(MpegEncContext *s)
main external API structure.
static void close(AVCodecParserContext *s)
ScanTable intra_scantable
int height
picture size. must be a multiple of 16
void ff_mjpeg_encode_picture_trailer(MpegEncContext *s)
static void jpeg_table_header(MpegEncContext *s)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
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 avpriv_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]
#define CODEC_FLAG_EMU_EDGE
Don't draw edges.
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
void ff_mjpeg_encode_stuffing(MpegEncContext *s)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int prediction_method
prediction method (needed for huffyuv)
static void put_marker(PutBitContext *p, int code)
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
void ff_mjpeg_encode_dc(MpegEncContext *s, int val, uint8_t *huff_size, uint16_t *huff_code)
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
int flags
AVCodecContext.flags (HQ, MV4, ...)
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void escape_FF(MpegEncContext *s, int start)
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
This structure stores compressed data.
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.