26#include "config_components.h"
49 const uint8_t *pixels,
105 for (
unsigned i = 0, nc_bits = 0, nc_val = 0;
i < 10;
i++) {
110 a->q_intra_matrix[
index + 0] + (1 << 15)) >> 16))
113 a->q_intra_matrix[
index + 8] + (1 << 15)) >> 16))
116 a->q_intra_matrix[
index + 1] + (1 << 15)) >> 16))
119 a->q_intra_matrix[
index + 9] + (1 << 15)) >> 16))
139 nc_val = (nc_val << 2) | 2;
150 for (count = 63; count > 3; count--) {
159 ((
block[0] + 32) >> 6) << 4);
162 for (
i = 0;
i <= count;
i++) {
167 a->q_intra_matrix[
index + 0] + (1 << 15)) >> 16))
170 a->q_intra_matrix[
index + 8] + (1 << 15)) >> 16))
173 a->q_intra_matrix[
index + 1] + (1 << 15)) >> 16))
176 a->q_intra_matrix[
index + 9] + (1 << 15)) >> 16))
205 for (
i = 0;
i < 6;
i++)
208 for (
i = 0;
i < 6;
i++) {
218 int16_t (*
block)[64] =
a->block;
219 int linesize =
frame->linesize[0];
222 const uint8_t *ptr_y =
frame->data[0] + (mb_y * 16 * linesize) + mb_x * 16;
223 const uint8_t *ptr_cb =
frame->data[1] + (mb_y * 8 *
frame->linesize[1]) + mb_x * 8;
224 const uint8_t *ptr_cr =
frame->data[2] + (mb_y * 8 *
frame->linesize[2]) + mb_x * 8;
226 a->get_pixels(
block[0], ptr_y, linesize);
227 a->get_pixels(
block[1], ptr_y + 8, linesize);
228 a->get_pixels(
block[2], ptr_y + 8 * linesize, linesize);
229 a->get_pixels(
block[3], ptr_y + 8 * linesize + 8, linesize);
230 for (
i = 0;
i < 4;
i++)
234 a->get_pixels(
block[4], ptr_cb,
frame->linesize[1]);
235 a->get_pixels(
block[5], ptr_cr,
frame->linesize[2]);
236 for (
i = 4;
i < 6;
i++)
242 const int linesizes[3],
243 int valid_width,
int valid_height)
247 uint8_t x_offset, y_offset;
248 uint8_t component, subsampling;
249 } block_descriptor[] = {
250 { 0, 0, 0, 0 }, { 8, 0, 0, 0 }, { 0, 8, 0, 0 }, { 8, 8, 0, 0 },
251 { 0, 0, 1, 1 }, { 0, 0, 2, 1 },
254 for (
int i = 0;
i < nb_blocks; ++
i) {
259 if (width_avail <= 0 || height_avail <= 0) {
262 memset(
a->block[
i], 0,
sizeof(
a->block[
i]));
265 width_avail =
FFMIN(width_avail, 8);
266 height_avail =
FFMIN(height_avail, 8);
268 ptrdiff_t linesize = linesizes[
desc->component];
272 for (
int h = 0;;
block += 8,
src += linesize) {
274 for (
int w = 0;
w < width_avail; ++
w)
276 for (
int w = width_avail;
w < 8; ++
w)
278 if (++
h == height_avail)
281 const int16_t *
const last_row =
block;
282 for (
int h = height_avail;
h < 8; ++
h) {
287 a->fdsp.fdct(
a->block[
i]);
294 const AVFrame *pict,
int *got_packet)
305 ((uintptr_t)pict->
data[0] & 7 || pict->
linesize[0] & 7 ||
306 (uintptr_t)pict->
data[1] & 7 || pict->
linesize[1] & 7 ||
308 a->get_pixels =
a->pdsp.get_pixels_unaligned;
310 a->get_pixels =
a->pdsp.get_pixels;
314 for (
int mb_y = 0; mb_y <
c->mb_height2; mb_y++) {
315 for (
int mb_x = 0; mb_x <
c->mb_width2; mb_x++) {
321 if (avctx->
width & 15) {
322 const uint8_t *
src[3] = {
323 pict->
data[0] +
c->mb_width2 * 16,
324 pict->
data[1] +
c->mb_width2 * 8,
325 pict->
data[2] +
c->mb_width2 * 8,
327 int available_width = avctx->
width & 15;
329 for (
int mb_y = 0; mb_y <
c->mb_height2; mb_y++) {
338 const uint8_t *
src[3] = {
343 int available_height = avctx->
height & 15;
345 for (
int remaining = avctx->
width;; remaining -= 16) {
363 c->bbdsp.bswap_buf((uint32_t *)
pkt->data,
397 for (
i = 0;
i < 64;
i++) {
400 a->q_intra_matrix[
i] = (((
int64_t)inv_qscale << 30) + q / 2) / q;
403 a->q_intra_matrix[
i] = ((inv_qscale << 16) + q / 2) / q;
410#if CONFIG_ASV1_ENCODER
425#if CONFIG_ASV2_ENCODER
const uint16_t ff_aanscales[64]
AAN (Arai, Agui and Nakajima) (I)DCT tables.
const FFCodec ff_asv1_encoder
const FFCodec ff_asv2_encoder
const uint8_t ff_asv_level_tab[7][2]
const uint8_t ff_asv_dc_ccp_tab[8][2]
const uint8_t ff_asv_scantab[64]
const uint8_t ff_asv_ac_ccp_tab[16][2]
const uint16_t ff_asv2_level_tab[63][2]
av_cold void ff_asv_common_init(AVCodecContext *avctx)
const uint8_t ff_asv_ccp_tab[17][2]
ASUS V1/V2 encoder/decoder common data.
static void asv1_put_level(PutBitContext *pb, int level)
static void dct_get(ASVEncContext *a, const AVFrame *frame, int mb_x, int mb_y)
static int encode_mb(ASVEncContext *a, int16_t block[6][64])
static void asv2_encode_block(ASVEncContext *a, int16_t block[64])
static av_cold int encode_init(AVCodecContext *avctx)
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static void asv2_put_level(ASVEncContext *a, PutBitContext *pb, int level)
static void handle_partial_mb(ASVEncContext *a, const uint8_t *const data[3], const int linesizes[3], int valid_width, int valid_height)
static void asv1_encode_block(ASVEncContext *a, int16_t block[64])
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define AV_CEIL_RSHIFT(a, b)
int(* init)(AVBSFContext *ctx)
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
void ff_fdct_ifast(int16_t *data)
static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, AVPacket *pkt)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define AV_LOG_WARNING
Something somehow does not look correct.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, int bits_per_raw_sample)
Macro definitions for various function/variable attributes.
#define MKTAG(a, b, c, d)
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
const uint16_t ff_mpeg1_default_intra_matrix[256]
#define PIXBLOCKDSP_8BPP_GET_PIXELS_SUPPORTS_UNALIGNED
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void put_bits_le(PutBitContext *s, int n, BitBuf value)
static void flush_put_bits_le(PutBitContext *s)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static int put_bytes_left(const PutBitContext *s, int round_up)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int put_bytes_output(const PutBitContext *s)
void(* get_pixels)(int16_t *restrict block, const uint8_t *pixels, ptrdiff_t stride)
main external API structure.
int width
picture width / height.
int global_quality
Global quality for codecs which cannot change it per frame.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.