proresdsp.c
Go to the documentation of this file.
1 /*
2  * Apple ProRes compatible decoder
3  *
4  * Copyright (c) 2010-2011 Maxim Poliakovski
5  *
6  * This file is part of Libav.
7  *
8  * Libav is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * Libav is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "dct.h"
24 #include "dsputil.h"
25 #include "proresdsp.h"
26 #include "simple_idct.h"
27 #include "libavutil/common.h"
28 
29 #define BIAS (1 << (PRORES_BITS_PER_SAMPLE - 1)) ///< bias value for converting signed pixels into unsigned ones
30 #define CLIP_MIN (1 << (PRORES_BITS_PER_SAMPLE - 8)) ///< minimum value for clipping resulting pixels
31 #define CLIP_MAX (1 << PRORES_BITS_PER_SAMPLE) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels
32 
33 #define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX))
34 
35 #if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
36 /**
37  * Add bias value, clamp and output pixels of a slice
38  */
39 static void put_pixels(uint16_t *dst, int stride, const int16_t *in)
40 {
41  int x, y, src_offset, dst_offset;
42 
43  for (y = 0, dst_offset = 0; y < 8; y++, dst_offset += stride) {
44  for (x = 0; x < 8; x++) {
45  src_offset = (y << 3) + x;
46 
47  dst[dst_offset + x] = CLIP_AND_BIAS(in[src_offset]);
48  }
49  }
50 }
51 
52 static void prores_idct_put_c(uint16_t *out, int linesize, int16_t *block, const int16_t *qmat)
53 {
54  ff_prores_idct(block, qmat);
55  put_pixels(out, linesize >> 1, block);
56 }
57 #endif
58 
59 #if CONFIG_PRORES_KS_ENCODER
60 static void prores_fdct_c(const uint16_t *src, int linesize, int16_t *block)
61 {
62  int x, y;
63  const uint16_t *tsrc = src;
64 
65  for (y = 0; y < 8; y++) {
66  for (x = 0; x < 8; x++)
67  block[y * 8 + x] = tsrc[x];
68  tsrc += linesize >> 1;
69  }
70  ff_jpeg_fdct_islow_10(block);
71 }
72 #endif
73 
75 {
76 #if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
77  dsp->idct_put = prores_idct_put_c;
79 
80  if (ARCH_X86) ff_proresdsp_x86_init(dsp, avctx);
81 
84 #endif
85 #if CONFIG_PRORES_KS_ENCODER
86  dsp->fdct = prores_fdct_c;
90 #endif
91 }
void ff_jpeg_fdct_islow_10(int16_t *data)
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
Definition: git-howto.txt:5
int idct_permutation_type
Definition: proresdsp.h:32
int stride
Definition: mace.c:144
void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
Definition: proresdsp.c:74
void ff_prores_idct(int16_t *block, const int16_t *qmat)
Special version of ff_simple_idct_10() which does dequantization and scales by a factor of 2 more bet...
Definition: simple_idct.c:221
uint8_t dct_permutation[64]
Definition: proresdsp.h:35
Discrete Time axis x
#define ARCH_X86
Definition: config.h:35
int dct_permutation_type
Definition: proresdsp.h:34
uint8_t idct_permutation[64]
Definition: proresdsp.h:33
#define FF_NO_IDCT_PERM
Definition: dsputil.h:251
AVS_Value src
Definition: avisynth_c.h:523
main external API structure.
#define CLIP_AND_BIAS(x)
Definition: proresdsp.c:33
void(* idct_put)(uint16_t *out, int linesize, int16_t *block, const int16_t *qmat)
Definition: proresdsp.h:36
void ff_init_scantable_permutation(uint8_t *idct_permutation, int idct_permutation_type)
Definition: dsputil.c:131
common internal and external API header
function y
Definition: D.m:1
DSP utils.
simple idct header.
void(* fdct)(const uint16_t *src, int linesize, int16_t *block)
Definition: proresdsp.h:37
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx)
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=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;}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_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_dlog(ac->avr,"%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-> out