[prev in list] [next in list] [prev in thread] [next in thread]
List: xine-cvslog
Subject: [xine-cvs] =?utf-8?q?HG=3A_xine-lib-1=2E2=3A_ffmpeg=5Fvideo=5Fdec?= =?utf-8?q?oder=3A_re-enabled_pal
From: Torsten_Jager <t.jager () gmx ! de>
Date: 2013-02-21 20:30:53
Message-ID: 34f4d398ff18666a073f.1361478108 () hg ! debian ! org
[Download RAW message or body]
# HG changeset patch
# User Torsten Jager <t.jager@gmx.de>
# Date 1361478108 -7200
# Node ID 34f4d398ff18666a073fbbc71cd1dc8bcb8491eb
# Branch default
# Parent 31d88870e54d3fbd19174cfc479254dc593bc5d4
ffmpeg_video_decoder: re-enabled palette video decoding
diff --git a/src/combined/ffmpeg/ff_video_decoder.c \
b/src/combined/ffmpeg/ff_video_decoder.c
--- a/src/combined/ffmpeg/ff_video_decoder.c
+++ b/src/combined/ffmpeg/ff_video_decoder.c
@@ -134,8 +134,11 @@
xine_list_t *dr1_frames;
-#ifdef AVPaletteControl
+#if AVPALETTE == 1
AVPaletteControl palette_control;
+#elif AVPALETTE == 2
+ uint32_t palette[256];
+ int palette_changed;
#endif
int color_matrix, full2mpeg;
@@ -1199,18 +1202,14 @@
buf->decoder_info[2]);
}
-#ifdef AVPaletteControl
else if (buf->decoder_info[1] == BUF_SPECIAL_PALETTE) {
unsigned int i;
+ palette_entry_t *demuxer_palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- palette_entry_t *demuxer_palette;
- AVPaletteControl *decoder_palette;
+#if AVPALETTE == 1
+ AVPaletteControl *decoder_palette = &this->palette_control;
- lprintf("BUF_SPECIAL_PALETTE\n");
- this->context->palctrl = &this->palette_control;
- decoder_palette = (AVPaletteControl *)this->context->palctrl;
- demuxer_palette = (palette_entry_t *)buf->decoder_info_ptr[2];
-
+ lprintf ("BUF_SPECIAL_PALETTE\n");
for (i = 0; i < buf->decoder_info[2]; i++) {
decoder_palette->palette[i] =
(demuxer_palette[i].r << 16) |
@@ -1218,9 +1217,19 @@
(demuxer_palette[i].b << 0);
}
decoder_palette->palette_changed = 1;
+ this->context->palctrl = decoder_palette;
+#elif AVPALETTE == 2
+ lprintf ("BUF_SPECIAL_PALETTE\n");
+ for (i = 0; i < buf->decoder_info[2]; i++) {
+ this->palette[i] =
+ (demuxer_palette[i].r << 16) |
+ (demuxer_palette[i].g << 8) |
+ (demuxer_palette[i].b << 0);
+ }
+ this->palette_changed = 1;
+#endif
}
-#endif
else if (buf->decoder_info[1] == BUF_SPECIAL_RV_CHUNK_TABLE) {
int i;
@@ -1576,6 +1585,13 @@
avpkt.data = (uint8_t *)&chunk_buf[offset];
avpkt.size = this->size;
avpkt.flags = AV_PKT_FLAG_KEY;
+# if AVPALETTE == 2
+ if (this->palette_changed) {
+ uint8_t *sd = av_packet_new_side_data (&avpkt, AV_PKT_DATA_PALETTE, 256 * 4);
+ if (sd)
+ memcpy (sd, this->palette, 256 * 4);
+ }
+# endif
# if ENABLE_VAAPI
if(this->accel) {
len = this->accel->avcodec_decode_video2 ( this->accel_img, this->context, \
this->av_frame, @@ -1586,6 +1602,18 @@
len = avcodec_decode_video2 (this->context, this->av_frame,
&got_picture, &avpkt);
}
+# if AVPALETTE == 2
+ if (this->palette_changed) {
+ /* TJ. Oh dear and sigh.
+ AVPacket side data handling is broken even in ffmpeg 1.1.1 - see \
avcodec/avpacket.c + The suggested av_free_packet () would leave a memory leak \
here, and + ff_packet_free_side_data () is private. */
+ avpkt.data = NULL;
+ avpkt.size = 0;
+ av_destruct_packet (&avpkt);
+ this->palette_changed = 0;
+ }
+# endif
#else
# if ENABLE_VAAPI
if(this->accel) {
@@ -2026,7 +2054,7 @@
this->av_frame = avcodec_alloc_frame();
this->context = avcodec_alloc_context();
this->context->opaque = this;
-#ifdef AVPaletteControl
+#if AVPALETTE == 1
this->context->palctrl = NULL;
#endif
--git a/src/combined/ffmpeg/ffmpeg_compat.h b/src/combined/ffmpeg/ffmpeg_compat.h
--- a/src/combined/ffmpeg/ffmpeg_compat.h
+++ b/src/combined/ffmpeg/ffmpeg_compat.h
@@ -105,4 +105,13 @@
# define AVFRAMEAGE 1
#endif
+#if LIBAVCODEC_VERSION_MAJOR < 53
+/* release 0.7.x (libavcodec 52) has deprecated AVCodecContext.palctrl but for \
backwards compatibility no + working alternative. */
+# define AVPALETTE 1
+#else
+/* pass palette as AVPacket side data */
+# define AVPALETTE 2
+#endif
+
#endif /* XINE_AVCODEC_COMPAT_H */
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Xine-cvslog mailing list
Xine-cvslog@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xine-cvslog
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic