summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c27
-rw-r--r--libavcodec/h264.h1
-rw-r--r--libavcodec/internal.h3
-rw-r--r--libavcodec/utils.c23
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavcodec/w32pthreads.h24
-rw-r--r--libavcodec/x86/h264_weight.asm4
7 files changed, 70 insertions, 14 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index d5b9b17..77db8ef 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1128,6 +1128,7 @@ int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
av_cold int ff_h264_decode_init(AVCodecContext *avctx){
H264Context *h= avctx->priv_data;
MpegEncContext * const s = &h->s;
+ int i;
MPV_decode_defaults(s);
@@ -1152,6 +1153,8 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){
h->thread_context[0] = h;
h->outputed_poc = h->next_outputed_poc = INT_MIN;
+ for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
+ h->last_pocs[i] = INT_MIN;
h->prev_poc_msb= 1<<16;
h->x264_build = -1;
ff_h264_reset_sei(h);
@@ -1493,11 +1496,23 @@ static void decode_postinit(H264Context *h, int setup_finished){
if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames)
{ }
- else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT)
- || (s->low_delay &&
- ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2)
- || cur->f.pict_type == AV_PICTURE_TYPE_B)))
- {
+ else if (out_of_order && pics-1 == s->avctx->has_b_frames &&
+ s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) {
+ int cnt = 0, invalid = 0;
+ for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) {
+ cnt += out->poc < h->last_pocs[i];
+ invalid += h->last_pocs[i] == INT_MIN;
+ }
+ if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
+ s->avctx->has_b_frames = FFMAX(s->avctx->has_b_frames, cnt);
+ } else if (cnt) {
+ for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
+ h->last_pocs[i] = INT_MIN;
+ }
+ s->low_delay = 0;
+ } else if (s->low_delay &&
+ ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) ||
+ cur->f.pict_type == AV_PICTURE_TYPE_B)) {
s->low_delay = 0;
s->avctx->has_b_frames++;
}
@@ -1509,6 +1524,8 @@ static void decode_postinit(H264Context *h, int setup_finished){
for(i=out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i+1];
}
+ memmove(h->last_pocs, &h->last_pocs[1], sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
+ h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = out->poc;
if(!out_of_order && pics > s->avctx->has_b_frames){
h->next_output_pic = out;
if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 63ed357..1dbf3ec 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -490,6 +490,7 @@ typedef struct H264Context{
Picture *long_ref[32];
Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture
Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size?
+ int last_pocs[MAX_DELAYED_PIC_COUNT];
Picture *next_output_pic;
int outputed_poc;
int next_outputed_poc;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index d431a85..375c567 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -60,4 +60,7 @@ unsigned int avpriv_toupper4(unsigned int x);
*/
void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic);
+int avpriv_lock_avformat(void);
+int avpriv_unlock_avformat(void);
+
#endif /* AVCODEC_INTERNAL_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b4c9404..7e0a8cf 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -48,6 +48,7 @@
static int volatile entangled_thread_counter=0;
static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
static void *codec_mutex;
+static void *avformat_mutex;
void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
{
@@ -1378,6 +1379,8 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
if (ff_lockmgr_cb) {
if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
return -1;
+ if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY))
+ return -1;
}
ff_lockmgr_cb = cb;
@@ -1385,6 +1388,26 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
if (ff_lockmgr_cb) {
if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
return -1;
+ if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE))
+ return -1;
+ }
+ return 0;
+}
+
+int avpriv_lock_avformat(void)
+{
+ if (ff_lockmgr_cb) {
+ if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_OBTAIN))
+ return -1;
+ }
+ return 0;
+}
+
+int avpriv_unlock_avformat(void)
+{
+ if (ff_lockmgr_cb) {
+ if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_RELEASE))
+ return -1;
}
return 0;
}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index ad64b60..6cbc3f6 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR 27
+#define LIBAVCODEC_VERSION_MINOR 28
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/w32pthreads.h b/libavcodec/w32pthreads.h
index 7774817..c015b87 100644
--- a/libavcodec/w32pthreads.h
+++ b/libavcodec/w32pthreads.h
@@ -91,10 +91,26 @@ static void pthread_join(pthread_t thread, void **value_ptr)
CloseHandle(thread.handle);
}
-#define pthread_mutex_init(m, a) InitializeCriticalSection(m)
-#define pthread_mutex_destroy(m) DeleteCriticalSection(m)
-#define pthread_mutex_lock(m) EnterCriticalSection(m)
-#define pthread_mutex_unlock(m) LeaveCriticalSection(m)
+static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr)
+{
+ InitializeCriticalSection(m);
+ return 0;
+}
+static inline int pthread_mutex_destroy(pthread_mutex_t *m)
+{
+ DeleteCriticalSection(m);
+ return 0;
+}
+static inline int pthread_mutex_lock(pthread_mutex_t *m)
+{
+ EnterCriticalSection(m);
+ return 0;
+}
+static inline int pthread_mutex_unlock(pthread_mutex_t *m)
+{
+ LeaveCriticalSection(m);
+ return 0;
+}
/* for pre-Windows 6.0 platforms we need to define and use our own condition
* variable and api */
diff --git a/libavcodec/x86/h264_weight.asm b/libavcodec/x86/h264_weight.asm
index 9bfa8f0..fbe6ce2 100644
--- a/libavcodec/x86/h264_weight.asm
+++ b/libavcodec/x86/h264_weight.asm
@@ -122,12 +122,8 @@ cglobal h264_weight_%1_%3, 6, 6, %2
INIT_MMX
WEIGHT_FUNC_HALF_MM 4, 0, mmx2
-WEIGHT_FUNC_HALF_MM 4, 0, mmx2
-WEIGHT_FUNC_HALF_MM 4, 0, mmx2
INIT_XMM
WEIGHT_FUNC_HALF_MM 8, 8, sse2
-WEIGHT_FUNC_HALF_MM 8, 8, sse2
-WEIGHT_FUNC_HALF_MM 8, 8, sse2
%macro BIWEIGHT_SETUP 0
%ifdef ARCH_X86_64
OpenPOWER on IntegriCloud