Merge remote-tracking branch 'qatar/master'

* qatar/master:
  vp6: Reset the internal state when aborting key frames header parsing
  vp56: Release old pictures after a resolution changes
  vp6: Check for huffman tree build errors
  vp56: Check for missing reference frame data
  cinepak: Fix invalid read access on extra data
  vmd: fix segfaults on corruped streams
  cook: Fix js_vlc_bits value validation for joint stereo
  segafilm: Check for memory allocation failures in segafilm demuxer.
  segafilm: Fix potential division by 0 on corrupted streams in the demuxer
  Fixed segfault on corrupted sega streams in the demuxer.
  Fixed deference of NULL pointer in motionpixels decoder.
  libx264: support 9- and 10-bit output.
  h264: correct implicit_weight for field-interlaced pictures.
  mpegvideo: set correct offset for edge emulation buffer.
  mpegvideo: fix position of bottom edge.

Conflicts:
	libavcodec/motionpixels.c
	libavcodec/mpegvideo.c
	libavcodec/version.h
	libavcodec/vmdav.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-10-07 03:38:50 +02:00
commit 86602d1c79
7 changed files with 54 additions and 15 deletions

View File

@ -3050,6 +3050,11 @@ typedef struct AVCodec {
* Private codec-specific defaults.
*/
const AVCodecDefault *defaults;
/**
* Initialize codec static data, called from avcodec_register().
*/
void (*init_static_data)(struct AVCodec *codec);
} AVCodec;
/**

View File

@ -2219,7 +2219,11 @@ static void implicit_weight_table(H264Context *h, int field){
}
if(field < 0){
cur_poc = s->current_picture_ptr->poc;
if (s->picture_structure == PICT_FRAME) {
cur_poc = s->current_picture_ptr->poc;
} else {
cur_poc = s->current_picture_ptr->field_poc[s->picture_structure - 1];
}
if( h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF
&& h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){
h->use_weight= 0;

View File

@ -20,6 +20,7 @@
*/
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "internal.h"
#include <x264.h>
@ -138,6 +139,8 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = X264_CSP_I420;
if (x264_bit_depth > 8)
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = 3;
if (frame) {
@ -510,6 +513,30 @@ static av_cold int X264_init(AVCodecContext *avctx)
return 0;
}
static const enum PixelFormat pix_fmts_8bit[] = {
PIX_FMT_YUV420P,
PIX_FMT_YUVJ420P,
PIX_FMT_NONE
};
static const enum PixelFormat pix_fmts_9bit[] = {
PIX_FMT_YUV420P9,
PIX_FMT_NONE
};
static const enum PixelFormat pix_fmts_10bit[] = {
PIX_FMT_YUV420P10,
PIX_FMT_NONE
};
static av_cold void X264_init_static(AVCodec *codec)
{
if (x264_bit_depth == 8)
codec->pix_fmts = pix_fmts_8bit;
else if (x264_bit_depth == 9)
codec->pix_fmts = pix_fmts_9bit;
else if (x264_bit_depth == 10)
codec->pix_fmts = pix_fmts_10bit;
}
#define OFFSET(x) offsetof(X264Context, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
@ -604,8 +631,8 @@ AVCodec ff_libx264_encoder = {
.encode = X264_frame,
.close = X264_close,
.capabilities = CODEC_CAP_DELAY,
.pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.priv_class = &class,
.defaults = x264_defaults,
.init_static_data = X264_init_static,
};

View File

@ -377,8 +377,7 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
int i;
// edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264)
FF_ALLOCZ_OR_GOTO(s->avctx, s->allocated_edge_emu_buffer, (s->width+64)*2*21*2*2, fail); //(width + edge + align)*interlaced*MBsize*tolerance
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21*2;
FF_ALLOCZ_OR_GOTO(s->avctx, s->edge_emu_buffer, (s->width+64)*2*21*2, fail); //(width + edge + align)*interlaced*MBsize*tolerance
//FIXME should be linesize instead of s->width*2 but that is not known before get_buffer()
FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, (s->width+64)*4*16*2*sizeof(uint8_t), fail)
@ -416,7 +415,7 @@ fail:
static void free_duplicate_context(MpegEncContext *s){
if(s==NULL) return;
av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL;
av_freep(&s->edge_emu_buffer);
av_freep(&s->me.scratchpad);
s->me.temp=
s->rd_scratchpad=
@ -433,7 +432,6 @@ static void free_duplicate_context(MpegEncContext *s){
static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){
#define COPY(a) bak->a= src->a
COPY(allocated_edge_emu_buffer);
COPY(edge_emu_buffer);
COPY(me.scratchpad);
COPY(me.temp);
@ -2329,12 +2327,15 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
edge_h= FFMIN(h, s->v_edge_pos - y);
s->dsp.draw_edges(s->current_picture_ptr->f.data[0] + y *s->linesize , s->linesize,
s->h_edge_pos , edge_h , EDGE_WIDTH , EDGE_WIDTH , sides);
s->dsp.draw_edges(s->current_picture_ptr->f.data[1] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
s->h_edge_pos>>hshift, edge_h>>vshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
s->dsp.draw_edges(s->current_picture_ptr->f.data[2] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
s->h_edge_pos>>hshift, edge_h>>vshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
s->dsp.draw_edges(s->current_picture_ptr->f.data[0] + y *s->linesize,
s->linesize, s->h_edge_pos, edge_h,
EDGE_WIDTH, EDGE_WIDTH, sides);
s->dsp.draw_edges(s->current_picture_ptr->f.data[1] + (y>>vshift)*s->uvlinesize,
s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
s->dsp.draw_edges(s->current_picture_ptr->f.data[2] + (y>>vshift)*s->uvlinesize,
s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
}
h= FFMIN(h, s->avctx->height - y);

View File

@ -321,8 +321,7 @@ typedef struct MpegEncContext {
uint8_t *mbintra_table; ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
uint8_t *cbp_table; ///< used to store cbp, ac_pred for partitioned decoding
uint8_t *pred_dir_table; ///< used to store pred_dir for partitioned decoding
uint8_t *allocated_edge_emu_buffer;
uint8_t *edge_emu_buffer; ///< points into the middle of allocated_edge_emu_buffer
uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data
uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision
uint8_t *obmc_scratchpad;
uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers

View File

@ -107,6 +107,9 @@ void avcodec_register(AVCodec *codec)
while (*p != NULL) p = &(*p)->next;
*p = codec;
codec->next = NULL;
if (codec->init_static_data)
codec->init_static_data(codec);
}
unsigned avcodec_get_edge_width(void)

View File

@ -22,7 +22,7 @@
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 19
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \