54 static MHEG5Bool mg_subtitle_on = MHEG5TRUE;
55 static MHEG5Bool mg_full_screen = MHEG5TRUE;
56 static S_RECTANGLE mg_video_scaling = { -1000, -1000, 1000, 1000 };
57 #ifdef INCLUDE_FREESAT 58 static S_RECTANGLE mg_image_scaling = { -1000, -1000, 1000, 1000 };
61 static void Mheg5ToScalingCoordinates(
S_RECTANGLE *rect )
65 DBGTRACE(TGRAPHICS,
" RatioX (%d/%d)", mg_ctxt.vid_x.mlt, mg_ctxt.vid_x.div);
66 tmp = rect->left + rect->width;
67 rect->left = (rect->left * mg_ctxt.vid_x.mlt) / mg_ctxt.vid_x.div;
68 tmp = (tmp * mg_ctxt.vid_x.mlt) / mg_ctxt.vid_x.div;
69 rect->width = tmp - rect->left;
70 DBGTRACE(TGRAPHICS,
" RatioY (%d/%d)", mg_ctxt.vid_y.mlt, mg_ctxt.vid_y.div);
71 tmp = rect->top + rect->height;
72 rect->top = (rect->top * mg_ctxt.vid_y.mlt) / mg_ctxt.vid_y.div;
73 tmp = (tmp * mg_ctxt.vid_y.mlt) / mg_ctxt.vid_y.div;
74 rect->height = tmp - rect->top;
75 DBGTRACE(TGRAPHICS,
"%ux%u", rect->width, rect->height);
91 if (mg_subtitle_on != subtitleOn)
93 mg_subtitle_on = subtitleOn;
94 if (subtitleOn && mg_full_screen)
105 void MG_SetVideoPosition(
MHEG5Video *video, MHEG5Int contentHook )
108 S32BIT xOffset, yOffset;
110 MHEG5Bool fullscreen = MHEG5FALSE;
112 if (video && video->visible.ingredient.root.runningStatus)
114 rgn.left = video->visible.position[0];
115 rgn.top = video->visible.position[1];
116 rgn.right = video->visible.position[0] + video->visible.boxSize[0];
117 rgn.bottom = video->visible.position[1] + video->visible.boxSize[1];
119 xOffset = video->visible.position[0] + video->xOffset;
120 yOffset = video->visible.position[1] + video->yOffset;
121 new_video_scaling.left = xOffset;
122 new_video_scaling.top = yOffset;
123 TRACE(TGRAPHICS | TSTRM | TSTATE, (
"rgn=(%d,%d,%d,%d) offset=(%d,%d)", rgn.left, rgn.top, rgn.right, rgn.bottom, xOffset, yOffset))
128 else if (rgn.left > mg_ctxt.input_width)
129 rgn.left = mg_ctxt.input_width;
133 else if (rgn.top > mg_ctxt.input_height)
134 rgn.top = mg_ctxt.input_height;
136 if (rgn.right > mg_ctxt.input_width)
137 rgn.right = mg_ctxt.input_width;
138 else if (rgn.right < 0)
141 if (rgn.bottom > mg_ctxt.input_height)
142 rgn.bottom = mg_ctxt.input_height;
143 else if (rgn.bottom < 0)
145 TRACE(TGRAPHICS | TSTRM | TSTATE, (
"rgn=(%d,%d,%d,%d) offset=(%d,%d)", rgn.left, rgn.top, rgn.right, rgn.bottom, xOffset, yOffset))
148 if (rgn.right < rgn.left) rgn.right = rgn.left;
149 if (rgn.bottom < rgn.top) rgn.bottom = rgn.top;
154 if (xOffset + video->xScale < rgn.right)
156 rgn.right = video->xScale + xOffset;
158 if (yOffset + video->yScale < rgn.bottom)
160 rgn.bottom = video->yScale + yOffset;
165 if (xOffset + mg_ctxt.input_width < rgn.right)
167 rgn.right = mg_ctxt.input_width + xOffset;
169 if (yOffset + mg_ctxt.input_height < rgn.bottom)
171 rgn.bottom = mg_ctxt.input_height + yOffset;
174 if (rgn.left < xOffset)
181 xOffset = rgn.left - xOffset;
183 if (rgn.top < yOffset)
190 yOffset = rgn.top - yOffset;
192 TRACE(TGRAPHICS | TSTRM | TSTATE, (
"rgn=(%d,%d,%d,%d) offset=(%d,%d)", rgn.left, rgn.top, rgn.right, rgn.bottom, xOffset, yOffset));
194 if (!video->scaleSet)
196 TRACE(TGRAPHICS | TSTRM | TSTATE, (
"No SCALE rgn=(%d,%d,%d,%d) offset=(%d,%d)", rgn.left, rgn.top, rgn.right, rgn.bottom, xOffset, yOffset))
197 new_video_scaling.width = (U16BIT)SD_WIDTH;
198 new_video_scaling.height = (U16BIT)SD_HEIGHT;
199 if (new_video_scaling.left == 0 && new_video_scaling.top == 0)
201 fullscreen = MHEG5TRUE;
206 TRACE(TGRAPHICS | TSTRM | TSTATE, (
"SCALE(%d,%d) rgn=(%d,%d,%d,%d) offset=(%d,%d)", (
int)video->xScale, (
int)video->yScale,
207 rgn.left, rgn.top, rgn.right, rgn.bottom, xOffset, yOffset))
208 new_video_scaling.width = (U16BIT)video->xScale;
209 new_video_scaling.height = (U16BIT)video->yScale;
210 if (new_video_scaling.left == 0 && new_video_scaling.top == 0 &&
211 new_video_scaling.width == SD_WIDTH && new_video_scaling.height == SD_HEIGHT)
213 fullscreen = MHEG5TRUE;
219 TRACE(TGRAPHICS | TSTRM | TSTATE, (
"default video position"))
220 new_video_scaling.top = 0;
221 new_video_scaling.left = 0;
222 new_video_scaling.width = SD_WIDTH;
223 new_video_scaling.height = SD_HEIGHT;
224 fullscreen = MHEG5TRUE;
226 #ifdef INCLUDE_FREESAT 227 if (contentHook == CHOOK_BITMAP_IMAGE_PLANE_IFRAME)
229 if (new_video_scaling.height != mg_image_scaling.height ||
230 new_video_scaling.width != mg_image_scaling.width ||
231 new_video_scaling.left != mg_image_scaling.left ||
232 new_video_scaling.top != mg_image_scaling.top
235 mg_image_scaling = new_video_scaling;
238 DVB_MhegSetImageScaling( NULL );
244 Mheg5ToScalingCoordinates( &new_video_scaling );
245 DVB_MhegSetImageScaling( &new_video_scaling );
251 if (new_video_scaling.height != mg_video_scaling.height ||
252 new_video_scaling.width != mg_video_scaling.width ||
253 new_video_scaling.left != mg_video_scaling.left ||
254 new_video_scaling.top != mg_video_scaling.top
257 mg_video_scaling = new_video_scaling;
266 Mheg5ToScalingCoordinates( &new_video_scaling );
270 if (mg_full_screen != fullscreen)
272 mg_full_screen = fullscreen;
273 if (fullscreen && mg_subtitle_on)
295 MHEG5Int *graphicsXVal, MHEG5Int *graphicsYVal )
297 E_FORMAT_CONVERSION formatConversion;
299 S32BIT width = (S32BIT)mg_video_scaling.width;
300 S32BIT height = (S32BIT)mg_video_scaling.height;
301 #ifdef INCLUDE_USER_DEFINED_VTG 306 formatConversion = DVB_MhegGetDecoderFormatConversion();
307 switch (formatConversion)
309 case FORMAT_CONVERSION_UNKNOWN:
310 case FORMAT_CONVERSION_IGNORE:
311 *graphicsXVal = width * videoXval;
312 *graphicsYVal = height * videoYval;
314 case FORMAT_CONVERSION_PANSCAN:
315 *graphicsXVal = width * (8 * videoXval - SD_WIDTH) / 6;
316 *graphicsYVal = height * videoYval;
318 case FORMAT_CONVERSION_LETTERBOX:
319 *graphicsXVal = width * videoXval;
320 *graphicsYVal = height * (6 * videoYval + SD_HEIGHT) / 8;
322 case FORMAT_CONVERSION_LETTERBOX_14_9:
323 *graphicsXVal = width * (16 * videoXval - SD_WIDTH) / 14;
324 *graphicsYVal = height * (12 * videoYval + SD_HEIGHT) / 14;
326 case FORMAT_CONVERSION_PILLAR_BOX:
327 *graphicsXVal = width * (6 * videoXval + SD_WIDTH) / 8;
328 *graphicsYVal = height * videoYval;
330 case FORMAT_CONVERSION_ZOOM_4_3:
331 *graphicsXVal = width * videoXval;
332 *graphicsYVal = height * (8 * videoYval - SD_HEIGHT) / 6;
334 case FORMAT_CONVERSION_CENTRE_4_3:
335 *graphicsXVal = width * (8 * videoXval - SD_WIDTH) / 6;
336 *graphicsYVal = height * (8 * videoYval - SD_HEIGHT) / 6;
338 case FORMAT_CONVERSION_ZOOM_14_9:
339 *graphicsXVal = width * (14 * videoXval + SD_WIDTH) / 16;
340 *graphicsYVal = height * (14 * videoYval - SD_HEIGHT) / 12;
342 case FORMAT_CONVERSION_PANSCAN_14_9:
343 *graphicsXVal = width * (14 * videoXval - SD_WIDTH) / 12;
344 *graphicsYVal = height * (14 * videoYval - SD_HEIGHT) / 12;
346 case FORMAT_CONVERSION_CENTRE_14_9:
347 *graphicsXVal = width * (16 * videoXval - SD_WIDTH) / 14;
348 *graphicsYVal = height * (16 * videoYval - SD_HEIGHT) / 14;
350 #ifdef INCLUDE_USER_DEFINED_VTG 351 case FORMAT_CONVERSION_USER_DEFINED:
352 tmMHEG5VideoToGraphics(videoXval, videoYval, &xVal, &yVal);
353 *graphicsXVal = ((xVal * mg_ctxt.vid_x.div + mg_ctxt.vid_x.mlt / 2) /
355 *graphicsYVal = ((yVal * mg_ctxt.vid_y.div + mg_ctxt.vid_y.mlt / 2) /
361 *graphicsXVal = width * videoXval;
362 *graphicsYVal = height * videoYval;
367 *graphicsXVal = ((*graphicsXVal + SD_WIDTH / 2) / SD_WIDTH +
368 mg_video_scaling.left);
369 *graphicsYVal = ((*graphicsYVal + SD_HEIGHT / 2) / SD_HEIGHT +
370 mg_video_scaling.top);
374 void MG_VideoPositionReset(
void)
379 mg_full_screen = TRUE;
void MG_SetSubtitleMode(MHEG5Bool subtitleOn)
Set the current subtitle display mode to be either On or Off, Should only have an impact if subtitles...
void DVB_MhegSetVideoScaling(S_RECTANGLE *scaling)
Set Mheg video scaling.
E_MhegErr DVB_MhegSubtitleSetVisibility(E_DvbSubtitleShowState showState)
Show or hide DVB subtitles. This operation remains in force until set again by another call to this f...
DVB Video functions are required by MHEG5 engine. All required functions should be non-blocking...
This file defines the profile for the MHEG engine.
Mheg5 logging and debug printing.
void MG_DisplayVideoToGraphics(MHEG5Int videoXval, MHEG5Int videoYval, MHEG5Int *graphicsXVal, MHEG5Int *graphicsYVal)
Calculate the graphical co-ordinate from a given video coordinate (should take into account the curre...
Interaction Channel Streaming functions required by MHEG5 engine References: [1] UK1 Profile - Digita...
Video Scaling / Positioning functionality.