57 uint16_t *reversed_code,
int num_entries)
59 for (
int i = 0;
i < num_entries;
i++)
78 for (
int i = -255;
i < 256;
i++) {
108 if (
s->width > 65500 ||
s->height > 65500) {
113 s->min_qcoeff = -2048;
114 s->max_qcoeff = 2047;
118 s->intra_ac_vlc_length =
119 s->intra_ac_vlc_last_length =
120 s->intra_chroma_ac_vlc_length =
123 switch (
s->avctx->pix_fmt) {
125 s->avctx->codec_tag =
MKTAG(
'S',
'H',
'Q',
'0');
128 s->avctx->codec_tag =
MKTAG(
'S',
'H',
'Q',
'2');
131 s->avctx->codec_tag =
MKTAG(
'S',
'H',
'Q',
'4');
155 slice_len =
s->pb.buf_ptr - (
s->pb.buf +
s->slice_start);
156 AV_WL24(
s->pb.buf +
s->slice_start, slice_len);
159 s->slice_start =
s->pb.buf_ptr -
s->pb.buf;
165 unsigned int diff_u =
diff + 255;
199 int alevel,
level, last_non_zero,
dc,
i, j,
run, last_index, sign;
204 component = (n <= 3 ? 0 : (n&1) + 1);
206 val =
s->last_dc[component] -
dc;
208 s->last_dc[component] =
dc;
212 last_index =
s->block_last_index[n];
214 for (
i = 1;
i <= last_index;
i++) {
215 j =
s->intra_scantable.permutated[
i];
220 run =
i - last_non_zero - 1;
270 return mb_height / 4 + (slice_num < (mb_height % 4));
280 *first_in_slice = (mb_y_order == 0);
281 return mb_y_order * 4 + slice_num;
284 #if CONFIG_SPEEDHQ_ENCODER
285 static const AVClass speedhq_class = {
306 .priv_class = &speedhq_class,
static double val(void *priv, double ch)
AVCodec ff_speedhq_encoder
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
#define MKTAG(a, b, c, d)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int ff_thread_once(char *control, void(*routine)(void))
static enum AVPixelFormat pix_fmts[]
#define MASK_ABS(mask, level)
static av_always_inline uint32_t bitswap_32(uint32_t x)
void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len)
const uint16_t ff_mpeg12_vlc_dc_chroma_code[12]
const uint16_t ff_mpeg12_vlc_dc_lum_code[12]
const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12]
const unsigned char ff_mpeg12_vlc_dc_lum_bits[12]
const AVOption ff_mpv_generic_options[]
int ff_mpv_encode_end(AVCodecContext *avctx)
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static int get_bits_diff(MpegEncContext *s)
int ff_mpv_encode_init(AVCodecContext *avctx)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void put_bits_le(PutBitContext *s, int n, BitBuf value)
static void flush_put_bits_le(PutBitContext *s)
av_cold void ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64])
static int ff_speedhq_mb_rows_in_slice(int slice_num, int mb_height)
void ff_speedhq_end_slice(MpegEncContext *s)
static uint32_t speedhq_lum_dc_uni[512]
static uint16_t mpeg12_vlc_dc_chroma_code_reversed[12]
av_cold int ff_speedhq_encode_init(MpegEncContext *s)
static uint16_t mpeg12_vlc_dc_lum_code_reversed[12]
static void encode_dc(PutBitContext *pb, int diff, int component)
static void encode_block(MpegEncContext *s, int16_t *block, int n)
static void reverse_code(const uint16_t *code, const uint8_t *bits, uint16_t *reversed_code, int num_entries)
static av_cold void speedhq_init_static_data(void)
int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_slice)
static uint8_t speedhq_static_rl_table_store[2][2 *MAX_RUN+MAX_LEVEL+3]
void ff_speedhq_encode_picture_header(MpegEncContext *s)
static uint8_t uni_speedhq_ac_vlc_len[64 *64 *2]
static uint32_t reverse(uint32_t num, int bits)
static uint32_t speedhq_chr_dc_uni[512]
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
const char * name
Name of the codec implementation.
uint8_t * index_run[2]
encoding only
const uint16_t(* table_vlc)[2]
int8_t * max_level[2]
encoding & decoding
static av_always_inline int diff(const uint32_t a, const uint32_t b)