summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-12-30 00:53:08 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-12-30 00:56:10 +0200
commitd46b86bc7c39082b26ec71aa16431f3275d836ff (patch)
tree035da87ed658f7d75c0eba5a5d4de5462a4c8ddd /libmpcodecs
parenta06b32b64e91082c11f747e2910f10a4afd3dfa9 (diff)
parent3e8f2815c19703f5cb6f75db2910234d499d9676 (diff)
downloadmpv-d46b86bc7c39082b26ec71aa16431f3275d836ff.tar.bz2
mpv-d46b86bc7c39082b26ec71aa16431f3275d836ff.tar.xz
Merge svn changes up to r30136
Ignore another broken correct-pts change in 30134.
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad_ffmpeg.c15
-rw-r--r--libmpcodecs/mp_image.h4
-rw-r--r--libmpcodecs/vd_ffmpeg.c10
-rw-r--r--libmpcodecs/vd_vfw.c1
-rw-r--r--libmpcodecs/vf.c6
-rw-r--r--libmpcodecs/vf_palette.c2
6 files changed, 28 insertions, 10 deletions
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index 12bd6aef6a..217ec25ff1 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -167,7 +167,17 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m
int len2=maxlen;
double pts;
int x=ds_get_packet_pts(sh_audio->ds,&start, &pts);
- if(x<=0) break; // error
+ if(x<=0) {
+ start = NULL;
+ x = 0;
+ ds_parse(sh_audio->ds, &start, &x, MP_NOPTS_VALUE, 0);
+ if (x <= 0)
+ break; // error
+ } else {
+ int in_size = x;
+ int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0);
+ sh_audio->ds->buffer_pos -= in_size - consumed;
+ }
av_init_packet(&pkt);
pkt.data = start;
pkt.size = x;
@@ -178,7 +188,8 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m
y=avcodec_decode_audio3(sh_audio->context,(int16_t*)buf,&len2,&pkt);
//printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
- if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
+ if(!sh_audio->needs_parsing && y<x)
+ sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
if(len2>0){
if (((AVCodecContext *)sh_audio->context)->channels >= 5) {
int samplesize = av_get_bits_per_sample_format(((AVCodecContext *)
diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h
index 77ce04102a..a62f403e27 100644
--- a/libmpcodecs/mp_image.h
+++ b/libmpcodecs/mp_image.h
@@ -38,7 +38,7 @@
#define MP_IMGFLAG_YUV 0x200
// set if it's swapped (BGR or YVU) plane/byteorder
#define MP_IMGFLAG_SWAPPED 0x400
-// using palette for RGB data
+// set if you want memory for palette allocated and managed by vf_get_image etc.
#define MP_IMGFLAG_RGB_PALETTE 0x800
#define MP_IMGFLAGMASK_COLORS 0xF00
@@ -223,6 +223,8 @@ static inline void free_mp_image(mp_image_t* mpi){
if(mpi->flags&MP_IMGFLAG_ALLOCATED){
/* becouse we allocate the whole image in once */
if(mpi->planes[0]) free(mpi->planes[0]);
+ if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
+ free(mpi->planes[1]);
}
free(mpi);
}
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 52e11623db..a89e0a4dbe 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -29,6 +29,10 @@ static const vd_info_t info = {
#include "libavcodec/avcodec.h"
+#if AVPALETTE_SIZE > 1024
+#error palette too large, adapt libmpcodecs/vf.c:vf_get_image
+#endif
+
#if CONFIG_XVMC
#include "libavcodec/xvmc.h"
#endif
@@ -533,6 +537,8 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, type== MP_IMGTYPE_IPB ? "using IPB\n" : "using IP\n");
}
+ if (ctx->best_csp == IMGFMT_RGB8 || ctx->best_csp == IMGFMT_BGR8)
+ flags |= MP_IMGFLAG_RGB_PALETTE;
mpi= mpcodecs_get_image(sh, type, flags, width, height);
if (!mpi) return -1;
@@ -570,10 +576,6 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){
}
#endif
- // Palette support: libavcodec copies palette to *data[1]
- if (mpi->bpp == 8)
- mpi->planes[1] = av_malloc(AVPALETTE_SIZE);
-
pic->data[0]= mpi->planes[0];
pic->data[1]= mpi->planes[1];
pic->data[2]= mpi->planes[2];
diff --git a/libmpcodecs/vd_vfw.c b/libmpcodecs/vd_vfw.c
index 197ead6bae..99b1cbeeb8 100644
--- a/libmpcodecs/vd_vfw.c
+++ b/libmpcodecs/vd_vfw.c
@@ -333,7 +333,6 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
if (priv->palette)
{
mpi->planes[1] = priv->palette;
- mpi->flags |= MP_IMGFLAG_RGB_PALETTE;
mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Found and copied palette\n");
}
else
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 5e7d1b4768..3c1c5e9538 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -329,8 +329,8 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
// keep buffer allocation status & color flags only:
// mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;
- // accept restrictions & draw_slice flags only:
- mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK);
+ // accept restrictions, draw_slice and palette flags only:
+ mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE);
if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
if(mpi->width!=w2 || mpi->height!=h){
// printf("vf.c: MPI parameters changed! %dx%d -> %dx%d \n", mpi->width,mpi->height,w2,h);
@@ -413,6 +413,8 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
} else {
//if(!mpi->stride[0])
mpi->stride[0]=mpi->width*mpi->bpp/8;
+ if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
+ mpi->planes[1] = memalign(64, 1024);
}
// printf("clearing img!\n");
vf_mpi_clear(mpi,0,0,mpi->width,mpi->height);
diff --git a/libmpcodecs/vf_palette.c b/libmpcodecs/vf_palette.c
index a867a4ce44..197a772dc9 100644
--- a/libmpcodecs/vf_palette.c
+++ b/libmpcodecs/vf_palette.c
@@ -76,6 +76,7 @@ static int config(struct vf_instance* vf,
static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
+ uint8_t *old_palette = mpi->planes[1];
// hope we'll get DR buffer:
dmpi=vf_get_image(vf->next,vf->priv->fmt,
@@ -152,6 +153,7 @@ static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
}
}
}
+ mpi->planes[1] = old_palette;
return vf_next_put_image(vf,dmpi, pts);
}