summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/atrac3.c11
-rw-r--r--libavcodec/cljr.c18
-rw-r--r--libavcodec/dxva2.h1
-rw-r--r--libavcodec/mpegvideo.c17
-rw-r--r--libavcodec/mpegvideo_common.h2
-rw-r--r--libavcodec/msrledec.c4
-rw-r--r--libavcodec/pcm-mpeg.c52
-rw-r--r--libavcodec/ppc/h264_altivec.c4
-rw-r--r--libavcodec/ppc/util_altivec.h2
-rw-r--r--libavcodec/tableprint.h4
-rw-r--r--libavcodec/vc1dec.c2
-rw-r--r--libavcodec/w32pthreads.h54
12 files changed, 117 insertions, 54 deletions
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index ccbb718e00..b9f1f516cc 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -708,9 +708,10 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_
memset(pSnd->IMDCT_buf, 0, 512 * sizeof(float));
/* gain compensation and overlapping */
- gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]),
- &((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]),
- &((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band]));
+ gainCompensateAndOverlap(pSnd->IMDCT_buf, &pSnd->prevFrame[band * 256],
+ &pOut[band * 256],
+ &pSnd->gainBlock[1 - pSnd->gcBlkSwitch].gBlock[band],
+ &pSnd->gainBlock[ pSnd->gcBlkSwitch].gBlock[band]);
}
/* Swap the gain control buffers for the next frame. */
@@ -795,7 +796,9 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf,
for (i=0 ; i<q->channels ; i++) {
/* Set the bitstream reader at the start of a channel sound unit. */
- init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels);
+ init_get_bits(&q->gb,
+ databuf + i * q->bytes_per_frame / q->channels,
+ q->bits_per_frame / q->channels);
result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[i], out_samples[i], i, q->codingMode);
if (result != 0)
diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c
index 6e352b8e61..53ab40cbe2 100644
--- a/libavcodec/cljr.c
+++ b/libavcodec/cljr.c
@@ -35,9 +35,6 @@
typedef struct CLJRContext{
AVCodecContext *avctx;
AVFrame picture;
- int delta[16];
- int offset[4];
- GetBitContext gb;
} CLJRContext;
static int decode_frame(AVCodecContext *avctx,
@@ -47,6 +44,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
CLJRContext * const a = avctx->priv_data;
+ GetBitContext gb;
AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&a->picture;
int x, y;
@@ -67,20 +65,20 @@ static int decode_frame(AVCodecContext *avctx,
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
- init_get_bits(&a->gb, buf, buf_size * 8);
+ init_get_bits(&gb, buf, buf_size * 8);
for(y=0; y<avctx->height; y++){
uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ];
uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ];
uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ];
for(x=0; x<avctx->width; x+=4){
- luma[3] = get_bits(&a->gb, 5) << 3;
- luma[2] = get_bits(&a->gb, 5) << 3;
- luma[1] = get_bits(&a->gb, 5) << 3;
- luma[0] = get_bits(&a->gb, 5) << 3;
+ luma[3] = get_bits(&gb, 5) << 3;
+ luma[2] = get_bits(&gb, 5) << 3;
+ luma[1] = get_bits(&gb, 5) << 3;
+ luma[0] = get_bits(&gb, 5) << 3;
luma+= 4;
- *(cb++) = get_bits(&a->gb, 6) << 2;
- *(cr++) = get_bits(&a->gb, 6) << 2;
+ *(cb++) = get_bits(&gb, 6) << 2;
+ *(cr++) = get_bits(&gb, 6) << 2;
}
}
diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h
index 6eb494b9fe..fc99560830 100644
--- a/libavcodec/dxva2.h
+++ b/libavcodec/dxva2.h
@@ -25,6 +25,7 @@
#include <stdint.h>
+#include <d3d9.h>
#include <dxva2api.h>
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 9c55af725e..666cad8151 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -840,10 +840,14 @@ av_cold int MPV_common_init(MpegEncContext *s)
FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail);
s->parse_context.state = -1;
- if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)) {
- s->visualization_buffer[0] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
- s->visualization_buffer[1] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
- s->visualization_buffer[2] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
+ if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
+ s->avctx->debug_mv) {
+ s->visualization_buffer[0] = av_malloc((s->mb_width * 16 +
+ 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
+ s->visualization_buffer[1] = av_malloc((s->mb_width * 16 +
+ 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
+ s->visualization_buffer[2] = av_malloc((s->mb_width * 16 +
+ 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
}
s->context_initialized = 1;
@@ -1512,7 +1516,8 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
}
}
- if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
+ if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
+ s->avctx->debug_mv) {
const int shift= 1 + s->quarter_sample;
int mb_y;
uint8_t *ptr;
@@ -1538,7 +1543,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
int mb_x;
for(mb_x=0; mb_x<s->mb_width; mb_x++){
const int mb_index= mb_x + mb_y*s->mb_stride;
- if((s->avctx->debug_mv) && pict->motion_val){
+ if (s->avctx->debug_mv && pict->motion_val) {
int type;
for(type=0; type<3; type++){
int direction = 0;
diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h
index bf6c4db580..a7badd1ffb 100644
--- a/libavcodec/mpegvideo_common.h
+++ b/libavcodec/mpegvideo_common.h
@@ -585,7 +585,7 @@ static inline void chroma_4mv_motion(MpegEncContext *s,
if (src_y == (s->height >> 1))
dxy &= ~2;
- offset = (src_y * (s->uvlinesize)) + src_x;
+ offset = src_y * s->uvlinesize + src_x;
ptr = ref_picture[1] + offset;
if(s->flags&CODEC_FLAG_EMU_EDGE){
if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8
diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c
index 97510830d5..db8de7032d 100644
--- a/libavcodec/msrledec.c
+++ b/libavcodec/msrledec.c
@@ -138,8 +138,8 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
uint32_t av_uninit(pix32);
unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3);
- output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
- output_end = pic->data[0] + (avctx->height) * pic->linesize[0];
+ output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
+ output_end = pic->data[0] + avctx->height * pic->linesize[0];
while(src < data + srcsize) {
p1 = *src++;
if(p1 == 0) { //Escape code
diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c
index 5d3dd7036a..b9417733ca 100644
--- a/libavcodec/pcm-mpeg.c
+++ b/libavcodec/pcm-mpeg.c
@@ -121,17 +121,30 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
return 0;
}
-static int pcm_bluray_decode_frame(AVCodecContext *avctx,
- void *data,
- int *data_size,
- AVPacket *avpkt)
+typedef struct PCMBRDecode {
+ AVFrame frame;
+} PCMBRDecode;
+
+static av_cold int pcm_bluray_decode_init(AVCodecContext * avctx)
+{
+ PCMBRDecode *s = avctx->priv_data;
+
+ avcodec_get_frame_defaults(&s->frame);
+ avctx->coded_frame = &s->frame;
+
+ return 0;
+}
+
+static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *src = avpkt->data;
int buf_size = avpkt->size;
+ PCMBRDecode *s = avctx->priv_data;
int num_source_channels, channel, retval;
- int sample_size, samples, output_size;
- int16_t *dst16 = data;
- int32_t *dst32 = data;
+ int sample_size, samples;
+ int16_t *dst16;
+ int32_t *dst32;
if (buf_size < 4) {
av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n");
@@ -148,15 +161,14 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
sample_size = (num_source_channels * avctx->bits_per_coded_sample) >> 3;
samples = buf_size / sample_size;
- output_size = samples * avctx->channels *
- (avctx->sample_fmt == AV_SAMPLE_FMT_S32 ? 4 : 2);
- if (output_size > *data_size) {
- av_log(avctx, AV_LOG_ERROR,
- "Insufficient output buffer space (%d bytes, needed %d bytes)\n",
- *data_size, output_size);
- return -1;
+ /* get output buffer */
+ s->frame.nb_samples = samples;
+ if ((retval = avctx->get_buffer(avctx, &s->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return retval;
}
- *data_size = output_size;
+ dst16 = (int16_t *)s->frame.data[0];
+ dst32 = (int32_t *)s->frame.data[0];
if (samples) {
switch (avctx->channel_layout) {
@@ -167,7 +179,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
samples *= num_source_channels;
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
#if HAVE_BIGENDIAN
- memcpy(dst16, src, output_size);
+ memcpy(dst16, src, buf_size);
#else
do {
*dst16++ = bytestream_get_be16(&src);
@@ -291,10 +303,13 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
}
}
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = s->frame;
+
retval = src - avpkt->data;
if (avctx->debug & FF_DEBUG_BITSTREAM)
av_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n",
- retval, *data_size);
+ retval, buf_size);
return retval;
}
@@ -302,7 +317,10 @@ AVCodec ff_pcm_bluray_decoder = {
.name = "pcm_bluray",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_PCM_BLURAY,
+ .priv_data_size = sizeof(PCMBRDecode),
+ .init = pcm_bluray_decode_init,
.decode = pcm_bluray_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"),
diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c
index bf4fd0f016..9b3622a673 100644
--- a/libavcodec/ppc/h264_altivec.c
+++ b/libavcodec/ppc/h264_altivec.c
@@ -616,8 +616,8 @@ static inline void write16x4(uint8_t *dst, int dst_stride,
*(dst_int+15*int_dst_stride) = *(src_int + 15);
}
-/** \brief performs a 6x16 transpose of data in src, and stores it to dst
- \todo FIXME: see if we can't spare some vec_lvsl() by them factorizing
+/** @brief performs a 6x16 transpose of data in src, and stores it to dst
+ @todo FIXME: see if we can't spare some vec_lvsl() by them factorizing
out of unaligned_load() */
#define readAndTranspose16x6(src, src_stride, r8, r9, r10, r11, r12, r13) {\
register vec_u8 r0 = unaligned_load(0, src); \
diff --git a/libavcodec/ppc/util_altivec.h b/libavcodec/ppc/util_altivec.h
index cb638dff08..6800348570 100644
--- a/libavcodec/ppc/util_altivec.h
+++ b/libavcodec/ppc/util_altivec.h
@@ -94,7 +94,7 @@ do { \
} while (0)
-/** \brief loads unaligned vector \a *src with offset \a offset
+/** @brief loads unaligned vector @a *src with offset @a offset
and returns it */
static inline vector unsigned char unaligned_load(int offset, uint8_t *src)
{
diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h
index e126a72afb..1b39dc6ba1 100644
--- a/libavcodec/tableprint.h
+++ b/libavcodec/tableprint.h
@@ -58,7 +58,7 @@ void write_##type##_2d_array(const void *arg, int len, int len2)\
/**
* @name Predefined functions for printing tables
*
- * \{
+ * @{
*/
void write_int8_t_array (const int8_t *, int);
void write_uint8_t_array (const uint8_t *, int);
@@ -69,7 +69,7 @@ void write_int8_t_2d_array (const void *, int, int);
void write_uint8_t_2d_array (const void *, int, int);
void write_uint32_t_2d_array(const void *, int, int);
void write_float_2d_array (const void *, int, int);
-/** \} */ // end of printfuncs group
+/** @} */ // end of printfuncs group
#define WRITE_ARRAY(prefix, type, name) \
do { \
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 6f1af89e22..20b7f72291 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -236,7 +236,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v)
if (s->mb_x) {
topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1;
fieldtx = v->fieldtx_plane[topleft_mb_pos];
- stride_y = (s->linesize) << fieldtx;
+ stride_y = s->linesize << fieldtx;
v_dist = (16 - fieldtx) >> (fieldtx == 0);
s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
s->dest[0] - 16 * s->linesize - 16,
diff --git a/libavcodec/w32pthreads.h b/libavcodec/w32pthreads.h
index c015b87a42..2d1470c5ee 100644
--- a/libavcodec/w32pthreads.h
+++ b/libavcodec/w32pthreads.h
@@ -115,9 +115,12 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m)
/* for pre-Windows 6.0 platforms we need to define and use our own condition
* variable and api */
typedef struct {
+ pthread_mutex_t mtx_broadcast;
pthread_mutex_t mtx_waiter_count;
volatile int waiter_count;
HANDLE semaphore;
+ HANDLE waiters_done;
+ int is_broadcast;
} win32_cond_t;
static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
@@ -136,8 +139,12 @@ static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
if (!win32_cond->semaphore)
return;
+ win32_cond->waiters_done = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (!win32_cond->waiters_done)
+ return;
pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL);
+ pthread_mutex_init(&win32_cond->mtx_broadcast, NULL);
}
static void pthread_cond_destroy(pthread_cond_t *cond)
@@ -149,7 +156,9 @@ static void pthread_cond_destroy(pthread_cond_t *cond)
/* non native condition variables */
CloseHandle(win32_cond->semaphore);
+ CloseHandle(win32_cond->waiters_done);
pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
+ pthread_mutex_destroy(&win32_cond->mtx_broadcast);
av_freep(&win32_cond);
cond->ptr = NULL;
}
@@ -157,41 +166,70 @@ static void pthread_cond_destroy(pthread_cond_t *cond)
static void pthread_cond_broadcast(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->ptr;
+ int have_waiter;
+
if (cond_broadcast) {
cond_broadcast(cond);
return;
}
/* non native condition variables */
+ pthread_mutex_lock(&win32_cond->mtx_broadcast);
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
+ have_waiter = 0;
+
if (win32_cond->waiter_count) {
- ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
- win32_cond->waiter_count = 0;
+ win32_cond->is_broadcast = 1;
+ have_waiter = 1;
}
- pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
+
+ if (have_waiter) {
+ ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
+ pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
+ WaitForSingleObject(win32_cond->waiters_done, INFINITE);
+ win32_cond->is_broadcast = 0;
+ } else
+ pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
+ pthread_mutex_unlock(&win32_cond->mtx_broadcast);
}
static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
win32_cond_t *win32_cond = cond->ptr;
+ int last_waiter;
if (cond_wait) {
cond_wait(cond, mutex, INFINITE);
return;
}
/* non native condition variables */
+ pthread_mutex_lock(&win32_cond->mtx_broadcast);
+ pthread_mutex_unlock(&win32_cond->mtx_broadcast);
+
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
win32_cond->waiter_count++;
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
+ // unlock the external mutex
pthread_mutex_unlock(mutex);
WaitForSingleObject(win32_cond->semaphore, INFINITE);
- pthread_mutex_lock(mutex);
+
+ pthread_mutex_lock(&win32_cond->mtx_waiter_count);
+ win32_cond->waiter_count--;
+ last_waiter = !win32_cond->waiter_count && win32_cond->is_broadcast;
+ pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
+
+ if (last_waiter)
+ SetEvent(win32_cond->waiters_done);
+
+ // lock the external mutex
+ return pthread_mutex_lock(mutex);
}
static void pthread_cond_signal(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->ptr;
+ int have_waiter;
if (cond_signal) {
cond_signal(cond);
return;
@@ -199,11 +237,11 @@ static void pthread_cond_signal(pthread_cond_t *cond)
/* non-native condition variables */
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
- if (win32_cond->waiter_count) {
- ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
- win32_cond->waiter_count--;
- }
+ have_waiter = win32_cond->waiter_count;
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
+
+ if (have_waiter)
+ ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
}
static void w32thread_init(void)