From fe4662624d711faab6b406490a64c2382661997e Mon Sep 17 00:00:00 2001 From: Good Guy Date: Wed, 26 Oct 2016 10:16:40 -0600 Subject: [PATCH] fixes for xft when gc func not copy, fixes for zmpeg timestamp processing --- cinelerra-5.1/guicast/bcwindowbase.h | 2 ++ cinelerra-5.1/guicast/bcwindowdraw.C | 52 ++++++++++++++++++++-------- cinelerra-5.1/libzmpeg3/demux.C | 8 ++--- cinelerra-5.1/libzmpeg3/toc.C | 4 +-- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/cinelerra-5.1/guicast/bcwindowbase.h b/cinelerra-5.1/guicast/bcwindowbase.h index 994da7b0..aeaba388 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.h +++ b/cinelerra-5.1/guicast/bcwindowbase.h @@ -605,6 +605,8 @@ private: int find_next_textbox(BC_WindowBase **first_textbox, BC_WindowBase **next_textbox, int &result); int find_prev_textbox(BC_WindowBase **last_textbox, BC_WindowBase **prev_textbox, int &result); + void xft_draw_string(XftColor *xft_color, XftFont *xft_font, int x, int y, + const FcChar32 *fc, int len, BC_Pixmap *pixmap=0); void translate_coordinates(Window src_w, Window dest_w, int src_x, int src_y, int *dest_x_return, int *dest_y_return); diff --git a/cinelerra-5.1/guicast/bcwindowdraw.C b/cinelerra-5.1/guicast/bcwindowdraw.C index 635679ea..3119cde1 100644 --- a/cinelerra-5.1/guicast/bcwindowdraw.C +++ b/cinelerra-5.1/guicast/bcwindowdraw.C @@ -277,6 +277,40 @@ int BC_WindowBase::wcharpos(const wchar_t *text, XftFont *font, int length, } } +void BC_WindowBase::xft_draw_string(XftColor *xft_color, XftFont *xft_font, + int x, int y, const FcChar32 *fc, int len, BC_Pixmap *pixmap) +{ + Pixmap draw_pixmap = 0; + XftDraw *xft_draw = (XftDraw *) + (pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw); + int src_x = x, src_y = y, src_w = 0, src_h = 0; + XGCValues values; + XGetGCValues(top_level->display, top_level->gc, GCFunction, &values); + if( values.function != GXcopy ) { + XSetFunction(top_level->display, top_level->gc, GXcopy); + XGlyphInfo info; + XftTextExtents32(top_level->display, xft_font, fc, len, &info); + src_w = info.width; src_h = info.height; + draw_pixmap = XCreatePixmap(top_level->display, top_level->win, + src_w, src_h, top_level->default_depth); + int color = get_color(); set_color(0); + XFillRectangle(top_level->display, draw_pixmap, top_level->gc, 0, 0, src_w, src_h); + set_color(color); + xft_draw = XftDrawCreate(top_level->display, draw_pixmap, + top_level->vis, top_level->cmap); + src_x = info.x; src_y = info.y; + } + XftDrawString32(xft_draw, xft_color, xft_font, src_x, src_y, fc, len); + if( values.function != GXcopy ) { + XSetFunction(top_level->display, top_level->gc, values.function); + Pixmap xpixmap = pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap; + XCopyArea(top_level->display, draw_pixmap, xpixmap, + top_level->gc, 0, 0, src_w, src_h, x, y); + XFreePixmap(top_level->display, draw_pixmap); + XftDrawDestroy(xft_draw); + } +} + void BC_WindowBase::draw_wtext(int x, int y, const wchar_t *text, int length, BC_Pixmap *pixmap, int *charpos) { @@ -360,13 +394,8 @@ void BC_WindowBase::draw_wtext(int x, int y, if(nextfont != curfont) { l = up - ubp; - XftDrawString32((XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw), - &xft_color, - curfont, - x, - y, - (const FcChar32*)ubp, - l); + xft_draw_string(&xft_color, curfont, x, y, + (const FcChar32*)ubp, l, pixmap); if(charpos) cp = &charpos[ubp - text + 1]; @@ -379,13 +408,8 @@ void BC_WindowBase::draw_wtext(int x, int y, if(up > ubp) { - XftDrawString32((XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw), - &xft_color, - curfont, - x, - y, - (const FcChar32*)ubp, - up - ubp); + xft_draw_string(&xft_color, curfont, x, y, + (const FcChar32*)ubp, up - ubp, pixmap); if(charpos) wcharpos(ubp, curfont, up - ubp, &charpos[ubp - text + 1]); } diff --git a/cinelerra-5.1/libzmpeg3/demux.C b/cinelerra-5.1/libzmpeg3/demux.C index 77473ce6..e5ae3409 100644 --- a/cinelerra-5.1/libzmpeg3/demux.C +++ b/cinelerra-5.1/libzmpeg3/demux.C @@ -271,7 +271,7 @@ get_payload() if( dump ) zmsgs(" 0x%x bytes elementary data\n", raw_size-raw_offset); // if( pid == 0x1100 ) zmsgs("get_payload 1 0x%x\n", audio_pid); if( pid == audio_pid && (do_audio || read_all) ) { - if( do_audio ) got_audio = pid; + if( do_audio ) got_audio = audio_pid; if( dump ) { zmsgs(" offset=0x%jx 0x%x bytes AC3 pid=0x%x\n", absolute_position(), raw_size-raw_offset, pid); @@ -279,7 +279,7 @@ get_payload() get_transport_payload(1, 0); } else if( pid == video_pid && (do_video || read_all) ) { - if( do_video ) got_video = pid; + if( do_video ) got_video = video_pid; get_transport_payload(0, 1); } else { @@ -1539,7 +1539,7 @@ seek_byte(int64_t byte) void zdemuxer_t:: set_audio_pts(uint64_t pts, const double denom) { - if( pts ) { + if( pts && pes_audio_time < 0 ) { pes_audio_pid = custom_id; pes_audio_time = pts / denom; //zmsgs("pid 0x%03x, pts %f @0x%jx\n",pes_audio_pid, pes_audio_time, @@ -1550,7 +1550,7 @@ set_audio_pts(uint64_t pts, const double denom) void zdemuxer_t:: set_video_pts(uint64_t pts, const double denom) { - if( pts ) { + if( pts && pes_video_time < 0 ) { pes_video_pid = custom_id; pes_video_time = pts / denom; //zmsgs("pid 0x%03x, pts %f @0x%jx\n",pes_video_pid, pes_video_time, diff --git a/cinelerra-5.1/libzmpeg3/toc.C b/cinelerra-5.1/libzmpeg3/toc.C index b50c011d..ef5a60a3 100644 --- a/cinelerra-5.1/libzmpeg3/toc.C +++ b/cinelerra-5.1/libzmpeg3/toc.C @@ -1062,7 +1062,7 @@ do_toc(int64_t *bytes_processed) /* In a transport stream the audio or video is determined by the PID. */ /* In other streams the data type is determined by stream ID. */ if( demuxer->got_audio >= 0 || is_transport_stream() || is_audio_stream() ) { - int audio_pid = demuxer->got_audio; + int audio_pid = is_transport_stream() ? demuxer->custom_id : demuxer->got_audio; atrack_t *atrk = 0; for( idx=0; idx < total_atracks; ++idx ) { if( atrack[idx]->pid == audio_pid ) { /* Update an audio track */ @@ -1087,7 +1087,7 @@ do_toc(int64_t *bytes_processed) } } if( demuxer->got_video >= 0 || is_transport_stream() || is_video_stream() ) { - int video_pid = demuxer->got_video; + int video_pid = is_transport_stream() ? demuxer->custom_id : demuxer->got_video; vtrack_t *vtrk = 0; for( idx=0; idx < total_vtracks; ++idx ) { if( vtrack[idx]->pid == video_pid ) { /* Update a video track */ -- 2.26.2