Skip to content

Commit

Permalink
Merge remote-tracking branch 'qatar/master'
Browse files Browse the repository at this point in the history
* qatar/master:
  avformat: Drop pointless "format" from container long names
  swscale: bury one more piece of inline asm under HAVE_INLINE_ASM.
  wv: K&R formatting cosmetics
  configure: Add missing descriptions to help output
  h264_ps: declare array of colorspace strings on its own line.
  fate: amix: specify f32 sample format for comparison
  tiny_psnr: support 32-bit float samples
  eamad/eatgq/eatqi: call special EA IDCT directly
  eamad: remove use of MpegEncContext
  mpegvideo: remove unnecessary inclusions of faandct.h
  af_asyncts: avoid overflow in out_size with large delta values
  af_asyncts: add first_pts option

Conflicts:
	configure
	libavcodec/eamad.c
	libavcodec/h264_ps.c
	libavformat/crcenc.c
	libavformat/ffmdec.c
	libavformat/ffmenc.c
	libavformat/framecrcenc.c
	libavformat/md5enc.c
	libavformat/nutdec.c
	libavformat/rawenc.c
	libavformat/yuv4mpeg.c
	tests/tiny_psnr.c

Merged-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Jul 30, 2012
2 parents a85b4a5 + 6774247 commit b5da7d4
Show file tree
Hide file tree
Showing 104 changed files with 400 additions and 324 deletions.
7 changes: 6 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Component options:
--enable-x11grab enable X11 grabbing [no]
--disable-network disable network support [no]
--disable-dct disable DCT code
--disable-dwt disable DWT code
--disable-lsp disable LSP code
--disable-mdct disable MDCT code
--disable-rdft disable RDFT code
--disable-fft disable FFT code
Expand Down Expand Up @@ -229,17 +231,19 @@ Advanced options (experts only):
--yasmexe=EXE use yasm-compatible assembler EXE [$yasmexe_default]
--cc=CC use C compiler CC [$cc_default]
--cxx=CXX use C compiler CXX [$cxx_default]
--dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
--ld=LD use linker LD [$ld_default]
--host-cc=HOSTCC use host C compiler HOSTCC
--host-cflags=HCFLAGS use HCFLAGS when compiling for host
--host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
--host-libs=HLIBS use libs HLIBS when linking for host
--host-os=OS compiler host OS [$target_os]
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
--extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
--extra-libs=ELIBS add ELIBS [$ELIBS]
--extra-version=STRING version string suffix []
--optflags override optimization-related compiler flags
--optflags=OPTFLAGS override optimization-related compiler flags
--build-suffix=SUFFIX library name suffix []
--malloc-prefix=PREFIX prefix malloc and related names with PREFIX
--progs-suffix=SUFFIX program name suffix []
Expand All @@ -248,6 +252,7 @@ Advanced options (experts only):
instruction selection, may crash on older CPUs)
--enable-pic build position-independent code
--enable-sram allow use of on-chip SRAM
--enable-thumb compile for Thumb instruction set
--disable-symver disable symbol versioning
--disable-fastdiv disable table-based division
--enable-hardcoded-tables use hardcoded tables instead of runtime generation
Expand Down
7 changes: 7 additions & 0 deletions doc/filters.texi
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ adding/dropping samples.
@item max_comp
Maximum compensation in samples per second.

@item first_pts
Assume the first pts should be this value.
This allows for padding/trimming at the start of stream. By default, no
assumption is made about the first frame's expected pts, so no padding or
trimming is done. For example, this could be set to 0 to pad the beginning with
silence if an audio stream starts after the video stream.

@end table

@section channelsplit
Expand Down
3 changes: 0 additions & 3 deletions libavcodec/dsputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -2880,9 +2880,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct_add= ff_faanidct_add;
c->idct = ff_faanidct;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
c->idct_put= ff_ea_idct_put_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{ //accurate/default
c->idct_put = ff_simple_idct_put_8;
c->idct_add = ff_simple_idct_add_8;
Expand Down
3 changes: 0 additions & 3 deletions libavcodec/dsputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ PUTAVG_PIXELS(14)
#define ff_put_pixels16x16_c ff_put_pixels16x16_8_c
#define ff_avg_pixels16x16_c ff_avg_pixels16x16_8_c

/* EA functions */
void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);

/* RV40 functions */
void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
Expand Down
1 change: 1 addition & 0 deletions libavcodec/eaidct.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "dsputil.h"
#include "eaidct.h"

