summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad.c4
-rw-r--r--libmpcodecs/ad_ffmpeg.c11
-rw-r--r--libmpcodecs/ae_lavc.c1
-rw-r--r--libmpcodecs/mp_image.h3
-rw-r--r--libmpcodecs/vd_ffmpeg.c4
-rw-r--r--libmpcodecs/vd_libmpeg2.c8
-rw-r--r--libmpcodecs/vf.c4
-rw-r--r--libmpcodecs/vf_bmovl.c2
-rw-r--r--libmpcodecs/vf_filmdint.c8
-rw-r--r--libmpcodecs/vf_framestep.c3
-rw-r--r--libmpcodecs/vf_ilpack.c4
-rw-r--r--libmpcodecs/vf_noise.c6
-rw-r--r--libmpcodecs/vf_sab.c8
-rw-r--r--libmpcodecs/vf_scale.c12
-rw-r--r--libmpcodecs/vf_screenshot.c12
-rw-r--r--libmpcodecs/vf_smartblur.c8
-rw-r--r--libmpcodecs/vf_tile.c2
-rw-r--r--libmpcodecs/vf_yadif.c4
18 files changed, 52 insertions, 52 deletions
diff --git a/libmpcodecs/ad.c b/libmpcodecs/ad.c
index 3f191826fa..c7e87cd92e 100644
--- a/libmpcodecs/ad.c
+++ b/libmpcodecs/ad.c
@@ -1,6 +1,4 @@
-/*
- ad.c - audio decoder interface
-*/
+/* audio decoder interface */
#include <stdio.h>
#include <stdlib.h>
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index 560dd90c0a..7ecbb20cb3 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -112,6 +112,15 @@ static int init(sh_audio_t *sh_audio)
sh_audio->channels=lavc_context->channels;
sh_audio->samplerate=lavc_context->sample_rate;
sh_audio->i_bps=lavc_context->bit_rate/8;
+ switch (lavc_context->sample_fmt) {
+ case SAMPLE_FMT_U8: sh_audio->sample_format = AF_FORMAT_U8; break;
+ case SAMPLE_FMT_S16: sh_audio->sample_format = AF_FORMAT_S16_NE; break;
+ case SAMPLE_FMT_S32: sh_audio->sample_format = AF_FORMAT_S32_NE; break;
+ case SAMPLE_FMT_FLT: sh_audio->sample_format = AF_FORMAT_FLOAT_NE; break;
+ default:
+ mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n");
+ return 0;
+ }
if(sh_audio->wf){
// If the decoder uses the wrong number of channels all is lost anyway.
// sh_audio->channels=sh_audio->wf->nChannels;
@@ -120,7 +129,7 @@ static int init(sh_audio_t *sh_audio)
if (sh_audio->wf->nAvgBytesPerSec)
sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
}
- sh_audio->samplesize=2;
+ sh_audio->samplesize=af_fmt2bits(sh_audio->sample_format)/ 8;
return 1;
}
diff --git a/libmpcodecs/ae_lavc.c b/libmpcodecs/ae_lavc.c
index 3b07d6a963..4bc82abed4 100644
--- a/libmpcodecs/ae_lavc.c
+++ b/libmpcodecs/ae_lavc.c
@@ -248,6 +248,7 @@ int mpae_init_lavc(audio_encoder_t *encoder)
}
encoder->decode_buffer_size = lavc_actx->frame_size * 2 * encoder->params.channels;
+ while (encoder->decode_buffer_size < 1024) encoder->decode_buffer_size *= 2;
encoder->bind = bind_lavc;
encoder->get_frame_size = get_frame_size;
encoder->encode = encode_lavc;
diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h
index fb06e62fc9..77ce04102a 100644
--- a/libmpcodecs/mp_image.h
+++ b/libmpcodecs/mp_image.h
@@ -54,8 +54,6 @@
// buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
#define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
-// set if it can not be reused yet (for MP_IMGTYPE_NUMBERED)
-#define MP_IMGFLAG_IN_USE 0x10000
// codec doesn't support any form of direct rendering - it has own buffer
// allocation. so we just export its buffer pointers:
@@ -101,6 +99,7 @@ typedef struct mp_image {
int chroma_height;
int chroma_x_shift; // horizontal
int chroma_y_shift; // vertical
+ int usage_count;
/* for private use by filter or vo driver (to store buffer id or dmpi) */
void* priv;
} mp_image_t;
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 16b8eb9452..708254304d 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -434,7 +434,7 @@ static void draw_slice(struct AVCodecContext *s,
const AVFrame *src, int offset[4],
int y, int type, int height){
sh_video_t *sh = s->opaque;
- uint8_t *source[3]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2]};
+ uint8_t *source[MP_MAX_PLANES]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2]};
#if 0
int start=0, i;
int width= s->width;
@@ -703,7 +703,7 @@ static void release_buffer(struct AVCodecContext *avctx, AVFrame *pic){
}
#endif
// release mpi (in case MPI_IMGTYPE_NUMBERED is used, e.g. for VDPAU)
- mpi->flags &= ~MP_IMGFLAG_IN_USE;
+ mpi->usage_count--;
}
if(pic->type!=FF_BUFFER_TYPE_USER){
diff --git a/libmpcodecs/vd_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c
index ef7671e3ce..1a8fd6f214 100644
--- a/libmpcodecs/vd_libmpeg2.c
+++ b/libmpcodecs/vd_libmpeg2.c
@@ -125,14 +125,12 @@ static void draw_slice (void * _sh, uint8_t * const * src, unsigned int y){
vd_libmpeg2_ctx_t *context = sh->context;
mpeg2dec_t* mpeg2dec = context->mpeg2dec;
const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
- int stride[3];
+ int stride[MP_MAX_PLANES] = {mpeg2dec->decoder.stride, mpeg2dec->decoder.uv_stride, mpeg2dec->decoder.uv_stride};
+ uint8_t *srcs[MP_MAX_PLANES] = {src[0], src[1], src[2]};
// printf("draw_slice() y=%d \n",y);
- stride[0]=mpeg2dec->decoder.stride;
- stride[1]=stride[2]=mpeg2dec->decoder.uv_stride;
-
- mpcodecs_draw_slice(sh, (uint8_t **)src,
+ mpcodecs_draw_slice(sh, srcs,
stride, info->sequence->picture_width,
(y+16<=info->sequence->picture_height) ? 16 :
info->sequence->picture_height-y,
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 445e631c21..9bed6c78f8 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -303,7 +303,7 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
if (number == -1) {
int i;
for (i = 0; i < NUM_NUMBERED_MPI; i++)
- if (!vf->imgctx.numbered_images[i] || !(vf->imgctx.numbered_images[i]->flags & MP_IMGFLAG_IN_USE))
+ if (!vf->imgctx.numbered_images[i] || !vf->imgctx.numbered_images[i]->usage_count)
break;
number = i;
}
@@ -430,7 +430,7 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
mpi->qscale = NULL;
}
- mpi->flags |= MP_IMGFLAG_IN_USE;
+ mpi->usage_count++;
// printf("\rVF_MPI: %p %p %p %d %d %d \n",
// mpi->planes[0],mpi->planes[1],mpi->planes[2],
// mpi->stride[0],mpi->stride[1],mpi->stride[2]);
diff --git a/libmpcodecs/vf_bmovl.c b/libmpcodecs/vf_bmovl.c
index 1c16d60ca7..0412779cb5 100644
--- a/libmpcodecs/vf_bmovl.c
+++ b/libmpcodecs/vf_bmovl.c
@@ -1,5 +1,5 @@
/*
- * vf_bmovl.c v0.9.1 - BitMap OVerLay video filter for MPlayer
+ * BitMap OVerLay video filter for MPlayer
*
* (C) 2002 Per Wigren <wigren@home.se>
*
diff --git a/libmpcodecs/vf_filmdint.c b/libmpcodecs/vf_filmdint.c
index 5427171fbd..b15990bd97 100644
--- a/libmpcodecs/vf_filmdint.c
+++ b/libmpcodecs/vf_filmdint.c
@@ -422,7 +422,7 @@ block_metrics_faster_c(unsigned char *a, unsigned char *b, int as, int bs,
"paddusw %%mm2, %%mm7\n\t" \
"paddusw %%mm1, %%mm7\n\t" \
: "=r" (a), "=r" (b) \
- : "r"((long)as), "r"((long)bs), "m" (ones), "0"(a), "1"(b), "X"(*a), "X"(*b) \
+ : "r"((x86_reg)as), "r"((x86_reg)bs), "m" (ones), "0"(a), "1"(b), "X"(*a), "X"(*b) \
); \
} while (--lines);
@@ -464,8 +464,8 @@ block_metrics_mmx2(unsigned char *a, unsigned char *b, int as, int bs,
mp_msg(MSGT_VFILTER, MSGL_FATAL, "block_metrics_mmx2: internal error\n");
#else
static const unsigned long long ones = 0x0101010101010101ull;
- unsigned long interlaced;
- unsigned long prefetch_line = (((long)a>>3) & 7) + 10;
+ x86_reg interlaced;
+ x86_reg prefetch_line = (((long)a>>3) & 7) + 10;
#ifdef DEBUG
struct frame_stats ts = *s;
#endif
@@ -631,7 +631,7 @@ dint_copy_line_mmx2(unsigned char *dst, unsigned char *a, long bos,
"por %%mm3, %%mm1 \n\t" /* avg if >= threshold */
"movq %%mm1, (%2,%4) \n\t"
: /* no output */
- : "r" (a), "r" (bos), "r" (dst), "r" ((long)ss), "r" ((long)ds), "r" (cos)
+ : "r" (a), "r" ((x86_reg)bos), "r" ((x86_reg)dst), "r" ((x86_reg)ss), "r" ((x86_reg)ds), "r" ((x86_reg)cos)
);
a += 8;
dst += 8;
diff --git a/libmpcodecs/vf_framestep.c b/libmpcodecs/vf_framestep.c
index c5f93244de..fde72bd6e7 100644
--- a/libmpcodecs/vf_framestep.c
+++ b/libmpcodecs/vf_framestep.c
@@ -1,6 +1,5 @@
/*
- * vf_fstep.c - filter to ouput only 1 every n frame, or only the I (key)
- * frame
+ * filter to ouput only 1 every n frame, or only the I (key)frame
*
* The parameters are:
*
diff --git a/libmpcodecs/vf_ilpack.c b/libmpcodecs/vf_ilpack.c
index f3ce051535..1f25e054f5 100644
--- a/libmpcodecs/vf_ilpack.c
+++ b/libmpcodecs/vf_ilpack.c
@@ -187,7 +187,7 @@ static void pack_li_0_MMX(unsigned char *dst, unsigned char *y,
:
: "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
#if ARCH_X86_64
- "d" ((long)us), "r" ((long)vs)
+ "d" ((x86_reg)us), "r" ((x86_reg)vs)
#else
"d" (&us)
#endif
@@ -299,7 +299,7 @@ static void pack_li_1_MMX(unsigned char *dst, unsigned char *y,
:
: "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
#if ARCH_X86_64
- "d" ((long)us), "r" ((long)vs)
+ "d" ((x86_reg)us), "r" ((x86_reg)vs)
#else
"d" (&us)
#endif
diff --git a/libmpcodecs/vf_noise.c b/libmpcodecs/vf_noise.c
index f797121973..0d4a089d5e 100644
--- a/libmpcodecs/vf_noise.c
+++ b/libmpcodecs/vf_noise.c
@@ -147,7 +147,7 @@ static int8_t *initNoise(FilterParam *fp){
#if HAVE_MMX
static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
- long mmx_len= len&(~7);
+ x86_reg mmx_len= len&(~7);
noise+=shift;
__asm__ volatile(
@@ -176,7 +176,7 @@ static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int
//duplicate of previous except movntq
#if HAVE_MMX2
static inline void lineNoise_MMX2(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
- long mmx_len= len&(~7);
+ x86_reg mmx_len= len&(~7);
noise+=shift;
__asm__ volatile(
@@ -218,7 +218,7 @@ static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int le
#if HAVE_MMX
static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t **shift){
- long mmx_len= len&(~7);
+ x86_reg mmx_len= len&(~7);
__asm__ volatile(
"mov %5, %%"REG_a" \n\t"
diff --git a/libmpcodecs/vf_sab.c b/libmpcodecs/vf_sab.c
index 5074e45b3e..5a0ce4e48f 100644
--- a/libmpcodecs/vf_sab.c
+++ b/libmpcodecs/vf_sab.c
@@ -174,10 +174,10 @@ static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride,
int x, y;
FilterParam f= *fp;
const int radius= f.distWidth/2;
- uint8_t *srcArray[3]= {src, NULL, NULL};
- uint8_t *dstArray[3]= {f.preFilterBuf, NULL, NULL};
- int srcStrideArray[3]= {srcStride, 0, 0};
- int dstStrideArray[3]= {f.preFilterStride, 0, 0};
+ uint8_t *srcArray[MP_MAX_PLANES]= {src};
+ uint8_t *dstArray[MP_MAX_PLANES]= {f.preFilterBuf};
+ int srcStrideArray[MP_MAX_PLANES]= {srcStride};
+ int dstStrideArray[MP_MAX_PLANES]= {f.preFilterStride};
// f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
sws_scale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index fd1c6ee7f3..b453114475 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -318,9 +318,9 @@ static void start_slice(struct vf_instance* vf, mp_image_t *mpi){
vf->priv->w, vf->priv->h);
}
-static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src[3], int src_stride[3], int y, int h,
- uint8_t *dst[3], int dst_stride[3], int interlaced){
- uint8_t *src2[3]={src[0], src[1], src[2]};
+static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src[MP_MAX_PLANES], int src_stride[MP_MAX_PLANES],
+ int y, int h, uint8_t *dst[MP_MAX_PLANES], int dst_stride[MP_MAX_PLANES], int interlaced){
+ uint8_t *src2[MP_MAX_PLANES]={src[0], src[1], src[2]};
#ifdef WORDS_BIGENDIAN
uint32_t pal2[256];
if (src[1] && !src[2]){
@@ -333,9 +333,9 @@ static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src
if(interlaced){
int i;
- uint8_t *dst2[3]={dst[0], dst[1], dst[2]};
- int src_stride2[3]={2*src_stride[0], 2*src_stride[1], 2*src_stride[2]};
- int dst_stride2[3]={2*dst_stride[0], 2*dst_stride[1], 2*dst_stride[2]};
+ uint8_t *dst2[MP_MAX_PLANES]={dst[0], dst[1], dst[2]};
+ int src_stride2[MP_MAX_PLANES]={2*src_stride[0], 2*src_stride[1], 2*src_stride[2]};
+ int dst_stride2[MP_MAX_PLANES]={2*dst_stride[0], 2*dst_stride[1], 2*dst_stride[2]};
sws_scale_ordered(sws1, src2, src_stride2, y>>1, h>>1, dst2, dst_stride2);
for(i=0; i<3; i++){
diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c
index cded6ad1dd..1fb37a623b 100644
--- a/libmpcodecs/vf_screenshot.c
+++ b/libmpcodecs/vf_screenshot.c
@@ -108,16 +108,14 @@ static void gen_fname(struct vf_priv_s* priv)
static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi)
{
- uint8_t *dst[3];
- int dst_stride[3];
+ uint8_t *dst[MP_MAX_PLANES] = {NULL};
+ int dst_stride[MP_MAX_PLANES] = {0};
dst_stride[0] = priv->stride;
- dst_stride[1] = dst_stride[2] = 0;
if (!priv->buffer)
priv->buffer = memalign(16, dst_stride[0]*priv->dh);
dst[0] = priv->buffer;
- dst[1] = dst[2] = 0;
sws_scale_ordered(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride);
}
@@ -137,12 +135,10 @@ static void draw_slice(struct vf_instance* vf, unsigned char** src,
int* stride, int w,int h, int x, int y)
{
if (vf->priv->store_slices) {
- uint8_t *dst[3];
- int dst_stride[3];
+ uint8_t *dst[MP_MAX_PLANES] = {NULL};
+ int dst_stride[MP_MAX_PLANES] = {0};
dst_stride[0] = vf->priv->stride;
- dst_stride[1] = dst_stride[2] = 0;
dst[0] = vf->priv->buffer;
- dst[1] = dst[2] = 0;
sws_scale_ordered(vf->priv->ctx, src, stride, y, h, dst, dst_stride);
}
vf_next_draw_slice(vf,src,stride,w,h,x,y);
diff --git a/libmpcodecs/vf_smartblur.c b/libmpcodecs/vf_smartblur.c
index 78ab70a6ce..a420bf109c 100644
--- a/libmpcodecs/vf_smartblur.c
+++ b/libmpcodecs/vf_smartblur.c
@@ -132,10 +132,10 @@ static void uninit(struct vf_instance* vf){
static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, FilterParam *fp){
int x, y;
FilterParam f= *fp;
- uint8_t *srcArray[3]= {src, NULL, NULL};
- uint8_t *dstArray[3]= {dst, NULL, NULL};
- int srcStrideArray[3]= {srcStride, 0, 0};
- int dstStrideArray[3]= {dstStride, 0, 0};
+ uint8_t *srcArray[MP_MAX_PLANES]= {src};
+ uint8_t *dstArray[MP_MAX_PLANES]= {dst};
+ int srcStrideArray[MP_MAX_PLANES]= {srcStride};
+ int dstStrideArray[MP_MAX_PLANES]= {dstStride};
sws_scale(f.filterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
diff --git a/libmpcodecs/vf_tile.c b/libmpcodecs/vf_tile.c
index c5b4b90e96..5559c3f41a 100644
--- a/libmpcodecs/vf_tile.c
+++ b/libmpcodecs/vf_tile.c
@@ -1,5 +1,5 @@
/*
- * vf_tile.c - filter to tile a serie of image in a single, bigger, image
+ * filter to tile a serie of image in a single, bigger, image
*
* The parameters are:
*
diff --git a/libmpcodecs/vf_yadif.c b/libmpcodecs/vf_yadif.c
index 828ca29dd7..82ffe21412 100644
--- a/libmpcodecs/vf_yadif.c
+++ b/libmpcodecs/vf_yadif.c
@@ -248,8 +248,8 @@ static void filter_line_mmx2(struct vf_priv_s *p, uint8_t *dst, uint8_t *prev, u
:[prev] "r"(prev),\
[cur] "r"(cur),\
[next] "r"(next),\
- [prefs]"r"((long)refs),\
- [mrefs]"r"((long)-refs),\
+ [prefs]"r"((x86_reg)refs),\
+ [mrefs]"r"((x86_reg)-refs),\
[pw1] "m"(pw_1),\
[pb1] "m"(pb_1),\
[mode] "g"(mode)\