rendered paste bodyIndex: DVDRingBuffer.cpp===================================================================--- DVDRingBuffer.cpp (revision 20788)+++ DVDRingBuffer.cpp (working copy)@@ -776,8 +776,8 @@ m_menuBtnLock.lock(); if ((m_menuBuflength > 4) && m_buttonExists &&- (m_dvdMenuButton.rects[0].h >= m_hl_button.height()) &&- (m_dvdMenuButton.rects[0].w >= m_hl_button.width()))+ (m_dvdMenuButton.rects[0]->h >= m_hl_button.height()) &&+ (m_dvdMenuButton.rects[0]->w >= m_hl_button.width())) { return &(m_dvdMenuButton); }@@ -801,8 +801,8 @@ int x1, y1; int x = 0; int y = 0;- x1 = m_dvdMenuButton.rects[0].x;- y1 = m_dvdMenuButton.rects[0].y;+ x1 = m_dvdMenuButton.rects[0]->x;+ y1 = m_dvdMenuButton.rects[0]->y; if (m_hl_button.x() > x1) x = m_hl_button.x() - x1; if (m_hl_button.y() > y1)@@ -926,8 +926,9 @@ { for (i = 0; i < sub->num_rects; i++) {- av_free(sub->rects[i].bitmap);- av_free(sub->rects[i].rgba_palette);+ av_free(sub->rects[i]->pict.data[0]);+ av_free(sub->rects[i]->pict.data[1]);+ av_freep(&sub->rects[i]); } av_freep(&sub->rects); sub->num_rects = 0;@@ -935,26 +936,30 @@ bitmap = (uint8_t*) av_malloc(w * h); sub->num_rects = (NumMenuButtons() > 0) ? 2 : 1;- sub->rects = (AVSubtitleRect *)- av_mallocz(sizeof(AVSubtitleRect) * sub->num_rects);- sub->rects[0].rgba_palette = (uint32_t*)av_malloc(4 *4);+ sub->rects = (AVSubtitleRect **)+ av_mallocz(sizeof(AVSubtitleRect*) * sub->num_rects);+ for (i = 0; i < sub->num_rects; i++)+ {+ sub->rects[i] = (AVSubtitleRect *) av_mallocz(sizeof(AVSubtitleRect));+ }+ sub->rects[0]->pict.data[1] = (uint8_t*)av_mallocz(4 * 4); decode_rle(bitmap, w * 2, w, (h + 1) / 2, spu_pkt, offset1 * 2, buf_size); decode_rle(bitmap + w, w * 2, w, h / 2, spu_pkt, offset2 * 2, buf_size);- guess_palette(sub->rects[0].rgba_palette, palette, alpha);- sub->rects[0].bitmap = bitmap;- sub->rects[0].x = x1;- sub->rects[0].y = y1;- sub->rects[0].w = w;- sub->rects[0].h = h;- sub->rects[0].nb_colors = 4;- sub->rects[0].linesize = w;+ guess_palette((uint32_t *)(sub->rects[0]->pict.data[1]), palette, alpha);+ sub->rects[0]->pict.data[0] = bitmap;+ sub->rects[0]->x = x1;+ sub->rects[0]->y = y1;+ sub->rects[0]->w = w;+ sub->rects[0]->h = h;+ sub->rects[0]->nb_colors = 4;+ sub->rects[0]->pict.linesize[0] = w; if (NumMenuButtons() > 0) {- sub->rects[1].rgba_palette = (uint32_t*)av_malloc(4 *4);- guess_palette(sub->rects[1].rgba_palette,- m_button_color, m_button_alpha);+ sub->rects[1]->pict.data[1] = (uint8_t*)av_malloc(4 *4);+ guess_palette((uint32_t *)(sub->rects[1]->pict.data[1]),+ m_button_color, m_button_alpha); } else find_smallest_bounding_rectangle(sub);@@ -1027,9 +1032,10 @@ { for (uint i = 0; i < m_dvdMenuButton.num_rects; i++) {- AVSubtitleRect* rect = &(m_dvdMenuButton.rects[i]);- av_free(rect->rgba_palette);- av_free(rect->bitmap);+ AVSubtitleRect* rect = m_dvdMenuButton.rects[i];+ av_free(rect->pict.data[0]);+ av_free(rect->pict.data[1]);+ av_free(rect); } av_free(m_dvdMenuButton.rects); m_dvdMenuButton.rects = NULL;@@ -1291,14 +1297,13 @@ /** \brief converts palette values from YUV to RGB */-void DVDRingBufferPriv::guess_palette(uint32_t *rgba_palette,uint8_t *palette,- uint8_t *alpha)+void DVDRingBufferPriv::guess_palette(uint32_t *rgba_palette, uint8_t *palette,+ uint8_t *alpha) { int i,r,g,b,y,cr,cb; uint32_t yuv; - for (i = 0; i < 4; i++)- rgba_palette[i] = 0;+ memset(rgba_palette, 0, 4); for (i=0 ; i < 4 ; i++) {@@ -1315,7 +1320,7 @@ if (r > 0xff) r = 0xff; if (g > 0xff) g = 0xff; if (b > 0xff) b = 0xff;- rgba_palette[i] = ((alpha[i] * 17) << 24) | (r << 16 )| (g << 8) | b;+ rgba_palette[i] = ((alpha[i] * 17) << 24) | (r << 16) | (g << 8) | b; } } @@ -1403,53 +1408,53 @@ uint8_t *bitmap; if (s->num_rects == 0 || s->rects == NULL ||- s->rects[0].w <= 0 || s->rects[0].h <= 0)+ s->rects[0]->w <= 0 || s->rects[0]->h <= 0) { return 0; } memset(transp_color, 0, 256);- for (i = 0; i < s->rects[0].nb_colors; i++)+ for (i = 0; i < s->rects[0]->nb_colors * 4; i+=4) {- if ((s->rects[0].rgba_palette[i] >> 24) == 0)+ if ((s->rects[0]->pict.data[1][i] >> 24) == 0) transp_color[i] = 1; } y1 = 0;- while (y1 < s->rects[0].h &&- is_transp(s->rects[0].bitmap + y1 * s->rects[0].linesize,- 1, s->rects[0].w, transp_color))+ while (y1 < s->rects[0]->h &&+ is_transp(s->rects[0]->pict.data[0] + y1 * s->rects[0]->pict.linesize[0],+ 1, s->rects[0]->w, transp_color)) { y1++; } - if (y1 == s->rects[0].h)+ if (y1 == s->rects[0]->h) {- av_freep(&s->rects[0].bitmap);- s->rects[0].w = s->rects[0].h = 0;+ av_freep(&s->rects[0]->pict.data[0]);+ s->rects[0]->w = s->rects[0]->h = 0; return 0; } - y2 = s->rects[0].h - 1;+ y2 = s->rects[0]->h - 1; while (y2 > 0 &&- is_transp(s->rects[0].bitmap + y2 * s->rects[0].linesize, 1,- s->rects[0].w, transp_color))+ is_transp(s->rects[0]->pict.data[0] + y2 * s->rects[0]->pict.linesize[0], 1,+ s->rects[0]->w, transp_color)) { y2--; } x1 = 0;- while (x1 < (s->rects[0].w - 1) &&- is_transp(s->rects[0].bitmap + x1, s->rects[0].linesize,- s->rects[0].h, transp_color))+ while (x1 < (s->rects[0]->w - 1) &&+ is_transp(s->rects[0]->pict.data[0] + x1, s->rects[0]->pict.linesize[0],+ s->rects[0]->h, transp_color)) { x1++; } - x2 = s->rects[0].w - 1;+ x2 = s->rects[0]->w - 1; while (x2 > 0 &&- is_transp(s->rects[0].bitmap + x2, s->rects[0].linesize,- s->rects[0].h, transp_color))+ is_transp(s->rects[0]->pict.data[0] + x2, s->rects[0]->pict.linesize[0],+ s->rects[0]->h, transp_color)) { x2--; }@@ -1462,16 +1467,16 @@ for(y = 0; y < h; y++) {- memcpy(bitmap + w * y, s->rects[0].bitmap + x1 +- (y1 + y) * s->rects[0].linesize, w);+ memcpy(bitmap + w * y, s->rects[0]->pict.data[0] + x1 ++ (y1 + y) * s->rects[0]->pict.linesize[0], w); } - av_freep(&s->rects[0].bitmap);- s->rects[0].bitmap = bitmap;- s->rects[0].linesize = w;- s->rects[0].w = w;- s->rects[0].h = h;- s->rects[0].x += x1;- s->rects[0].y += y1;+ av_freep(&s->rects[0]->pict.data[0]);+ s->rects[0]->pict.data[0] = bitmap;+ s->rects[0]->pict.linesize[0] = w;+ s->rects[0]->w = w;+ s->rects[0]->h = h;+ s->rects[0]->x += x1;+ s->rects[0]->y += y1; return 1; }Index: NuppelVideoPlayer.cpp===================================================================--- NuppelVideoPlayer.cpp (revision 20788)+++ NuppelVideoPlayer.cpp (working copy)@@ -1,5 +1,7 @@ // -*- Mode: c++ -*- +#undef HAVE_AV_CONFIG_H+ // Std C headers #include <cstdio> #include <cstdlib>@@ -58,6 +60,7 @@ extern "C" { #include "vbitext/vbi.h" #include "vsync.h"+#include "libavcodec/avcodec.h" #include "libswscale/swscale.h" } @@ -74,16 +77,16 @@ #include "videoout_dx.h" #undef GetFreeSpace #undef GetFileSize-#ifdef CONFIG_CYGWIN+#if CONFIG_CYGWIN #undef DialogBox #endif #endif -#ifndef HAVE_ROUND+#if ! HAVE_ROUND #define round(x) ((int) ((x) + 0.5)) #endif -#ifdef CONFIG_DARWIN+#if CONFIG_DARWIN extern "C" { int isnan(double); }@@ -1643,11 +1646,7 @@ if (yuv_scaler) {-#if ENABLE_SWSCALE sws_freeContext(yuv_scaler);-#else- img_resample_close(yuv_scaler);-#endif yuv_scaler = NULL; } @@ -2814,18 +2813,12 @@ yuv_scaler_in_size = vsize; yuv_scaler_out_size = yuv_desired_size; -#if ENABLE_SWSCALE yuv_scaler = sws_getCachedContext(yuv_scaler, yuv_scaler_in_size.width(), yuv_scaler_in_size.height(), PIX_FMT_YUV420P, yuv_scaler_out_size.width(), yuv_scaler_out_size.height(), PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);-#else- yuv_scaler = img_resample_init(- yuv_scaler_out_size.width(), yuv_scaler_out_size.height(),- yuv_scaler_in_size.width(), yuv_scaler_in_size.height());-#endif } AVPicture img_out, img_in;@@ -2836,13 +2829,9 @@ yuv_scaler_in_size.width(), yuv_scaler_in_size.height()); -#if ENABLE_SWSCALE sws_scale(yuv_scaler, img_in.data, img_in.linesize, 0, yuv_scaler_in_size.height(), img_out.data, img_out.linesize);-#else- img_resample(yuv_scaler, &img_out, &img_in);-#endif yuv_need_copy = false; yuv_wait.wakeAll(); }@@ -3552,7 +3541,7 @@ { // Request that the video output thread run with realtime priority. // If mythyv/mythfrontend was installed SUID root, this will work.-#ifndef CONFIG_DARWIN+#if !CONFIG_DARWIN gContext->addPrivRequest(MythPrivRequest::MythRealtime, &output_video); #endif @@ -5980,15 +5969,11 @@ bufflen = video_dim.width() * video_dim.height() * 4; outputbuf = new unsigned char[bufflen]; - avpicture_fill(&retbuf, outputbuf, PIX_FMT_RGBA32,+ avpicture_fill(&retbuf, outputbuf, PIX_FMT_RGB32, video_dim.width(), video_dim.height()); -#if ENABLE_SWSCALE myth_sws_img_convert(-#else- img_convert(-#endif- &retbuf, PIX_FMT_RGBA32, &orig, PIX_FMT_YUV420P,+ &retbuf, PIX_FMT_RGB32, &orig, PIX_FMT_YUV420P, video_dim.width(), video_dim.height()); vw = video_dim.width();@@ -6425,7 +6410,7 @@ if (player_ctx->buffer->isDVD()) { if (!player_ctx->buffer->DVD()->IsInMenu())-#ifndef CONFIG_CYGWIN+#if !CONFIG_CYGWIN secsplayed = player_ctx->buffer->DVD()->GetCurrentTime(); #else // DVD playing non-functional under windows for now@@ -7157,7 +7142,7 @@ // draw the subtitle bitmap(s) to the OSD for (std::size_t i = 0; i < subtitlePage.num_rects; ++i) {- AVSubtitleRect* rect = &subtitlePage.rects[i];+ AVSubtitleRect* rect = subtitlePage.rects[i]; bool displaysub = true; if (nonDisplayedAVSubtitles.size() > 0 &&@@ -7167,7 +7152,7 @@ displaysub = false; } - if (displaysub)+ if (displaysub && rect->pict.data[0]) { // AVSubtitleRect's image data's not guaranteed to be 4 byte // aligned.@@ -7176,8 +7161,8 @@ { for (int x = 0; x < rect->w; ++x) {- const uint8_t color = rect->bitmap[y*rect->linesize + x];- const uint32_t pixel = rect->rgba_palette[color];+ const uint8_t color = rect->pict.data[0][y*rect->pict.linesize[0] + x];+ const uint32_t pixel = (((uint32_t *)(rect->pict.data[1]))[color]); qImage.setPixel(x, y, pixel); } }@@ -7222,8 +7207,9 @@ osdHasSubtitles = true; } - av_free(rect->rgba_palette);- av_free(rect->bitmap);+ av_free(rect->pict.data[0]);+ av_free(rect->pict.data[1]);+ av_free(rect); } if (subtitlePage.num_rects > 0)@@ -7319,9 +7305,10 @@ for (std::size_t i = 0; i < subtitlePage.num_rects; ++i) {- AVSubtitleRect* rect = &subtitlePage.rects[i];- av_free(rect->rgba_palette);- av_free(rect->bitmap);+ AVSubtitleRect* rect = subtitlePage.rects[i];+ av_free(rect->pict.data[0]);+ av_free(rect->pict.data[1]);+ av_free(rect); } if (subtitlePage.num_rects > 0)@@ -7345,9 +7332,9 @@ // the dynamic buffers here for (std::size_t i = 0; i < subtitle.num_rects; ++i) {- AVSubtitleRect* rect = &subtitle.rects[i];- av_free(rect->rgba_palette);- av_free(rect->bitmap);+ AVSubtitleRect* rect = subtitle.rects[i];+ av_free(rect->pict.data[0]);+ av_free(rect->pict.data[1]); } if (subtitle.num_rects > 0)@@ -7379,6 +7366,7 @@ */ void NuppelVideoPlayer::AddAVSubtitle(const AVSubtitle &subtitle) {+printf("add new subtitle\n"); subtitleLock.lock(); nonDisplayedAVSubtitles.push_back(subtitle); subtitleLock.unlock();@@ -7478,17 +7466,17 @@ if (dvdSubtitle && subtitleOSD) {- hl_button = &(dvdSubtitle->rects[0]);+ hl_button = dvdSubtitle->rects[0]; osd->HideSet("subtitles"); osd->ClearAll("subtitles"); uint h = hl_button->h; uint w = hl_button->w;- int linesize = hl_button->linesize;+ int linesize = hl_button->pict.linesize[0]; QPoint topleft = QPoint(hl_button->x, hl_button->y); QRect buttonPos = player_ctx->buffer->DVD()->GetButtonCoords(); QImage hl_image(w, h, QImage::Format_ARGB32); uint8_t color;- uint32_t pixel;+ uint32_t pixel, *palette; QPoint currentPos = QPoint(0,0); for (uint y = 2; y < h; y++) {@@ -7496,13 +7484,14 @@ { currentPos.setY(y); currentPos.setX(x);- color = hl_button->bitmap[(y)*linesize+(x)];+ color = hl_button->pict.data[0][(y)*linesize+(x)]; // use rgba palette from dvd nav for drawing // highlighted button if (buttonPos.contains(currentPos))- pixel = dvdSubtitle->rects[1].rgba_palette[color];+ palette = (uint32_t *)(dvdSubtitle->rects[1]->pict.data[1]); else- pixel = hl_button->rgba_palette[color];+ palette = (uint32_t *)(hl_button->pict.data[1]);+ pixel = palette[color]; hl_image.setPixel(x, y, pixel); } }