summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2012-01-18 04:18:41 +0100
committerwm4 <wm4@mplayer2.org>2012-01-18 04:18:41 +0100
commitf341b21a90d27977562645fb80f0cbbc2a17af7b (patch)
treeaf4b95b39fa865ddcaa5a448b7e04a0f5e220f57 /libmpcodecs
parent4e76c7514f847648cdc9740d6ef997d1653effa8 (diff)
parentc4093e7d872d2daa485029b8b36661411387ef37 (diff)
downloadmpv-f341b21a90d27977562645fb80f0cbbc2a17af7b.tar.bz2
mpv-f341b21a90d27977562645fb80f0cbbc2a17af7b.tar.xz
Merge remote-tracking branch 'origin/master' into my_master
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad_ffmpeg.c42
-rw-r--r--libmpcodecs/vd_ffmpeg.c27
-rw-r--r--libmpcodecs/vf.c4
-rw-r--r--libmpcodecs/vf_fspp.c14
4 files changed, 37 insertions, 50 deletions
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index 762c80282d..cd742cf8f8 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
+#include <assert.h>
#include <libavcodec/avcodec.h>
@@ -47,7 +48,7 @@ LIBAD_EXTERN(ffmpeg)
struct priv {
AVCodecContext *avctx;
- bool old_packet;
+ int previous_data_left;
};
static int preinit(sh_audio_t *sh)
@@ -230,7 +231,7 @@ static int control(sh_audio_t *sh, int cmd, void *arg, ...)
case ADCTRL_RESYNC_STREAM:
avcodec_flush_buffers(ctx->avctx);
ds_clear_parser(sh->ds);
- ctx->old_packet = false;
+ ctx->previous_data_left = 0;
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
@@ -247,23 +248,37 @@ static int decode_audio(sh_audio_t *sh_audio, unsigned char *buf, int minlen,
while (len < minlen) {
AVPacket pkt;
int len2 = maxlen;
- double pts;
- int x = ds_get_packet_pts(sh_audio->ds, &start, &pts);
- if (x <= 0) {
+ double pts = MP_NOPTS_VALUE;
+ int x;
+ bool packet_already_used = ctx->previous_data_left;
+ struct demux_packet *mpkt = ds_get_packet2(sh_audio->ds,
+ ctx->previous_data_left);
+ if (!mpkt) {
+ assert(!ctx->previous_data_left);
start = NULL;
x = 0;
- ds_parse(sh_audio->ds, &start, &x, MP_NOPTS_VALUE, 0);
+ ds_parse(sh_audio->ds, &start, &x, pts, 0);
if (x <= 0)
break; // error
} else {
- int in_size = x;
+ assert(mpkt->len >= ctx->previous_data_left);
+ if (!ctx->previous_data_left) {
+ ctx->previous_data_left = mpkt->len;
+ pts = mpkt->pts;
+ }
+ x = ctx->previous_data_left;
+ start = mpkt->buffer + mpkt->len - ctx->previous_data_left;
int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0);
- sh_audio->ds->buffer_pos -= in_size - consumed;
+ ctx->previous_data_left -= consumed;
}
av_init_packet(&pkt);
pkt.data = start;
pkt.size = x;
- if (pts != MP_NOPTS_VALUE && !ctx->old_packet) {
+ if (mpkt && mpkt->avpacket) {
+ pkt.side_data = mpkt->avpacket->side_data;
+ pkt.side_data_elems = mpkt->avpacket->side_data_elems;
+ }
+ if (pts != MP_NOPTS_VALUE && !packet_already_used) {
sh_audio->pts = pts;
sh_audio->pts_bytes = 0;
}
@@ -275,14 +290,11 @@ static int decode_audio(sh_audio_t *sh_audio, unsigned char *buf, int minlen,
mp_msg(MSGT_DECAUDIO, MSGL_V, "lavc_audio: error\n");
break;
}
- if (!sh_audio->parser && y < x) {
- sh_audio->ds->buffer_pos += y - x; // put back data (HACK!)
- ctx->old_packet = true;
- }
+ if (!sh_audio->parser)
+ ctx->previous_data_left += x - y;
if (len2 > 0) {
if (avctx->channels >= 5) {
- int samplesize = av_get_bits_per_sample_format(
- avctx->sample_fmt) / 8;
+ int samplesize = av_get_bytes_per_sample(avctx->sample_fmt);
reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
avctx->channels,
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index b7f189ec5f..0688aae7cc 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -147,10 +147,7 @@ static int init(sh_video_t *sh)
&& lavc_codec->id != CODEC_ID_H264
&& lavc_codec->id != CODEC_ID_INTERPLAY_VIDEO
&& lavc_codec->id != CODEC_ID_ROQ && lavc_codec->id != CODEC_ID_VP8
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 108, 0)
- && lavc_codec->id != CODEC_ID_LAGARITH
-#endif
- )
+ && lavc_codec->id != CODEC_ID_LAGARITH)
ctx->do_dr1 = 1;
ctx->b_age = ctx->ip_age[0] = ctx->ip_age[1] = 256 * 256 * 256 * 64;
ctx->ip_count = ctx->b_count = 0;
@@ -314,27 +311,12 @@ static int init(sh_video_t *sh)
memcpy(avctx->extradata, sh->bih + 1, avctx->extradata_size);
break;
}
- /* Pass palette to codec */
- if (sh->bih && (sh->bih->biBitCount <= 8)) {
- avctx->palctrl = calloc(1, sizeof(AVPaletteControl));
- avctx->palctrl->palette_changed = 1;
- if (sh->bih->biSize - sizeof(*sh->bih))
- /* Palette size in biSize */
- memcpy(avctx->palctrl->palette, sh->bih + 1,
- FFMIN(sh->bih->biSize - sizeof(*sh->bih), AVPALETTE_SIZE));
- else
- /* Palette size in biClrUsed */
- memcpy(avctx->palctrl->palette, sh->bih + 1,
- FFMIN(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
- }
if (sh->bih)
avctx->bits_per_coded_sample = sh->bih->biBitCount;
- if (lavc_param->threads > 1) {
- avctx->thread_count = lavc_param->threads;
- avcodec_thread_init(avctx, lavc_param->threads);
- }
+ avctx->thread_count = lavc_param->threads;
+
/* open it */
if (avcodec_open(avctx, lavc_codec) < 0) {
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");
@@ -365,7 +347,6 @@ static void uninit(sh_video_t *sh)
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n");
av_freep(&avctx->extradata);
- free(avctx->palctrl);
av_freep(&avctx->slice_offset);
}
@@ -663,12 +644,10 @@ static struct mp_image *decode(struct sh_video *sh, struct demux_packet *packet,
pkt.size = len;
// HACK: make PNGs decode normally instead of as CorePNG delta frames
pkt.flags = AV_PKT_FLAG_KEY;
-#if LIBAVCODEC_VERSION_MAJOR >= 53
if (packet && packet->avpacket) {
pkt.side_data = packet->avpacket->side_data;
pkt.side_data_elems = packet->avpacket->side_data_elems;
}
-#endif
// The avcodec opaque field stupidly supports only int64_t type
union pts { int64_t i; double d; };
avctx->reordered_opaque = (union pts){.d = *reordered_pts}.i;
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 34790e3d62..d973db6d3e 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -138,6 +138,7 @@ static const vf_info_t *const filter_list[] = {
&vf_info_lavc,
&vf_info_lavcdeint,
&vf_info_screenshot,
+ &vf_info_fspp,
&vf_info_uspp,
&vf_info_dvbscale,
@@ -182,13 +183,10 @@ static const vf_info_t *const filter_list[] = {
&vf_info_hue,
#ifdef CONFIG_FFMPEG_INTERNALS
&vf_info_spp,
- &vf_info_fspp,
&vf_info_mcdeint,
#endif
-#ifdef CONFIG_FFMPEG_EVAL_API
&vf_info_geq,
&vf_info_qp,
-#endif
&vf_info_yuvcsp,
&vf_info_kerndeint,
&vf_info_rgbtest,
diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c
index e7e3af8310..da54892fb1 100644
--- a/libmpcodecs/vf_fspp.c
+++ b/libmpcodecs/vf_fspp.c
@@ -38,6 +38,10 @@
#include <inttypes.h>
#include <math.h>
+#include <libavutil/intreadwrite.h>
+#include <libavutil/mem.h>
+#include <libavcodec/avcodec.h>
+
#include "config.h"
#include "mp_msg.h"
@@ -46,15 +50,9 @@
#include "mp_image.h"
#include "vf.h"
#include "libvo/fastmemcpy.h"
+#include "mangle.h"
-#include "libavutil/internal.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-
-#undef free
-#undef malloc
+typedef short DCTELEM;
//===========================================================================//
#define BLOCKSZ 12