gimp-gap r812 - in trunk: . gap libgapvidapi po
- From: wolfgangh svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp-gap r812 - in trunk: . gap libgapvidapi po
- Date: Sat, 14 Feb 2009 19:03:08 +0000 (UTC)
Author: wolfgangh
Date: Sat Feb 14 19:03:07 2009
New Revision: 812
URL: http://svn.gnome.org/viewvc/gimp-gap?rev=812&view=rev
Log:
fixed aspect detection in videoapi for ffmpeg based decoder and Bugs #571428 #499553 #516819
Modified:
trunk/ChangeLog
trunk/gap/gap_frame_fetcher.c
trunk/gap/gap_image.c
trunk/gap/gap_morph_exec.c
trunk/gap/gap_mov_exec.c
trunk/gap/gap_range_ops.c
trunk/gap/gap_split.c
trunk/gap/gap_wr_color_levels.c
trunk/gap/gap_wr_opacity.c
trunk/libgapvidapi/gap_vid_api.c
trunk/libgapvidapi/gap_vid_api_ffmpeg.c
trunk/po/POTFILES.in
Modified: trunk/gap/gap_frame_fetcher.c
==============================================================================
--- trunk/gap/gap_frame_fetcher.c (original)
+++ trunk/gap/gap_frame_fetcher.c Sat Feb 14 19:03:07 2009
@@ -690,12 +690,20 @@
if (stackpos < l_nlayers)
{
gint32 src_layer_id;
+ gdouble l_xresoulution, l_yresoulution;
+ gint32 l_unit;
src_layer_id = l_layers_list[stackpos];
dup_image_id = gimp_image_new (gimp_image_width(image_id)
, gimp_image_height(image_id)
, gimp_image_base_type(image_id)
);
+ gimp_image_get_resolution(image_id, &l_xresoulution, &l_yresoulution);
+ gimp_image_set_resolution(dup_image_id, l_xresoulution, l_yresoulution);
+
+ l_unit = gimp_image_get_unit(image_id);
+ gimp_image_set_unit(dup_image_id, l_unit);
+
resulting_layer = gap_layer_copy_to_image (dup_image_id, src_layer_id);
}
Modified: trunk/gap/gap_image.c
==============================================================================
--- trunk/gap/gap_image.c (original)
+++ trunk/gap/gap_image.c Sat Feb 14 19:03:07 2009
@@ -158,13 +158,20 @@
guint l_width;
guint l_height;
gint32 new_image_id;
+ gdouble l_xresoulution, l_yresoulution;
+ gint32 l_unit;
+
/* create empty image */
l_width = gimp_image_width(old_image_id);
l_height = gimp_image_height(old_image_id);
l_type = gimp_image_base_type(old_image_id);
+ l_unit = gimp_image_get_unit(old_image_id);
+ gimp_image_get_resolution(old_image_id, &l_xresoulution, &l_yresoulution);
new_image_id = gimp_image_new(l_width, l_height,l_type);
+ gimp_image_set_resolution(new_image_id, l_xresoulution, l_yresoulution);
+ gimp_image_set_unit(new_image_id, l_unit);
if(layer_id)
{
Modified: trunk/gap/gap_morph_exec.c
==============================================================================
--- trunk/gap/gap_morph_exec.c (original)
+++ trunk/gap/gap_morph_exec.c Sat Feb 14 19:03:07 2009
@@ -2088,6 +2088,7 @@
, GIMP_NORMAL_MODE
);
}
+
gimp_image_add_layer(curr_image_id, dst_layer_id, 0);
@@ -2095,6 +2096,17 @@
dst_drawable = gimp_drawable_get (dst_layer_id);
if(dst_drawable == NULL) { return (-1); }
+ if(gap_debug)
+ {
+ printf("p_mix_layers dst_layer_id: %d bpp:%d top_layer_id:%d bpp:%d bg_layer_id:%d bpp:%d\n"
+ ,(int)dst_layer_id
+ ,(int)dst_drawable->bpp
+ ,(int)top_layer_id
+ ,(int)top_drawable->bpp
+ ,(int)bg_layer_id
+ ,(int)bg_drawable->bpp
+ );
+ }
@@ -2287,13 +2299,21 @@
}
dst_drawable = gimp_drawable_get (dst_layer_id);
-
- /* create the tween frame image */
- curr_image_id = gimp_image_new(curr_width, curr_height, GIMP_RGB);
+
+ if(gap_debug)
+ {
+ printf("p_create_morph_tween_frame dst_layer_id:%d, bpp:%d\n"
+ ,(int)dst_layer_id
+ ,(int)dst_drawable->bpp
+ );
+ }
/* add empty BG layer */
if(dst_drawable->bpp < 3)
{
+ /* create the tween frame image */
+ curr_image_id = gimp_image_new(curr_width, curr_height, GIMP_GRAY);
+
bg_layer_id = gimp_layer_new(curr_image_id, "bg_morph_layer"
, curr_width
, curr_height
@@ -2304,6 +2324,8 @@
}
else
{
+ /* create the tween frame image */
+ curr_image_id = gimp_image_new(curr_width, curr_height, GIMP_RGB);
bg_layer_id = gimp_layer_new(curr_image_id, "bg_morph_layer"
, curr_width
, curr_height
@@ -2320,13 +2342,26 @@
,(gdouble)0.0
,(gdouble)100.0
);
- top_layer_id = gimp_layer_new(curr_image_id, "top_morph_layer"
+ if(dst_drawable->bpp < 3)
+ {
+ top_layer_id = gimp_layer_new(curr_image_id, "top_morph_layer"
+ , curr_width
+ , curr_height
+ , GIMP_GRAYA_IMAGE
+ , curr_opacity
+ , GIMP_NORMAL_MODE
+ );
+ }
+ else
+ {
+ top_layer_id = gimp_layer_new(curr_image_id, "top_morph_layer"
, curr_width
, curr_height
, GIMP_RGBA_IMAGE
, curr_opacity
, GIMP_NORMAL_MODE
);
+ }
gimp_image_add_layer(curr_image_id, top_layer_id, 0);
Modified: trunk/gap/gap_mov_exec.c
==============================================================================
--- trunk/gap/gap_mov_exec.c (original)
+++ trunk/gap/gap_mov_exec.c Sat Feb 14 19:03:07 2009
@@ -1184,6 +1184,8 @@
gint l_nlayers;
gint32 *l_src_layers;
gint l_rc;
+ gdouble l_xresoulution, l_yresoulution;
+ gint32 l_unit;
l_mov_ptr = &apv_mov_data;
l_pvals = &apv_mov_vals;
@@ -1289,8 +1291,12 @@
l_width = (gimp_image_width(ainfo_ptr->image_id) * l_pvals->apv_scalex) / 100;
l_height = (gimp_image_height(ainfo_ptr->image_id) * l_pvals->apv_scaley) / 100;
l_type = gimp_image_base_type(ainfo_ptr->image_id);
+ l_unit = gimp_image_get_unit(ainfo_ptr->image_id);
+ gimp_image_get_resolution(ainfo_ptr->image_id, &l_xresoulution, &l_yresoulution);
l_mlayer_image_id = gimp_image_new(l_width, l_height,l_type);
+ gimp_image_set_resolution(l_mlayer_image_id, l_xresoulution, l_yresoulution);
+ gimp_image_set_unit(l_mlayer_image_id, l_unit);
gimp_image_undo_disable (l_mlayer_image_id);
l_pvals->apv_mlayer_image = l_mlayer_image_id;
@@ -1309,6 +1315,7 @@
case GAP_APV_QUICK:
/* use an empty dummy frame for all frames */
l_tmp_frame_id = gimp_image_new(l_width, l_height,l_type);
+ gimp_image_set_resolution(l_tmp_frame_id, l_xresoulution, l_yresoulution);
gimp_image_undo_disable (l_tmp_frame_id);
break;
case GAP_APV_ONE_FRAME:
Modified: trunk/gap/gap_range_ops.c
==============================================================================
--- trunk/gap/gap_range_ops.c (original)
+++ trunk/gap/gap_range_ops.c Sat Feb 14 19:03:07 2009
@@ -862,7 +862,8 @@
gboolean l_clear_selected_area;
gint32 calling_image_id;
gint32 calling_frame_nr;
-
+ gdouble l_xresoulution, l_yresoulution;
+ gint32 l_unit;
calling_image_id = ainfo_ptr->image_id;
calling_frame_nr = ainfo_ptr->curr_frame_nr;
@@ -877,17 +878,23 @@
l_tmp_layer_id = -1;
- /* get info about the image (size and type is common to all frames) */
+ /* get info about the image (size type and resolution is common to all frames) */
l_width = gimp_image_width(ainfo_ptr->image_id);
l_height = gimp_image_height(ainfo_ptr->image_id);
l_type = gimp_image_base_type(ainfo_ptr->image_id);
+ l_unit = gimp_image_get_unit(ainfo_ptr->image_id);
+ gimp_image_get_resolution(ainfo_ptr->image_id, &l_xresoulution, &l_yresoulution);
+
if (l_type == GIMP_INDEXED)
{
l_type = GIMP_RGB;
}
l_new_image_id = gimp_image_new(l_width, l_height,l_type);
+ gimp_image_set_resolution(l_new_image_id, l_xresoulution, l_yresoulution);
+ gimp_image_set_unit(l_new_image_id, l_unit);
+
l_visible = TRUE; /* only the 1.st layer should be visible */
l_clear_selected_area = FALSE;
Modified: trunk/gap/gap_split.c
==============================================================================
--- trunk/gap/gap_split.c (original)
+++ trunk/gap/gap_split.c Sat Feb 14 19:03:07 2009
@@ -147,6 +147,8 @@
int l_framenumber;
long l_layer_idx;
gint l_overwrite_mode;
+ gdouble l_xresoulution, l_yresoulution;
+ gint32 l_unit;
if(gap_debug)
{
@@ -173,6 +175,8 @@
l_width = gimp_image_width(ainfo_ptr->image_id);
l_height = gimp_image_height(ainfo_ptr->image_id);
l_type = gimp_image_base_type(ainfo_ptr->image_id);
+ l_unit = gimp_image_get_unit(ainfo_ptr->image_id);
+ gimp_image_get_resolution(ainfo_ptr->image_id, &l_xresoulution, &l_yresoulution);
l_layers_list = gimp_image_get_layers(ainfo_ptr->image_id, &l_nlayers);
if(l_layers_list != NULL)
@@ -251,6 +255,9 @@
{
/* create new image */
l_new_image_id = gimp_image_new(l_width, l_height,l_type);
+ gimp_image_set_resolution(l_new_image_id, l_xresoulution, l_yresoulution);
+ gimp_image_set_unit(l_new_image_id, l_unit);
+
if(l_new_image_id < 0)
{
l_rc = -1;
Modified: trunk/gap/gap_wr_color_levels.c
==============================================================================
--- trunk/gap/gap_wr_color_levels.c (original)
+++ trunk/gap/gap_wr_color_levels.c Sat Feb 14 19:03:07 2009
@@ -320,6 +320,13 @@
/* Get the runmode from the in-parameters */
GimpRunMode run_mode = param[0].data.d_int32;
+
+ if(gap_debug)
+ {
+ printf("START plug-in-wr-color-levels\n");
+ }
+
+
/* status variable, use it to check for errors in invocation usualy only
during non-interactive calling */
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
@@ -417,11 +424,11 @@
wcd->show_progress = FALSE;
l_cuvals.channel = param[3].data.d_int32;
- l_cuvals.low_input = param[3].data.d_int32;
- l_cuvals.high_input = param[3].data.d_int32;
- l_cuvals.gamma = param[4].data.d_float;
- l_cuvals.low_output = param[3].data.d_int32;
- l_cuvals.high_output = param[3].data.d_int32;
+ l_cuvals.low_input = param[4].data.d_int32;
+ l_cuvals.high_input = param[5].data.d_int32;
+ l_cuvals.gamma = param[6].data.d_float;
+ l_cuvals.low_output = param[7].data.d_int32;
+ l_cuvals.high_output = param[8].data.d_int32;
}
else
{
Modified: trunk/gap/gap_wr_opacity.c
==============================================================================
--- trunk/gap/gap_wr_opacity.c (original)
+++ trunk/gap/gap_wr_opacity.c Sat Feb 14 19:03:07 2009
@@ -215,7 +215,7 @@
if (nparams == global_number_in_args)
{
glob_vals.opacity = (gdouble) param[3].data.d_float;
- glob_vals.mode = (gint32) param[3].data.d_int32;
+ glob_vals.mode = (gint32) param[4].data.d_int32;
}
else
{
Modified: trunk/libgapvidapi/gap_vid_api.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api.c (original)
+++ trunk/libgapvidapi/gap_vid_api.c Sat Feb 14 19:03:07 2009
@@ -777,7 +777,14 @@
* p_register_all_decoders
* ---------------------------
* build the GVA_global_decoder_list
- * with one element for each available decoder
+ * with one element for each available decoder.
+ *
+ * in case the caller does not specifiy a prefered_decoder
+ * the order of registered decoders is relevant, because
+ * the 1st one that can handle the video is picked at open.
+ *
+ * This is typical the last one that is added to begin of the list
+ * (currently ffmpeg)
*/
static void
p_register_all_decoders(void)
@@ -805,9 +812,8 @@
}
#endif
-#ifdef ENABLE_GVA_LIBAVFORMAT
- p_ffmpeg_init();
- dec_elem = p_ffmpeg_new_dec_elem();
+#ifdef ENABLE_GVA_LIBMPEG3
+ dec_elem = p_mpeg3_new_dec_elem();
if(dec_elem)
{
dec_elem->next = GVA_global_decoder_list;
@@ -815,8 +821,9 @@
}
#endif
-#ifdef ENABLE_GVA_LIBMPEG3
- dec_elem = p_mpeg3_new_dec_elem();
+#ifdef ENABLE_GVA_LIBAVFORMAT
+ p_ffmpeg_init();
+ dec_elem = p_ffmpeg_new_dec_elem();
if(dec_elem)
{
dec_elem->next = GVA_global_decoder_list;
@@ -2067,6 +2074,13 @@
/* ------------------------------------
* GVA_image_set_aspect
* ------------------------------------
+ * if aspect_ratio is known convert the aspect
+ * to image X and Y resolution in DPI
+ * this allows GIMP to scale the display to correct aspect
+ * when View option "Dot for Dot" is turned off.
+ * Note that the resolution is just a guess based on typical
+ * monitor resolution in DPI.
+ * (videos usually have no DPI resoulution information, just aspect ratio)
*/
void
GVA_image_set_aspect(t_GVA_Handle *gvahand, gint32 image_id)
@@ -2076,15 +2090,28 @@
{
gdouble xresolution;
gdouble yresolution;
+ gdouble xresolutionMoni;
+ gdouble yresolutionMoni;
gdouble asymetric;
asymetric = ((gdouble)gvahand->width / (gdouble)gvahand->height)
/ gvahand->aspect_ratio;
- yresolution = 72.0;
+ gimp_get_monitor_resolution(&xresolutionMoni, &yresolutionMoni);
+
+ if (yresolutionMoni > 0)
+ {
+ yresolution = yresolutionMoni;
+ }
+ else
+ {
+ yresolution = 72.0;
+ }
xresolution = yresolution * asymetric;
- /* set resolution in DPI according to aspect ratio */
+ /* set resolution in DPI according to aspect ratio
+ * assuming a typical monitor resolution
+ */
gimp_image_set_unit (image_id, GIMP_UNIT_INCH);
gimp_image_set_resolution (image_id, xresolution, yresolution);
Modified: trunk/libgapvidapi/gap_vid_api_ffmpeg.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api_ffmpeg.c (original)
+++ trunk/libgapvidapi/gap_vid_api_ffmpeg.c Sat Feb 14 19:03:07 2009
@@ -3529,58 +3529,49 @@
/* -------------------------
* p_set_aspect_ratio
* -------------------------
+ * set the gvahand->aspect_ratio variable to aspect ratio
+ * typical values are
+ * 1.777777 For 16:9 video
+ * 1.333333 For 4:3 video
+ *
+ * Note that the gvahand->aspect_ratio variable describes the ratio
+ * for the full image (and not the ratio of a single pixel)
+ *
+ * (code is based on example ffplay.c)
*/
static void
p_set_aspect_ratio(t_GVA_Handle *gvahand, t_GVA_ffmpeg* handle)
{
- AVCodecContext *acc;
-
- acc = handle->vid_codec_context;
-
- gvahand->aspect_ratio = 0;
- if (acc->sample_aspect_ratio.num == 0)
+ AVStream *video_st;
+
+ video_st = handle->vid_stream;
+ gvahand->aspect_ratio = 0.0;
+
+ if (video_st->sample_aspect_ratio.num)
{
- gvahand->aspect_ratio = 0;
+ gvahand->aspect_ratio = av_q2d(video_st->sample_aspect_ratio);
}
- else
+ else if (video_st->codec->sample_aspect_ratio.num)
{
- if(gap_debug)
- {
- printf("ASPECT_RATIO: 1:1 as delivered via sample_aspect_ratio: %f w:%d h:%d\n"
- , av_q2d(acc->sample_aspect_ratio)
- ,acc->width
- ,acc->height
- );
- }
-
- /* the following variant (same as implementaed in ffplay.c)
- * does not work correct.
- * (delivers aspect_ratio 2,370370 for 16:9 video testtfile
- * but shall deliver 1.777777)
- */
- //gvahand->aspect_ratio = av_q2d(acc->sample_aspect_ratio)
- // * (gdouble)acc->width / (gdouble)acc->height;
-
- /* this variant does not work correct either, but will be used
- * because the error is smaller.
- * (delivers aspect_ratio 1,580247for 16:9 video testtfile
- * but shall deliver 1.777777)
- *
- * TODO findout how to detect aspect reliable and exact...
- */
- gvahand->aspect_ratio = av_q2d(acc->sample_aspect_ratio);
+ gvahand->aspect_ratio = av_q2d(video_st->codec->sample_aspect_ratio);
+ }
+
+ if (gvahand->aspect_ratio <= 0.0)
+ {
+ gvahand->aspect_ratio = 1.0;
+ }
+
+ if(gvahand->aspect_ratio != 0.0)
+ {
+ gvahand->aspect_ratio *= (gdouble)video_st->codec->width / video_st->codec->height;
}
- /* default width / height
- * is not USED, (it would hide the information, that the video
- * has no explictie aspect_ratio that is represented by 0.0)
- */
- //if (gvahand->aspect_ratio <= 0.0)
- //{
- // gvahand->aspect_ratio = (float)acc->width /
- // (float)acc->height;
- //}
+#if 0
+ if(gap_debug)
+ {
+ printf("#if 0 dtg_active_format=%d\n", video_st->codec->dtg_active_format);
+ }
/* dtg_active_format: aspect information may be available in some cases.
@@ -3588,32 +3579,39 @@
* information only used in DVB MPEG-2 transport streams)
* 0 if not set.
*/
- switch(acc->dtg_active_format)
+ switch(video_st->codec->dtg_active_format)
{
- case FF_DTG_AFD_4_3:
- case FF_DTG_AFD_4_3_SP_14_9:
- case FF_DTG_AFD_SP_4_3:
- gvahand->aspect_ratio = 4.0 / 3.0;
- break;
- case FF_DTG_AFD_16_9:
- case FF_DTG_AFD_16_9_SP_14_9:
- gvahand->aspect_ratio = 16.0 / 9.0;
- break;
- case FF_DTG_AFD_14_9:
- gvahand->aspect_ratio = 14.0 / 9.0;
- break;
+ case FF_DTG_AFD_4_3:
+ gvahand->aspect_ratio = 4.0 / 3.0;
+ break;
+ case FF_DTG_AFD_16_9:
+ gvahand->aspect_ratio = 16.0 / 9.0;
+ break;
+ case FF_DTG_AFD_14_9:
+ gvahand->aspect_ratio = 14.0 / 9.0;
+ break;
+ case FF_DTG_AFD_4_3_SP_14_9:
+ gvahand->aspect_ratio = 14.0 / 9.0;
+ break;
+ case FF_DTG_AFD_16_9_SP_14_9:
+ gvahand->aspect_ratio = 14.0 / 9.0;
+ break;
+ case FF_DTG_AFD_SP_4_3:
+ gvahand->aspect_ratio = 4.0 / 3.0;
+ break;
case FF_DTG_AFD_SAME:
default:
break;
}
+#endif
if(gap_debug)
{
printf("FF ASPECT: dtg_active_format:%d num:%d den:%d\n"
- ,(int)acc->dtg_active_format
- ,(int)acc->sample_aspect_ratio.num
- ,(int)acc->sample_aspect_ratio.den
+ ,(int)video_st->codec->dtg_active_format
+ ,(int)video_st->codec->sample_aspect_ratio.num
+ ,(int)video_st->codec->sample_aspect_ratio.den
);
printf("FF ASPECT: dtected aspect_ratio: %f\n"
,(float)gvahand->aspect_ratio
@@ -4700,7 +4698,6 @@
p_timecode_to_frame_nr(t_GVA_ffmpeg *handle, int64_t timecode)
{
int64_t framenr;
- int64_t steps;
int64_t l_timecode;
int64_t l_group_timecode;
@@ -4732,11 +4729,10 @@
if(gap_debug)
{
- printf("p_timecode_to_frame_nr: framenr:%lld timecode:%lld offset_frame1:%lld steps:%lld\n"
+ printf("p_timecode_to_frame_nr: framenr:%lld timecode:%lld offset_frame1:%lld\n"
, framenr
, timecode
, handle->timecode_offset_frame1
- , steps
);
}
return (framenr);
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sat Feb 14 19:03:07 2009
@@ -7,6 +7,7 @@
gap/gap_bluebox.c
gap/gap_bluebox_main.c
gap/gap_dbbrowser_utils.c
+gap/gap_decode_mplayer_main.c
gap/gap_decode_mplayer.c
gap/gap_decode_xanim.c
gap/gap_filter_foreach.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]