summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2011-05-16 02:21:20 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2011-05-16 02:21:20 +0100
commit9cc1ad12d7a936227d82f49a829713ca025a6bd6 (patch)
tree3928d0df4cfc3bbfe33c40570ffd5e979f45ef8a
parent713cbfc4fd926c1596bfa4f093fae308316004c2 (diff)
downloadxine-lib-9cc1ad12d7a936227d82f49a829713ca025a6bd6.tar.gz
xine-lib-9cc1ad12d7a936227d82f49a829713ca025a6bd6.tar.bz2
Fix up "pp" post-proc plugin and A/V decoding for ffmpeg 0.7.
-rw-r--r--m4/decoders.m44
-rw-r--r--src/combined/ffmpeg/ff_audio_decoder.c30
-rw-r--r--src/combined/ffmpeg/ff_video_decoder.c87
-rw-r--r--src/input/input_cdda.c30
-rw-r--r--src/post/planar/pp.c56
5 files changed, 149 insertions, 58 deletions
diff --git a/m4/decoders.m4 b/m4/decoders.m4
index ea3bf98d2..38a4b59b3 100644
--- a/m4/decoders.m4
+++ b/m4/decoders.m4
@@ -94,7 +94,9 @@ AC_DEFUN([XINE_DECODER_PLUGINS], [
dnl style for headers. The new style would be preferred actually...
AC_CHECK_HEADERS([ffmpeg/avutil.h])
AC_CHECK_HEADERS([libavutil/avutil.h])
- if test "$ac_cv_header_ffmpeg_avutil_h" = "yes" && test "$ac_cv_header_libavutil_avutil_h" = "yes"; then
+ AC_CHECK_HEADERS([libavutil/sha1.h])
+ AC_CHECK_HEADERS([libavutil/sha.h])
+ if test "$ac_cv_header_ffmpeg_avutil_h$ac_cv_header_libavutil_avutil_h" = "yesyes" || test "$ac_cv_header_libavutil_sha1_h$ac_cv_header_libavutil_sha_h" = "yesyes"; then
AC_MSG_ERROR([old & new ffmpeg headers found - you need to clean up!])
fi
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c
index 534a97afb..0367d0e50 100644
--- a/src/combined/ffmpeg/ff_audio_decoder.c
+++ b/src/combined/ffmpeg/ff_audio_decoder.c
@@ -45,6 +45,12 @@
#define AUDIOBUFSIZE (64 * 1024)
+#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
+# define AVAUDIO 3
+#else
+# define AVAUDIO 2
+#endif
+
typedef struct {
audio_decoder_class_t decoder_class;
} ff_audio_class_t;
@@ -254,6 +260,9 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
buf->decoder_info[2]);
} else if (!(buf->decoder_flags & BUF_FLAG_SPECIAL)) {
+#if AVAUDIO > 2
+ AVPacket avpkt;
+#endif
if( !this->decoder_ok ) {
if ( ! this->context || ! this->codec ) {
@@ -285,11 +294,21 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
if (!this->output_open) {
if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+#if AVAUDIO > 2
+ av_init_packet (&avpkt);
+ avpkt.data = (uint8_t *)&this->buf[0];
+ avpkt.size = this->size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ avcodec_decode_audio3 (this->context,
+ (int16_t *)this->decode_buffer,
+ &decode_buffer_size, &avpkt);
+#else
avcodec_decode_audio2 (this->context,
(int16_t *)this->decode_buffer,
&decode_buffer_size,
&this->buf[0],
this->size);
+#endif
this->audio_bits = this->context->bits_per_sample;
this->audio_sample_rate = this->context->sample_rate;
this->audio_channels = this->context->channels;
@@ -310,12 +329,21 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
offset = 0;
while (this->size>0) {
decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+#if AVAUDIO > 2
+ av_init_packet (&avpkt);
+ avpkt.data = (uint8_t *)&this->buf[offset];
+ avpkt.size = this->size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ bytes_consumed = avcodec_decode_audio3 (this->context,
+ (int16_t *)this->decode_buffer,
+ &decode_buffer_size, &avpkt);
+#else
bytes_consumed = avcodec_decode_audio2 (this->context,
(int16_t *)this->decode_buffer,
&decode_buffer_size,
&this->buf[offset],
this->size);
-
+#endif
if (bytes_consumed<0) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: error decompressing audio frame\n");
diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c
index b0f8a2d39..405871b04 100644
--- a/src/combined/ffmpeg/ff_video_decoder.c
+++ b/src/combined/ffmpeg/ff_video_decoder.c
@@ -57,6 +57,14 @@
#define ENABLE_DIRECT_RENDERING
+#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
+# define AVVIDEO 2
+#else
+# define AVVIDEO 1
+# define pp_context pp_context_t
+# define pp_mode pp_mode_t
+#endif
+
typedef struct ff_video_decoder_s ff_video_decoder_t;
typedef struct ff_video_class_s {
@@ -107,8 +115,8 @@ struct ff_video_decoder_s {
int pp_quality;
int pp_flags;
- pp_context_t *pp_context;
- pp_mode_t *pp_mode;
+ pp_context *our_context;
+ pp_mode *our_mode;
/* mpeg-es parsing */
mpeg_parser_t *mpeg_parser;
@@ -433,23 +441,23 @@ static void pp_change_quality (ff_video_decoder_t *this) {
this->pp_quality = this->class->pp_quality;
if(this->pp_available && this->pp_quality) {
- if(!this->pp_context && this->context)
- this->pp_context = pp_get_context(this->context->width, this->context->height,
+ if(!this->our_context && this->context)
+ this->our_context = pp_get_context(this->context->width, this->context->height,
this->pp_flags);
- if(this->pp_mode)
- pp_free_mode(this->pp_mode);
+ if(this->our_mode)
+ pp_free_mode(this->our_mode);
- this->pp_mode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a",
+ this->our_mode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a",
this->pp_quality);
} else {
- if(this->pp_mode) {
- pp_free_mode(this->pp_mode);
- this->pp_mode = NULL;
+ if(this->our_mode) {
+ pp_free_mode(this->our_mode);
+ this->our_mode = NULL;
}
- if(this->pp_context) {
- pp_free_context(this->pp_context);
- this->pp_context = NULL;
+ if(this->our_context) {
+ pp_free_context(this->our_context);
+ this->our_context = NULL;
}
}
}
@@ -1043,12 +1051,26 @@ static void ff_handle_mpeg12_buffer (ff_video_decoder_t *this, buf_element_t *bu
}
/* skip decoding b frames if too late */
+#if AVVIDEO > 1
+ /* FIXME: alternative for avcodec_decode_video2? */
+#else
this->context->hurry_up = (this->skipframes > 0);
+#endif
lprintf("avcodec_decode_video: size=%d\n", this->mpeg_parser->buffer_size);
+#if AVVIDEO > 1
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+ avpkt.data = (uint8_t *)this->mpeg_parser->chunk_buffer;
+ avpkt.size = this->mpeg_parser->buffer_size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ len = avcodec_decode_video2 (this->context, this->av_frame,
+ &got_picture, &avpkt);
+#else
len = avcodec_decode_video (this->context, this->av_frame,
&got_picture, this->mpeg_parser->chunk_buffer,
this->mpeg_parser->buffer_size);
+#endif
lprintf("avcodec_decode_video: decoded_size=%d, got_picture=%d\n",
len, got_picture);
len = current - buf->content - offset;
@@ -1100,7 +1122,14 @@ static void ff_handle_mpeg12_buffer (ff_video_decoder_t *this, buf_element_t *bu
} else {
- if (this->context->hurry_up) {
+ if (
+#if AVVIDEO > 1
+ /* FIXME: alternative for avcodec_decode_video2? */
+ this->skipframes
+#else
+ this->context->hurry_up
+#endif
+ ) {
/* skipped frame, output a bad frame */
img = this->stream->video_out->get_frame (this->stream->video_out,
this->bih.biWidth,
@@ -1288,13 +1317,25 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) {
got_picture = 0;
} else {
/* skip decoding b frames if too late */
+#if AVVIDEO > 1
+ /* FIXME: alternative for avcodec_decode_video2? */
+#else
this->context->hurry_up = (this->skipframes > 0);
-
+#endif
lprintf("buffer size: %d\n", this->size);
+#if AVVIDEO > 1
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+ avpkt.data = (uint8_t *)&chunk_buf[offset];
+ avpkt.size = this->size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ len = avcodec_decode_video2 (this->context, this->av_frame,
+ &got_picture, &avpkt);
+#else
len = avcodec_decode_video (this->context, this->av_frame,
&got_picture, &chunk_buf[offset],
this->size);
-
+#endif
/* reset consumed pts value */
this->context->reordered_opaque = ff_tag_pts(this, 0);
@@ -1408,7 +1449,7 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) {
img->base, img->pitches,
img->width, img->height,
this->av_frame->qscale_table, this->av_frame->qstride,
- this->pp_mode, this->pp_context,
+ this->our_mode, this->our_context,
this->av_frame->pict_type);
} else if (!this->av_frame->opaque) {
@@ -1640,11 +1681,11 @@ static void ff_dispose (video_decoder_t *this_gen) {
free(this->buf);
this->buf = NULL;
- if(this->pp_context)
- pp_free_context(this->pp_context);
+ if(this->our_context)
+ pp_free_context(this->our_context);
- if(this->pp_mode)
- pp_free_mode(this->pp_mode);
+ if(this->our_mode)
+ pp_free_mode(this->our_mode);
mpeg_parser_dispose(this->mpeg_parser);
@@ -1685,8 +1726,8 @@ static video_decoder_t *ff_video_open_plugin (video_decoder_class_t *class_gen,
this->aspect_ratio = 0;
this->pp_quality = 0;
- this->pp_context = NULL;
- this->pp_mode = NULL;
+ this->our_context = NULL;
+ this->our_mode = NULL;
this->mpeg_parser = NULL;
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index 05250f51c..57764c770 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -64,7 +64,11 @@
# include <sha1.h>
#else
# include <libavutil/base64.h>
-# include <libavutil/sha1.h>
+# ifdef HAVE_LIBAVUTIL_SHA1_H
+# include <libavutil/sha1.h>
+# else
+# include <libavutil/sha.h>
+# endif
#endif
#define LOG_MODULE "input_cdda"
@@ -100,6 +104,14 @@
#define CD_LEADOUT_TRACK 0xAA
#define CD_BLOCK_OFFSET 150
+#ifdef HAVE_LIBAVUTIL_SHA1_H
+/* old libavutil/sha1.h was found... */
+#define AVSHA AVSHA1
+# define av_sha_init(c,b) av_sha1_init(c)
+# define av_sha_update av_sha1_update
+# define av_sha_final av_sha1_final
+#endif
+
typedef struct _cdrom_toc_entry {
int track_mode;
int first_frame;
@@ -1837,7 +1849,7 @@ static uint32_t _cdda_calc_cddb_id(cdda_input_plugin_t *this) {
*/
static void _cdda_cdindex(cdda_input_plugin_t *this, cdrom_toc *toc) {
char temp[10];
- struct AVSHA1 *sha_ctx = malloc(av_sha1_size);
+ struct AVSHA *sha_ctx = malloc(av_sha_size);
unsigned char digest[20];
/* We're going to encode 20 bytes in base64, which will become
* 6 * 32 / 8 = 24 bytes.
@@ -1847,27 +1859,27 @@ static void _cdda_cdindex(cdda_input_plugin_t *this, cdrom_toc *toc) {
char base64[39];
int i;
- av_sha1_init(sha_ctx);
+ av_sha_init(sha_ctx, 160);
sprintf(temp, "%02X", toc->first_track);
- av_sha1_update(sha_ctx, (unsigned char*) temp, strlen(temp));
+ av_sha_update(sha_ctx, (unsigned char*) temp, strlen(temp));
sprintf(temp, "%02X", toc->last_track - toc->ignore_last_track);
- av_sha1_update(sha_ctx, (unsigned char*) temp, strlen(temp));
+ av_sha_update(sha_ctx, (unsigned char*) temp, strlen(temp));
sprintf (temp, "%08X", toc->leadout_track.first_frame);// + 150);
- av_sha1_update(sha_ctx, (unsigned char*) temp, strlen(temp));
+ av_sha_update(sha_ctx, (unsigned char*) temp, strlen(temp));
for (i = toc->first_track; i <= toc->last_track - toc->ignore_last_track; i++) {
sprintf(temp, "%08X", toc->toc_entries[i - 1].first_frame);
- av_sha1_update(sha_ctx, (unsigned char*) temp, strlen(temp));
+ av_sha_update(sha_ctx, (unsigned char*) temp, strlen(temp));
}
for (i = toc->last_track - toc->ignore_last_track + 1; i < 100; i++) {
- av_sha1_update(sha_ctx, (unsigned char*) temp, strlen(temp));
+ av_sha_update(sha_ctx, (unsigned char*) temp, strlen(temp));
}
- av_sha1_final(sha_ctx, digest);
+ av_sha_final(sha_ctx, digest);
free(sha_ctx);
av_base64_encode(base64, 39, digest, 20);
diff --git a/src/post/planar/pp.c b/src/post/planar/pp.c
index b985b47aa..767d52f96 100644
--- a/src/post/planar/pp.c
+++ b/src/post/planar/pp.c
@@ -36,6 +36,12 @@
#endif
#include <pthread.h>
+#if LIBPOSTPROC_VERSION_MAJOR < 52
+# define pp_context pp_context_t
+# define pp_mode pp_mode_t
+# define PP_PARAMETERS_T
+#endif
+
#define PP_STRING_SIZE 256 /* size of pp mode string (including all options) */
/* plugin class initialization function */
@@ -77,14 +83,15 @@ struct post_plugin_pp_s {
/* libpostproc specific stuff */
int pp_flags;
- pp_context_t *pp_context;
- pp_mode_t *pp_mode;
+ pp_context *our_context;
+ pp_mode *our_mode;
pthread_mutex_t lock;
};
static int set_parameters (xine_post_t *this_gen, void *param_gen) {
+#ifdef PP_PARAMETERS_T
post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
pp_parameters_t *param = (pp_parameters_t *)param_gen;
@@ -93,17 +100,18 @@ static int set_parameters (xine_post_t *this_gen, void *param_gen) {
memcpy( &this->params, param, sizeof(pp_parameters_t) );
pthread_mutex_unlock (&this->lock);
-
+#endif
return 1;
}
static int get_parameters (xine_post_t *this_gen, void *param_gen) {
+#ifdef PP_PARAMETERS_T
post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
pp_parameters_t *param = (pp_parameters_t *)param_gen;
memcpy( param, &this->params, sizeof(pp_parameters_t) );
-
+#endif
return 1;
}
@@ -198,8 +206,8 @@ static post_plugin_t *pp_open_plugin(post_class_t *class_gen, int inputs,
if(cpu_caps & MM_ACCEL_X86_3DNOW)
this->pp_flags |= PP_CPU_CAPS_3DNOW;
- this->pp_mode = NULL;
- this->pp_context = NULL;
+ this->our_mode = NULL;
+ this->our_context = NULL;
pthread_mutex_init (&this->lock, NULL);
@@ -228,13 +236,13 @@ static void pp_dispose(post_plugin_t *this_gen)
post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
if (_x_post_dispose(this_gen)) {
- if(this->pp_mode) {
- pp_free_mode(this->pp_mode);
- this->pp_mode = NULL;
+ if(this->our_mode) {
+ pp_free_mode(this->our_mode);
+ this->our_mode = NULL;
}
- if(this->pp_context) {
- pp_free_context(this->pp_context);
- this->pp_context = NULL;
+ if(this->our_context) {
+ pp_free_context(this->our_context);
+ this->our_context = NULL;
}
free(this);
}
@@ -284,7 +292,7 @@ static int pp_draw(vo_frame_t *frame, xine_stream_t *stream)
pthread_mutex_lock (&this->lock);
- if( !this->pp_context ||
+ if( !this->our_context ||
this->frame_width != yv12_frame->width ||
this->frame_height != yv12_frame->height ) {
@@ -292,32 +300,32 @@ static int pp_draw(vo_frame_t *frame, xine_stream_t *stream)
this->frame_height = yv12_frame->height;
pp_flags = this->pp_flags;
- if(this->pp_context)
- pp_free_context(this->pp_context);
+ if(this->our_context)
+ pp_free_context(this->our_context);
- this->pp_context = pp_get_context(frame->width, frame->height, pp_flags);
+ this->our_context = pp_get_context(frame->width, frame->height, pp_flags);
- if(this->pp_mode) {
- pp_free_mode(this->pp_mode);
- this->pp_mode = NULL;
+ if(this->our_mode) {
+ pp_free_mode(this->our_mode);
+ this->our_mode = NULL;
}
}
- if(!this->pp_mode)
- this->pp_mode = pp_get_mode_by_name_and_quality(this->params.mode,
+ if(!this->our_mode)
+ this->our_mode = pp_get_mode_by_name_and_quality(this->params.mode,
this->params.quality);
- if(this->pp_mode)
+ if(this->our_mode)
pp_postprocess(yv12_frame->base, yv12_frame->pitches,
out_frame->base, out_frame->pitches,
(frame->width+7)&(~7), frame->height,
NULL, 0,
- this->pp_mode, this->pp_context,
+ this->our_mode, this->our_context,
0 /*this->av_frame->pict_type*/);
pthread_mutex_unlock (&this->lock);
- if(this->pp_mode) {
+ if(this->our_mode) {
skip = out_frame->draw(out_frame, stream);
_x_post_frame_copy_up(frame, out_frame);
} else {