#define ASQRT 181 /* (1/sqrt(2))<<8 */
#define A4 669 /* cos(pi/8)*sqrt(2)<<9 */
Expand Down
27 changes: 27 additions & 0 deletions libavcodec/eaidct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This file is part of FFmpeg
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef AVCODEC_EAIDCT_H
#define AVCODEC_EAIDCT_H

#include <stdint.h>
#include "dsputil.h"

void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);

#endif /* AVCODEC_EAIDCT_H */
114 changes: 54 additions & 60 deletions libavcodec/eamad.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "aandcttab.h"
#include "eaidct.h"
#include "mpeg12.h"
#include "mpeg12data.h"
#include "libavutil/imgutils.h"
Expand All @@ -42,12 +43,18 @@
#define MADe_TAG MKTAG('M', 'A', 'D', 'e') /* MAD lqp-frame */

typedef struct MadContext {
MpegEncContext s;
AVCodecContext *avctx;
DSPContext dsp;
AVFrame frame;
AVFrame last_frame;
GetBitContext gb;
void *bitstream_buf;
unsigned int bitstream_buf_size;
DECLARE_ALIGNED(16, DCTELEM, block)[64];
ScanTable scantable;
uint16_t quant_matrix[64];
int mb_x;
int mb_y;
} MadContext;

static void bswap16_buf(uint16_t *dst, const uint16_t *src, int count)
Expand All @@ -59,14 +66,12 @@ static void bswap16_buf(uint16_t *dst, const uint16_t *src, int count)

static av_cold int decode_init(AVCodecContext *avctx)
{
MadContext *t = avctx->priv_data;
MpegEncContext *s = &t->s;
MadContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->pix_fmt = PIX_FMT_YUV420P;
if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_EA;
ff_dsputil_init(&s->dsp, avctx);
ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
ff_init_scantable_permutation(s->dsp.idct_permutation, FF_NO_IDCT_PERM);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
ff_mpeg12_init_vlcs();
return 0;
}
Expand All @@ -83,19 +88,18 @@ static inline void comp(unsigned char *dst, int dst_stride,
static inline void comp_block(MadContext *t, int mb_x, int mb_y,
int j, int mv_x, int mv_y, int add)
{
MpegEncContext *s = &t->s;
if (j < 4) {
unsigned offset = (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x;
if (offset >= (s->height - 7) * t->last_frame.linesize[0] - 7)
if (offset >= (t->avctx->height - 7) * t->last_frame.linesize[0] - 7)
return;
comp(t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
t->frame.linesize[0],
t->last_frame.data[0] + offset,
t->last_frame.linesize[0], add);
} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
} else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) {
int index = j - 3;
unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2);
if (offset >= (s->height/2 - 7) * t->last_frame.linesize[index] - 7)
if (offset >= (t->avctx->height/2 - 7) * t->last_frame.linesize[index] - 7)
return;
comp(t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x * 8,
t->frame.linesize[index],
Expand All @@ -106,26 +110,24 @@ static inline void comp_block(MadContext *t, int mb_x, int mb_y,

static inline void idct_put(MadContext *t, DCTELEM *block, int mb_x, int mb_y, int j)
{
MpegEncContext *s = &t->s;
if (j < 4) {
s->dsp.idct_put(
ff_ea_idct_put_c(
t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
t->frame.linesize[0], block);
} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
} else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) {
int index = j - 3;
s->dsp.idct_put(
ff_ea_idct_put_c(
t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x*8,
t->frame.linesize[index], block);
}
}

static inline int decode_block_intra(MadContext * t, DCTELEM * block)
static inline int decode_block_intra(MadContext *s, DCTELEM * block)
{
MpegEncContext *s = &t->s;
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
const uint8_t *scantable = s->intra_scantable.permutated;
int16_t *quant_matrix = s->intra_matrix;
const uint8_t *scantable = s->scantable.permutated;
int16_t *quant_matrix = s->quant_matrix;

block[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];

Expand Down Expand Up @@ -191,9 +193,8 @@ static int decode_motion(GetBitContext *gb)
return value;
}

static int decode_mb(MadContext *t, int inter)
static int decode_mb(MadContext *s, int inter)
{
MpegEncContext *s = &t->s;
int mv_map = 0;
int mv_x, mv_y;
int j;
Expand All @@ -210,32 +211,25 @@ static int decode_mb(MadContext *t, int inter)
for (j=0; j<6; j++) {
if (mv_map & (1<<j)) { // mv_x and mv_y are guarded by mv_map
int add = 2*decode_motion(&s->gb);
if (t->last_frame.data[0])
comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
if (s->last_frame.data[0])
comp_block(s, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
} else {
s->dsp.clear_block(t->block);
if(decode_block_intra(t, t->block) < 0)
s->dsp.clear_block(s->block);
if(decode_block_intra(s, s->block) < 0)
return -1;
idct_put(t, t->block, s->mb_x, s->mb_y, j);
idct_put(s, s->block, s->mb_x, s->mb_y, j);
}
}
return 0;
}

static void calc_intra_matrix(MadContext *t, int qscale)
static void calc_quant_matrix(MadContext *s, int qscale)
{
MpegEncContext *s = &t->s;
int i;

if (s->avctx->idct_algo == FF_IDCT_EA) {
s->intra_matrix[0] = (ff_inv_aanscales[0]*ff_mpeg1_default_intra_matrix[0]) >> 11;
for (i=1; i<64; i++)
s->intra_matrix[i] = (ff_inv_aanscales[i]*ff_mpeg1_default_intra_matrix[i]*qscale + 32) >> 10;
} else {
s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
for (i=1; i<64; i++)
s->intra_matrix[i] = (ff_mpeg1_default_intra_matrix[i]*qscale) << 1;
}
s->quant_matrix[0] = (ff_inv_aanscales[0]*ff_mpeg1_default_intra_matrix[0]) >> 11;
for (i=1; i<64; i++)
s->quant_matrix[i] = (ff_inv_aanscales[i]*ff_mpeg1_default_intra_matrix[i]*qscale + 32) >> 10;
}

static int decode_frame(AVCodecContext *avctx,
Expand All @@ -245,8 +239,8 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_end = buf+buf_size;
MadContext *t = avctx->priv_data;
MpegEncContext *s = &t->s;
MadContext *s = avctx->priv_data;
int width, height;
int chunk_type;
int inter;

Expand All @@ -263,48 +257,48 @@ static int decode_frame(AVCodecContext *avctx,
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
AV_RL16(&buf[6]), 1000, 1<<30);

s->width = AV_RL16(&buf[8]);
s->height = AV_RL16(&buf[10]);
calc_intra_matrix(t, buf[13]);
width = AV_RL16(&buf[8]);
height = AV_RL16(&buf[10]);
calc_quant_matrix(s, buf[13]);
buf += 16;

if (avctx->width != s->width || avctx->height != s->height) {
if((s->width * s->height)/2048*7 > buf_end-buf)
if (avctx->width != width || avctx->height != height) {
if((width * height)/2048*7 > buf_end-buf)
return -1;
if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
if (av_image_check_size(width, height, 0, avctx) < 0)
return -1;
avcodec_set_dimensions(avctx, s->width, s->height);
if (t->frame.data[0])
avctx->release_buffer(avctx, &t->frame);
if (t->last_frame.data[0])
avctx->release_buffer(avctx, &t->last_frame);
avcodec_set_dimensions(avctx, width, height);
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
}

t->frame.reference = 3;
if (!t->frame.data[0]) {
if (avctx->get_buffer(avctx, &t->frame) < 0) {
s->frame.reference = 3;
if (!s->frame.data[0]) {
if (avctx->get_buffer(avctx, &s->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}

av_fast_malloc(&t->bitstream_buf, &t->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!t->bitstream_buf)
av_fast_malloc(&s->bitstream_buf, &s->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buf)
return AVERROR(ENOMEM);
bswap16_buf(t->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
memset((uint8_t*)t->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
init_get_bits(&s->gb, t->bitstream_buf, 8*(buf_end-buf));
bswap16_buf(s->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
memset((uint8_t*)s->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
init_get_bits(&s->gb, s->bitstream_buf, 8*(buf_end-buf));

for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)
if(decode_mb(t, inter) < 0)
if(decode_mb(s, inter) < 0)
return -1;

*data_size = sizeof(AVFrame);
*(AVFrame*)data = t->frame;
*(AVFrame*)data = s->frame;

if (chunk_type != MADe_TAG)
FFSWAP(AVFrame, t->frame, t->last_frame);
FFSWAP(AVFrame, s->frame, s->last_frame);

return buf_size;
}
Expand Down
Loading

0 comments on commit b5da7d4

Please sign in to comment.