aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-04 00:32:31 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-04 00:32:31 +0200
commit86e107a7d468666189506d3edd4f4b5ca14cd59e (patch)
tree7270750bbe78c241461a844d7c1c8de3696e3765 /libavcodec
parentaf392efe51d5cc3536cb3c75bce8954179222d18 (diff)
parent1a068bfefd5da09f596e5079b39b418933bad0ea (diff)
downloadffmpeg-86e107a7d468666189506d3edd4f4b5ca14cd59e.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: cosmetics: Consistently use C-style comments with multiple inclusion guards anm: fix a few Doxygen comments misc typo and wording fixes attributes: add av_noreturn attributes: drop pointless define guards configure: do not disable av_always_inline with --enable-small flvdec: initial stream switch support avplay: fix write on freed memory for rawvideo snow: remove a VLA used for edge emulation x86: lavfi: fix gradfun/yadif build with mmx/sse disabled snow: remove the runs[] VLA. snow: Check mallocs at init flacdec: remove redundant setting of avctx->sample_fmt Conflicts: ffplay.c libavcodec/h264.c libavcodec/snow.c libavcodec/snow.h libavcodec/snowdec.c libavcodec/snowenc.c libavformat/flvdec.c libavutil/attributes.h tools/patcheck Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/anm.c9
-rw-r--r--libavcodec/dsputil.h4
-rw-r--r--libavcodec/flacdec.c2
-rw-r--r--libavcodec/h264.c4
-rw-r--r--libavcodec/snow.c25
-rw-r--r--libavcodec/snow.h3
-rw-r--r--libavcodec/snowdec.c7
-rw-r--r--libavcodec/snowenc.c21
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavcodec/xvmc.h2
10 files changed, 48 insertions, 31 deletions
diff --git a/libavcodec/anm.c b/libavcodec/anm.c
index d3f9d095b2..7fdfc94d0f 100644
--- a/libavcodec/anm.c
+++ b/libavcodec/anm.c
@@ -56,8 +56,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
/**
* Perform decode operation
- * @param dst, dst_end Destination image buffer
- * @param gb, GetByteContext (optional, see below)
+ * @param dst pointer to destination image buffer
+ * @param dst_end pointer to end of destination image buffer
+ * @param gb GetByteContext (optional, see below)
* @param pixel Fill color (optional, see below)
* @param count Pixel count
* @param x Pointer to x-axis counter
@@ -66,8 +67,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
* @return non-zero if destination buffer is exhausted
*
* a copy operation is achieved when 'gb' is set
- * a fill operation is acheived when 'gb' is null and pixel is >= 0
- * a skip operation is acheived when 'gb' is null and pixel is < 0
+ * a fill operation is achieved when 'gb' is null and pixel is >= 0
+ * a skip operation is achieved when 'gb' is null and pixel is < 0
*/
static inline int op(uint8_t **dst, const uint8_t *dst_end,
GetByteContext *gb,
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index e1aefe1eb6..c1397980f9 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -552,9 +552,9 @@ typedef struct DSPContext {
* @param src source array
* constraints: 16-byte aligned
* @param min minimum value
- * constraints: must in the the range [-(1<<24), 1<<24]
+ * constraints: must be in the range [-(1 << 24), 1 << 24]
* @param max maximum value
- * constraints: must in the the range [-(1<<24), 1<<24]
+ * constraints: must be in the range [-(1 << 24), 1 << 24]
* @param len number of elements in the array
* constraints: multiple of 32 greater than zero
*/
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 82c4e807dd..02ed463eb3 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -108,8 +108,6 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
FLACContext *s = avctx->priv_data;
s->avctx = avctx;
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-
/* for now, the raw FLAC header is allowed to be passed to the decoder as
frame data instead of extradata. */
if (!avctx->extradata)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 0958c09fc6..5cf8d54f51 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1737,7 +1737,7 @@ static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y,
}
top_border = h->top_borders[top_idx][s->mb_x];
- /* There are two lines saved, the line above the the top macroblock
+ /* There are two lines saved, the line above the top macroblock
* of a pair, and the line above the bottom macroblock. */
AV_COPY128(top_border, src_y + 16 * linesize);
if (pixel_shift)
@@ -4443,7 +4443,7 @@ again:
init_get_bits(&s->gb, ptr, bit_length);
if (ff_h264_decode_seq_parameter_set(h) < 0 && (h->is_avc ? (nalsize != consumed) && nalsize : 1)) {
av_log(h->s.avctx, AV_LOG_DEBUG,
- "SPS decoding failure, trying alternative mode\n");
+ "SPS decoding failure, trying again with the complete NAL\n");
if (h->is_avc)
av_assert0(next_avc - buf_index + consumed == nalsize);
init_get_bits(&s->gb, &buf[buf_index + 1 - consumed],
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 309e1bf040..04072501ad 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -394,7 +394,8 @@ mca( 8, 8,8)
av_cold int ff_snow_common_init(AVCodecContext *avctx){
SnowContext *s = avctx->priv_data;
int width, height;
- int i, j;
+ int i, j, ret;
+ int emu_buf_size;
s->avctx= avctx;
s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe
@@ -447,19 +448,27 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
width= s->avctx->width;
height= s->avctx->height;
- s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM));
- s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this does not belong here
- s->temp_dwt_buffer = av_mallocz(width * sizeof(DWTELEM));
- s->temp_idwt_buffer = av_mallocz(width * sizeof(IDWTELEM));
+ FF_ALLOCZ_OR_GOTO(avctx, s->spatial_idwt_buffer, width * height * sizeof(IDWTELEM), fail);
+ FF_ALLOCZ_OR_GOTO(avctx, s->spatial_dwt_buffer, width * height * sizeof(DWTELEM), fail); //FIXME this does not belong here
+ FF_ALLOCZ_OR_GOTO(avctx, s->temp_dwt_buffer, width * sizeof(DWTELEM), fail);
+ FF_ALLOCZ_OR_GOTO(avctx, s->temp_idwt_buffer, width * sizeof(IDWTELEM), fail);
+ FF_ALLOC_OR_GOTO(avctx, s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1) * sizeof(*s->run_buffer), fail);
for(i=0; i<MAX_REF_FRAMES; i++)
for(j=0; j<MAX_REF_FRAMES; j++)
ff_scale_mv_ref[i][j] = 256*(i+1)/(j+1);
- s->avctx->get_buffer(s->avctx, &s->mconly_picture);
- s->scratchbuf = av_mallocz(s->mconly_picture.linesize[0]*7*MB_SIZE);
+ if ((ret = s->avctx->get_buffer(s->avctx, &s->mconly_picture)) < 0) {
+// av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+// return ret;
+ }
+ FF_ALLOCZ_OR_GOTO(avctx, s->scratchbuf, FFMAX(s->mconly_picture.linesize[0], 2*width+256)*7*MB_SIZE, fail);
+ emu_buf_size = FFMAX(s->mconly_picture.linesize[0], 2*width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
+ FF_ALLOC_OR_GOTO(avctx, s->emu_edge_buffer, emu_buf_size, fail);
return 0;
+fail:
+ return AVERROR(ENOMEM);
}
int ff_snow_common_init_after_header(AVCodecContext *avctx) {
@@ -632,6 +641,7 @@ av_cold void ff_snow_common_end(SnowContext *s)
av_freep(&s->temp_dwt_buffer);
av_freep(&s->spatial_idwt_buffer);
av_freep(&s->temp_idwt_buffer);
+ av_freep(&s->run_buffer);
s->m.me.temp= NULL;
av_freep(&s->m.me.scratchpad);
@@ -641,6 +651,7 @@ av_cold void ff_snow_common_end(SnowContext *s)
av_freep(&s->block);
av_freep(&s->scratchbuf);
+ av_freep(&s->emu_edge_buffer);
for(i=0; i<MAX_REF_FRAMES; i++){
av_freep(&s->ref_mvs[i]);
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index c5d6492a9f..7e35b5f1be 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -135,6 +135,7 @@ typedef struct SnowContext{
DWTELEM *temp_dwt_buffer;
IDWTELEM *spatial_idwt_buffer;
IDWTELEM *temp_idwt_buffer;
+ int *run_buffer;
int colorspace_type;
int chroma_h_shift;
int chroma_v_shift;
@@ -165,7 +166,7 @@ typedef struct SnowContext{
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX)
uint8_t *scratchbuf;
- int *runs;
+ uint8_t *emu_edge_buffer;
}SnowContext;
/* Tables */
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index 405166c5fe..11a54dca71 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -365,7 +365,12 @@ static int decode_header(SnowContext *s){
static av_cold int decode_init(AVCodecContext *avctx)
{
- ff_snow_common_init(avctx);
+ int ret;
+
+ if ((ret = ff_snow_common_init(avctx)) < 0) {
+ ff_snow_common_end(avctx->priv_data);
+ return ret;
+ }
return 0;
}
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 1a60dbf96d..d6dd58cc2c 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -156,7 +156,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
static av_cold int encode_init(AVCodecContext *avctx)
{
SnowContext *s = avctx->priv_data;
- int plane_index;
+ int plane_index, ret;
if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
av_log(avctx, AV_LOG_ERROR, "This codec is under development, files encoded with it may not be decodable with future versions!!!\n"
@@ -185,7 +185,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->plane[plane_index].fast_mc= 1;
}
- ff_snow_common_init(avctx);
+ if ((ret = ff_snow_common_init(avctx)) < 0) {
+ ff_snow_common_end(avctx->priv_data);
+ return ret;
+ }
ff_snow_alloc_blocks(s);
s->version=0;
@@ -246,8 +249,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
}
- s->runs = av_malloc(avctx->width * avctx->height * sizeof(*s->runs));
-
return 0;
}
@@ -677,7 +678,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin
uint8_t *src= s-> input_picture.data[plane_index];
IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4;
uint8_t *cur = s->scratchbuf;
- uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS_MAX-1)];
+ uint8_t *tmp = s->emu_edge_buffer;
const int b_stride = s->b_width << s->block_max_depth;
const int b_height = s->b_height<< s->block_max_depth;
const int w= p->width;
@@ -843,6 +844,7 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, const IDWTELEM *src,
if(1){
int run=0;
+ int *runs = s->run_buffer;
int run_index=0;
int max_index;
@@ -876,7 +878,7 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, const IDWTELEM *src,
}
if(!(/*ll|*/l|lt|t|rt|p)){
if(v){
- s->runs[run_index++]= run;
+ runs[run_index++]= run;
run=0;
}else{
run++;
@@ -885,9 +887,9 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, const IDWTELEM *src,
}
}
max_index= run_index;
- s->runs[run_index++]= run;
+ runs[run_index++]= run;
run_index=0;
- run= s->runs[run_index++];
+ run= runs[run_index++];
put_symbol2(&s->c, b->state[30], max_index, 0);
if(run_index <= max_index)
@@ -931,7 +933,7 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, const IDWTELEM *src,
put_rac(&s->c, &b->state[0][context], !!v);
}else{
if(!run){
- run= s->runs[run_index++];
+ run= runs[run_index++];
if(run_index <= max_index)
put_symbol2(&s->c, b->state[1], run, 3);
@@ -1909,7 +1911,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
if (s->input_picture.data[0])
avctx->release_buffer(avctx, &s->input_picture);
av_free(avctx->stats_out);
- av_freep(&s->runs);
return 0;
}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 275200f16b..8709230c24 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -41,7 +41,7 @@
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
/**
- * Those FF_API_* defines are not part of public API.
+ * These FF_API_* defines are not part of the public API.
* They may change, break or disappear at any time.
*/
#ifndef FF_API_REQUEST_CHANNELS
diff --git a/libavcodec/xvmc.h b/libavcodec/xvmc.h
index fdaea7eab7..b2bf518d0c 100644
--- a/libavcodec/xvmc.h
+++ b/libavcodec/xvmc.h
@@ -147,7 +147,7 @@ struct xvmc_pix_fmt {
*/
int filled_mv_blocks_num;
- /** Number of the the next free data block; one data block consists of
+ /** Number of the next free data block; one data block consists of
64 short values in the data_blocks array.
All blocks before this one have already been claimed by placing their
position into the corresponding block description structure field,