aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-07 03:38:50 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-07 03:38:50 +0200
commit86602d1c79929caa1b88b942f0074b1481b52235 (patch)
treeb25d18d943dd732ef7814ad9d5392d62e07ffdfd
parent177ed7e818d1e3cb8159b99965254f1236bff106 (diff)
parenta72cad0a6c05aa74940101e937cb3dc602d7d67b (diff)
downloadffmpeg-86602d1c79929caa1b88b942f0074b1481b52235.tar.gz
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>
-rw-r--r--libavcodec/avcodec.h5
-rw-r--r--libavcodec/h264.c6
-rw-r--r--libavcodec/libx264.c29
-rw-r--r--libavcodec/mpegvideo.c21
-rw-r--r--libavcodec/mpegvideo.h3
-rw-r--r--libavcodec/utils.c3
-rw-r--r--libavcodec/version.h2
7 files changed, 54 insertions, 15 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index cb82ec7648..2b682fa6ac 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -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;
/**
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 197064faef..cb2ce986a9 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -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;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index c1aab6cf15..5c503237b5 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -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,
};
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index fbcd42c1f9..041c0c04c3 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -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);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 4a0822d467..7d6c8d24b8 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -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
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index f28b024c25..cc8362441c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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)
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1b5ee01c95..70f59b8dd1 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -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, \