vlc_filter.h - error: 'MODULE_STRING' undeclared

This forum is about all development around libVLC.
gmv
Blank Cone
Blank Cone
Posts: 15
Joined: 18 Feb 2013 18:46

vlc_filter.h - error: 'MODULE_STRING' undeclared

Postby gmv » 21 Jun 2013 17:11

Hi,
i have created a new method into the source file named picture.c, which is in the next path: vlc/misc/picture.c.

This method is native method since i want connect this class with a Java class. I have tested with a easy method to pass a string:

Code: Select all

JNIEXPORT void JNICALL Java_org_videolan_vlc_gui_video_VirtualActivity_HolaMundo (JNIEnv *env, jobject obj, jstring javaString) { const char *nativeString = (*env)->GetStringUTFChars(env, javaString, 0); (*env)->ReleaseStringUTFChars(env, javaString, nativeString); }
In the file named vlc_picture.h, i have declared the function:
VLC_API JNIEXPORT void JNICALL Java_org_videolan_vlc_gui_video_VirtualActivity_HolaMundo(JNIEnv * env, jobject jobj, jstring javaString);

In the Java class which uses that method:

Code: Select all

static { try{ Log.d(LOGTAG, "Cargando la librería native"); System.loadLibrary("native"); Log.d(LOGTAG, "Library loaded - native"); }catch (Exception e){ Log.d(LOGTAG, "Did not load library - native"); } } public native void HolaMundo(String javaString);
And finally, in Android.mk of the jni folder:

Code: Select all

include $(CLEAR_VARS) LOCAL_MODULE := native LOCAL_SRC_FILES := /../../vlc/src/misc/picture.c LOCAL_C_INCLUDES := \ $(ANDROID_NDK)/platforms/android-8/arch-arm/usr/include \ /usr/include/ \ /home/vmg/android/android/vlc/include \ /home/vmg/android/android/vlc/include/vlc \ include $(BUILD_SHARED_LIBRARY)
When i compile all the code, i get the next error:

Code: Select all

Compile thumb : native <= picture.c In file included from /home/vmg/android/android/vlc/include/vlc_vout.h:35:0, from /home/vmg/android/android/vlc/include/vlc_image.h:32, from jni//../../vlc/src/misc/picture.c:38: /home/vmg/android/android/vlc/include/vlc_filter.h: In function 'filter_NewPicture': /home/vmg/android/android/vlc/include/vlc_filter.h:158:9: error: 'MODULE_STRING' undeclared (first use in this function) /home/vmg/android/android/vlc/include/vlc_filter.h:158:9: note: each undeclared identifier is reported only once for each function it appears in /home/vmg/android/android/vlc/include/vlc_filter.h: In function 'filter_NewSubpicture': /home/vmg/android/android/vlc/include/vlc_filter.h:196:9: error: 'MODULE_STRING' undeclared (first use in this function) make[1]: *** [obj/local/armeabi-v7a/objs-debug/native//__/__/vlc/src/misc/picture.o] Error 1 make[1]: Leaving directory `/home/vmg/android/android/vlc-android' make: *** [vlc-android/obj/local/armeabi-v7a/libvlcjni.so] Error 2
The header file is correct and the library jni is included.

How can I solve it?
Thanks!

Rémi Denis-Courmont
Developer
Developer
Posts: 15231
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vlc_filter.h - error: 'MODULE_STRING' undeclared

Postby Rémi Denis-Courmont » 21 Jun 2013 17:29

Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

gmv
Blank Cone
Blank Cone
Posts: 15
Joined: 18 Feb 2013 18:46

Re: vlc_filter.h - error: 'MODULE_STRING' undeclared

Postby gmv » 24 Jun 2013 15:48

Sorry, but i haven't understood his reply and i don't know that i must do to solve it.

Sometimes i have included some new methods in .c class and only i have declared them in the appropiate vlc_*.h file.

If the new method has native code, should I follow a different procedure?
Since there are several Makefile and configure.ac files, what is the file where i must include those lines of code that are indicated into http://wiki.videolan.org/OutOfTreeCompile ?

In my picture.c file, i have created two methods:
- picture_t *picture_FiltroColor( picture_t *p_picture ) -> this method changes the values of the plane U and i've declared this function into vlc_picture.h and it works fine.
- JNIEXPORT void JNICALL
Java_org_videolan_vlc_gui_video_VirtualActivity_HolaMundo (JNIEnv *env, jobject obj, jstring javaString)
. the errors occur when i include this method.

Code: Select all

/***************************************************************************** * picture.c : picture management functions ***************************************************************************** * Copyright (C) 2000-2010 VLC authors and VideoLAN * Copyright (C) 2009-2010 Laurent Aimar * $Id: d90748c435233770cd725fd8c2249eee54fa93c2 $ * * Authors: Vincent Seguin <seguin@via.ecp.fr> * Samuel Hocevar <sam@zoy.org> * Laurent Aimar <fenrir _AT_ videolan _DOT_ org> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <assert.h> #include <vlc_common.h> #include <vlc_picture.h> #include <vlc_image.h> #include <vlc_block.h> #include <vlc_atomic.h> include <jni.h> #include <math.h> #include "org_videolan_vlc_gui_video_VirtualActivity.h" #include "org_videolan_vlc_gui_video_VirtualActivity_DepthTestSurfaceView.h" /** * Allocate a new picture in the heap. * * This function allocates a fake direct buffer in memory, which can be * used exactly like a video buffer. The video output thread then manages * how it gets displayed. */ static int AllocatePicture( picture_t *p_pic, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) { /* Make sure the real dimensions are a multiple of 16 */ if( picture_Setup( p_pic, i_chroma, i_width, i_height, i_sar_num, i_sar_den ) != VLC_SUCCESS ) return VLC_EGENERIC; /* Calculate how big the new image should be */ size_t i_bytes = 0; int i; for( i = 0; i < p_pic->i_planes; i++ ) { const plane_t *p = &p_pic->p[i]; if( p->i_pitch <= 0 || p->i_lines <= 0 || (size_t)p->i_pitch > (SIZE_MAX - i_bytes)/p->i_lines ) { p_pic->i_planes = 0; return VLC_ENOMEM; } i_bytes += p->i_pitch * p->i_lines; } uint8_t *p_data = vlc_memalign( 16, i_bytes ); if( !p_data ) { p_pic->i_planes = 0; return VLC_EGENERIC; } p_pic->gc.p_sys = (void *)p_data; /* Fill the p_pixels field for each plane */ p_pic->p[0].p_pixels = p_data; for( i = 1; i < p_pic->i_planes; i++ ) { p_pic->p[i].p_pixels = &p_pic->p[i-1].p_pixels[ p_pic->p[i-1].i_lines * p_pic->p[i-1].i_pitch ]; } return VLC_SUCCESS; } /***************************************************************************** * *****************************************************************************/ static void PictureDestroy( picture_t *p_picture ) { assert( p_picture && vlc_atomic_get( &p_picture->gc.refcount ) == 0 ); free( p_picture->p_q ); vlc_free( p_picture->gc.p_sys ); free( p_picture->p_sys ); free( p_picture ); } /***************************************************************************** * *****************************************************************************/ void picture_Reset( picture_t *p_picture ) { /* */ p_picture->date = VLC_TS_INVALID; p_picture->b_force = false; p_picture->b_progressive = false; p_picture->i_nb_fields = 2; p_picture->b_top_field_first = false; free( p_picture->p_q ); p_picture->p_q = NULL; p_picture->i_qstride = 0; p_picture->i_qtype = 0; } /***************************************************************************** * *****************************************************************************/ static int LCM( int a, int b ) { return a * b / GCD( a, b ); } int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) { /* Store default values */ p_picture->i_planes = 0; unsigned i; for( i = 0; i < VOUT_MAX_PLANES; i++ ) { plane_t *p = &p_picture->p[i]; p->p_pixels = NULL; p->i_pixel_pitch = 0; } vlc_atomic_set( &p_picture->gc.refcount, 0 ); p_picture->gc.pf_destroy = NULL; p_picture->gc.p_sys = NULL; p_picture->i_nb_fields = 2; p_picture->i_qtype = QTYPE_NONE; p_picture->i_qstride = 0; p_picture->p_q = NULL; video_format_Setup( &p_picture->format, i_chroma, i_width, i_height, i_sar_num, i_sar_den ); const vlc_chroma_description_t *p_dsc = vlc_fourcc_GetChromaDescription( p_picture->format.i_chroma ); if( !p_dsc ) return VLC_EGENERIC; /* We want V (width/height) to respect: (V * p_dsc->p[i].w.i_num) % p_dsc->p[i].w.i_den == 0 (V * p_dsc->p[i].w.i_num/p_dsc->p[i].w.i_den * p_dsc->i_pixel_size) % 16 == 0 Which is respected if you have V % lcm( p_dsc->p[0..planes].w.i_den * 16) == 0 */ int i_modulo_w = 1; int i_modulo_h = 1; unsigned int i_ratio_h = 1; for( i = 0; i < p_dsc->plane_count; i++ ) { i_modulo_w = LCM( i_modulo_w, 16 * p_dsc->p[i].w.den ); i_modulo_h = LCM( i_modulo_h, 16 * p_dsc->p[i].h.den ); if( i_ratio_h < p_dsc->p[i].h.den ) i_ratio_h = p_dsc->p[i].h.den; } i_modulo_h = LCM( i_modulo_h, 32 ); const int i_width_aligned = ( i_width + i_modulo_w - 1 ) / i_modulo_w * i_modulo_w; const int i_height_aligned = ( i_height + i_modulo_h - 1 ) / i_modulo_h * i_modulo_h; const int i_height_extra = 2 * i_ratio_h; /* This one is a hack for some ASM functions */ for( i = 0; i < p_dsc->plane_count; i++ ) { plane_t *p = &p_picture->p[i]; p->i_lines = (i_height_aligned + i_height_extra ) * p_dsc->p[i].h.num / p_dsc->p[i].h.den; p->i_visible_lines = i_height * p_dsc->p[i].h.num / p_dsc->p[i].h.den; p->i_pitch = i_width_aligned * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size; p->i_visible_pitch = i_width * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size; p->i_pixel_pitch = p_dsc->pixel_size; assert( (p->i_pitch % 16) == 0 ); } p_picture->i_planes = p_dsc->plane_count; return VLC_SUCCESS; } /***************************************************************************** * *****************************************************************************/ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_resource_t *p_resource ) { video_format_t fmt = *p_fmt; /* It is needed to be sure all information are filled */ video_format_Setup( &fmt, p_fmt->i_chroma, p_fmt->i_width, p_fmt->i_height, p_fmt->i_sar_num, p_fmt->i_sar_den ); if( p_fmt->i_x_offset < p_fmt->i_width && p_fmt->i_y_offset < p_fmt->i_height && p_fmt->i_visible_width > 0 && p_fmt->i_x_offset + p_fmt->i_visible_width <= p_fmt->i_width && p_fmt->i_visible_height > 0 && p_fmt->i_y_offset + p_fmt->i_visible_height <= p_fmt->i_height ) video_format_CopyCrop( &fmt, p_fmt ); /* */ picture_t *p_picture = calloc( 1, sizeof(*p_picture) ); if( !p_picture ) return NULL; if( p_resource ) { if( picture_Setup( p_picture, fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_sar_num, fmt.i_sar_den ) ) { free( p_picture ); return NULL; } p_picture->p_sys = p_resource->p_sys; assert( p_picture->gc.p_sys == NULL ); int i ; for( i = 0; i < p_picture->i_planes; i++ ) { p_picture->p[i].p_pixels = p_resource->p[i].p_pixels; p_picture->p[i].i_lines = p_resource->p[i].i_lines; p_picture->p[i].i_pitch = p_resource->p[i].i_pitch; } } else { if( AllocatePicture( p_picture, fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_sar_num, fmt.i_sar_den ) ) { free( p_picture ); return NULL; } assert( p_picture->gc.p_sys != NULL ); } /* */ p_picture->format = fmt; vlc_atomic_set( &p_picture->gc.refcount, 1 ); p_picture->gc.pf_destroy = PictureDestroy; return p_picture; } picture_t *picture_NewFromFormat( const video_format_t *p_fmt ) { return picture_NewFromResource( p_fmt, NULL ); } picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) { video_format_t fmt; memset( &fmt, 0, sizeof(fmt) ); video_format_Setup( &fmt, i_chroma, i_width, i_height, i_sar_num, i_sar_den ); return picture_NewFromFormat( &fmt ); } /***************************************************************************** * *****************************************************************************/ picture_t *picture_Hold( picture_t *p_picture ) { vlc_atomic_inc( &p_picture->gc.refcount ); return p_picture; } void picture_Release( picture_t *p_picture ) { if( vlc_atomic_dec( &p_picture->gc.refcount ) == 0 && p_picture->gc.pf_destroy ) p_picture->gc.pf_destroy( p_picture ); } bool picture_IsReferenced( picture_t *p_picture ) { return vlc_atomic_get( &p_picture->gc.refcount ) > 1; } /***************************************************************************** * *****************************************************************************/ void plane_CopyPixels( plane_t *p_dst, const plane_t *p_src ) { const unsigned i_width = __MIN( p_dst->i_visible_pitch, p_src->i_visible_pitch ); const unsigned i_height = __MIN( p_dst->i_visible_lines, p_src->i_visible_lines ); /* The 2x visible pitch check does two things: 1) Makes field plane_t's work correctly (see the deinterlacer module) 2) Moves less data if the pitch and visible pitch differ much. */ if( p_src->i_pitch == p_dst->i_pitch && p_src->i_pitch < 2*p_src->i_visible_pitch ) { /* There are margins, but with the same width : perfect ! */ memcpy( p_dst->p_pixels, p_src->p_pixels, p_src->i_pitch * i_height ); } else { /* We need to proceed line by line */ uint8_t *p_in = p_src->p_pixels; uint8_t *p_out = p_dst->p_pixels; int i_line; assert( p_in ); assert( p_out ); for( i_line = i_height; i_line--; ) { memcpy( p_out, p_in, i_width ); p_in += p_src->i_pitch; p_out += p_dst->i_pitch; } } } void picture_CopyProperties( picture_t *p_dst, const picture_t *p_src ) { p_dst->date = p_src->date; p_dst->b_force = p_src->b_force; p_dst->b_progressive = p_src->b_progressive; p_dst->i_nb_fields = p_src->i_nb_fields; p_dst->b_top_field_first = p_src->b_top_field_first; /* FIXME: copy ->p_q and ->p_qstride */ } void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src ) { int i; for( i = 0; i < p_src->i_planes ; i++ ) plane_CopyPixels( p_dst->p+i, p_src->p+i ); } void picture_Copy( picture_t *p_dst, const picture_t *p_src ) { picture_CopyPixels( p_dst, p_src ); picture_CopyProperties( p_dst, p_src ); } /***************************************************************************** * *****************************************************************************/ int picture_Export( vlc_object_t *p_obj, block_t **pp_image, video_format_t *p_fmt, picture_t *p_picture, vlc_fourcc_t i_format, int i_override_width, int i_override_height ) { /* */ video_format_t fmt_in = p_picture->format; if( fmt_in.i_sar_num <= 0 || fmt_in.i_sar_den <= 0 ) { fmt_in.i_sar_num = fmt_in.i_sar_den = 1; } /* */ video_format_t fmt_out; memset( &fmt_out, 0, sizeof(fmt_out) ); fmt_out.i_sar_num = fmt_out.i_sar_den = 1; fmt_out.i_chroma = i_format; /* compute original width/height */ unsigned int i_original_width; unsigned int i_original_height; if( fmt_in.i_sar_num >= fmt_in.i_sar_den ) { i_original_width = (int64_t)fmt_in.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den; i_original_height = fmt_in.i_height; } else { i_original_width = fmt_in.i_width; i_original_height = (int64_t)fmt_in.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num; } /* */ fmt_out.i_width = ( i_override_width < 0 ) ? i_original_width : (unsigned)i_override_width; fmt_out.i_height = ( i_override_height < 0 ) ? i_original_height : (unsigned)i_override_height; /* scale if only one direction is provided */ if( fmt_out.i_height == 0 && fmt_out.i_width > 0 ) { fmt_out.i_height = fmt_in.i_height * fmt_out.i_width * fmt_in.i_sar_den / fmt_in.i_width / fmt_in.i_sar_num; } else if( fmt_out.i_width == 0 && fmt_out.i_height > 0 ) { fmt_out.i_width = fmt_in.i_width * fmt_out.i_height * fmt_in.i_sar_num / fmt_in.i_height / fmt_in.i_sar_den; } image_handler_t *p_image = image_HandlerCreate( p_obj ); block_t *p_block = image_Write( p_image, p_picture, &fmt_in, &fmt_out ); image_HandlerDelete( p_image ); if( !p_block ) return VLC_EGENERIC; p_block->i_pts = p_block->i_dts = p_picture->date; if( p_fmt ) *p_fmt = fmt_out; *pp_image = p_block; return VLC_SUCCESS; } void picture_BlendSubpicture(picture_t *dst, filter_t *blend, subpicture_t *src) { assert(src && !src->b_fade && src->b_absolute); subpicture_region_t *r; for ( r = src->p_region; r != NULL; r = r->p_next) { assert(r->p_picture && r->i_align == 0); if (filter_ConfigureBlend(blend, dst->format.i_width, dst->format.i_height, &r->fmt) || filter_Blend(blend, dst, r->i_x, r->i_y, r->p_picture, src->i_alpha * r->i_alpha / 255)) { return; msg_Err(blend, "blending %4.4s to %4.4s failed", (char *)&blend->fmt_in.video.i_chroma, (char *)&blend->fmt_out.video.i_chroma ); } } } picture_t *picture_FiltroColor( picture_t *p_picture ){ /* i_lines: Number of lines, including margins.*/ /* i_pitch: Number of bytes in a line, including margins. */ /* plane_t p:description of the planes */ /* p_pixels: Start of the plane's data. */ uint8_t *p_out1 = p_picture->p[1].p_pixels; int f, c; int ancho = p_picture->p[1].i_pitch; int alto = p_picture->p[1].i_lines; /* Plano U*/ for ( f = 0; f < alto; f++){ for( c = 0; c < ancho ; c++){ *p_out1++ = 0; } } return p_picture; } JNIEXPORT void JNICALL Java_org_videolan_vlc_gui_video_VirtualActivity_HolaMundo (JNIEnv *env, jobject obj, jstring javaString) { const char *nativeString = (*env)->GetStringUTFChars(env, javaString, 0); (*env)->ReleaseStringUTFChars(env, javaString, nativeString); }

Thanks!

Rémi Denis-Courmont
Developer
Developer
Posts: 15231
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vlc_filter.h - error: 'MODULE_STRING' undeclared

Postby Rémi Denis-Courmont » 24 Jun 2013 18:05

The answer is on the page. In bold.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

gmv
Blank Cone
Blank Cone
Posts: 15
Joined: 18 Feb 2013 18:46

Re: vlc_filter.h - error: 'MODULE_STRING' undeclared

Postby gmv » 25 Jun 2013 15:08

Hi,
Sorry to bother you so much, but I do not know how to use this guide and i'm desperate.
I've tried to modify the picture.c file, but the errors persist.

Please, can you help me?

Code: Select all

/***************************************************************************** * picture.c : picture management functions ***************************************************************************** * Copyright (C) 2000-2010 VLC authors and VideoLAN * Copyright (C) 2009-2010 Laurent Aimar * $Id: d90748c435233770cd725fd8c2249eee54fa93c2 $ * * Authors: Vincent Seguin <seguin@via.ecp.fr> * Samuel Hocevar <sam@zoy.org> * Laurent Aimar <fenrir _AT_ videolan _DOT_ org> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <assert.h> [b]#define DOMAIN "vlc-myplugin" #define _(str) dgettext(DOMAIN, str) #define N_(str) (str)[/b] #include <stdlib.h> /* VLC core API headers */ #include <vlc_common.h> #include <vlc_plugin.h> #include <vlc_interface.h> #include <vlc_picture.h> #include <vlc_image.h> #include <vlc_block.h> #include <vlc_atomic.h> #include <vlc/vlc.h> #include <vlc_common.h> #include <vlc_url.h> #include <vlc_fourcc.h> #include <jni.h> #include <math.h> #include <android/log.h> #include "org_videolan_vlc_gui_video_VirtualActivity_DepthTestSurfaceView.h" #include "org_videolan_vlc_gui_video_VirtualActivity.h" [b]#define MODULE_STRING "picture"[/b] /* Forward declarations */ static int AllocatePicture( picture_t *p_pic,vlc_fourcc_t i_chroma,int i_width, int i_height,int i_sar_num, int i_sar_den ); static void PictureDestroy( picture_t *p_picture ); void picture_Reset( picture_t *p_picture ); static int LCM( int a, int b ); int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma,int i_width, int i_height, int i_sar_num, int i_sar_den ); picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_resource_t *p_resource ); picture_t *picture_NewFromFormat( const video_format_t *p_fmt ); picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ); picture_t *picture_Hold( picture_t *p_picture ); void picture_Release( picture_t *p_picture ); bool picture_IsReferenced( picture_t *p_picture ); void plane_CopyPixels( plane_t *p_dst, const plane_t *p_src ); void picture_CopyProperties( picture_t *p_dst, const picture_t *p_src ); void picture_Copy( picture_t *p_dst, const picture_t *p_src ); int picture_Export( vlc_object_t *p_obj, block_t **pp_image, video_format_t *p_fmt, picture_t *p_picture, vlc_fourcc_t i_format, int i_override_width, int i_override_height ); void picture_BlendSubpicture(picture_t *dst,filter_t *blend, subpicture_t *src); picture_t *picture_FiltroColor( picture_t *p_picture ); JNIEXPORT void JNICALL Java_org_videolan_vlc_gui_video_VirtualActivity_HolaMundo (JNIEnv *env, jobject obj, jstring javaString); /* Module descriptor */ [b]vlc_module_begin() set_text_domain (DOMAIN) set_description (N_("picture")) vlc_module_end ()[/b] /** * Allocate a new picture in the heap. * * This function allocates a fake direct buffer in memory, which can be * used exactly like a video buffer. The video output thread then manages * how it gets displayed. */ static int AllocatePicture( picture_t *p_pic, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) { /* Make sure the real dimensions are a multiple of 16 */ if( picture_Setup( p_pic, i_chroma, i_width, i_height, i_sar_num, i_sar_den ) != VLC_SUCCESS ) return VLC_EGENERIC; /* Calculate how big the new image should be */ size_t i_bytes = 0; int i; for( i = 0; i < p_pic->i_planes; i++ ) { const plane_t *p = &p_pic->p[i]; if( p->i_pitch <= 0 || p->i_lines <= 0 || (size_t)p->i_pitch > (SIZE_MAX - i_bytes)/p->i_lines ) { p_pic->i_planes = 0; return VLC_ENOMEM; } i_bytes += p->i_pitch * p->i_lines; } uint8_t *p_data = vlc_memalign( 16, i_bytes ); if( !p_data ) { p_pic->i_planes = 0; return VLC_EGENERIC; } p_pic->gc.p_sys = (void *)p_data; /* Fill the p_pixels field for each plane */ p_pic->p[0].p_pixels = p_data; for( i = 1; i < p_pic->i_planes; i++ ) { p_pic->p[i].p_pixels = &p_pic->p[i-1].p_pixels[ p_pic->p[i-1].i_lines * p_pic->p[i-1].i_pitch ]; } return VLC_SUCCESS; } /***************************************************************************** * *****************************************************************************/ static void PictureDestroy( picture_t *p_picture ) { assert( p_picture && vlc_atomic_get( &p_picture->gc.refcount ) == 0 ); free( p_picture->p_q ); vlc_free( p_picture->gc.p_sys ); free( p_picture->p_sys ); free( p_picture ); } /***************************************************************************** * *****************************************************************************/ void picture_Reset( picture_t *p_picture ) { /* */ p_picture->date = VLC_TS_INVALID; p_picture->b_force = false; p_picture->b_progressive = false; p_picture->i_nb_fields = 2; p_picture->b_top_field_first = false; free( p_picture->p_q ); p_picture->p_q = NULL; p_picture->i_qstride = 0; p_picture->i_qtype = 0; } /***************************************************************************** * *****************************************************************************/ static int LCM( int a, int b ) { return a * b / GCD( a, b ); } int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) { /* Store default values */ p_picture->i_planes = 0; unsigned i; for( i = 0; i < VOUT_MAX_PLANES; i++ ) { plane_t *p = &p_picture->p[i]; p->p_pixels = NULL; p->i_pixel_pitch = 0; } vlc_atomic_set( &p_picture->gc.refcount, 0 ); p_picture->gc.pf_destroy = NULL; p_picture->gc.p_sys = NULL; p_picture->i_nb_fields = 2; p_picture->i_qtype = QTYPE_NONE; p_picture->i_qstride = 0; p_picture->p_q = NULL; video_format_Setup( &p_picture->format, i_chroma, i_width, i_height, i_sar_num, i_sar_den ); const vlc_chroma_description_t *p_dsc = vlc_fourcc_GetChromaDescription( p_picture->format.i_chroma ); if( !p_dsc ) return VLC_EGENERIC; /* We want V (width/height) to respect: (V * p_dsc->p[i].w.i_num) % p_dsc->p[i].w.i_den == 0 (V * p_dsc->p[i].w.i_num/p_dsc->p[i].w.i_den * p_dsc->i_pixel_size) % 16 == 0 Which is respected if you have V % lcm( p_dsc->p[0..planes].w.i_den * 16) == 0 */ int i_modulo_w = 1; int i_modulo_h = 1; unsigned int i_ratio_h = 1; for( i = 0; i < p_dsc->plane_count; i++ ) { i_modulo_w = LCM( i_modulo_w, 16 * p_dsc->p[i].w.den ); i_modulo_h = LCM( i_modulo_h, 16 * p_dsc->p[i].h.den ); if( i_ratio_h < p_dsc->p[i].h.den ) i_ratio_h = p_dsc->p[i].h.den; } i_modulo_h = LCM( i_modulo_h, 32 ); const int i_width_aligned = ( i_width + i_modulo_w - 1 ) / i_modulo_w * i_modulo_w; const int i_height_aligned = ( i_height + i_modulo_h - 1 ) / i_modulo_h * i_modulo_h; const int i_height_extra = 2 * i_ratio_h; /* This one is a hack for some ASM functions */ for( i = 0; i < p_dsc->plane_count; i++ ) { plane_t *p = &p_picture->p[i]; p->i_lines = (i_height_aligned + i_height_extra ) * p_dsc->p[i].h.num / p_dsc->p[i].h.den; p->i_visible_lines = i_height * p_dsc->p[i].h.num / p_dsc->p[i].h.den; p->i_pitch = i_width_aligned * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size; p->i_visible_pitch = i_width * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size; p->i_pixel_pitch = p_dsc->pixel_size; assert( (p->i_pitch % 16) == 0 ); } p_picture->i_planes = p_dsc->plane_count; return VLC_SUCCESS; } /***************************************************************************** * *****************************************************************************/ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_resource_t *p_resource ) { video_format_t fmt = *p_fmt; /* It is needed to be sure all information are filled */ video_format_Setup( &fmt, p_fmt->i_chroma, p_fmt->i_width, p_fmt->i_height, p_fmt->i_sar_num, p_fmt->i_sar_den ); if( p_fmt->i_x_offset < p_fmt->i_width && p_fmt->i_y_offset < p_fmt->i_height && p_fmt->i_visible_width > 0 && p_fmt->i_x_offset + p_fmt->i_visible_width <= p_fmt->i_width && p_fmt->i_visible_height > 0 && p_fmt->i_y_offset + p_fmt->i_visible_height <= p_fmt->i_height ) video_format_CopyCrop( &fmt, p_fmt ); /* */ picture_t *p_picture = calloc( 1, sizeof(*p_picture) ); if( !p_picture ) return NULL; if( p_resource ) { if( picture_Setup( p_picture, fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_sar_num, fmt.i_sar_den ) ) { free( p_picture ); return NULL; } p_picture->p_sys = p_resource->p_sys; assert( p_picture->gc.p_sys == NULL ); int i ; for( i = 0; i < p_picture->i_planes; i++ ) { p_picture->p[i].p_pixels = p_resource->p[i].p_pixels; p_picture->p[i].i_lines = p_resource->p[i].i_lines; p_picture->p[i].i_pitch = p_resource->p[i].i_pitch; } } else { if( AllocatePicture( p_picture, fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_sar_num, fmt.i_sar_den ) ) { free( p_picture ); return NULL; } assert( p_picture->gc.p_sys != NULL ); } /* */ p_picture->format = fmt; vlc_atomic_set( &p_picture->gc.refcount, 1 ); p_picture->gc.pf_destroy = PictureDestroy; return p_picture; } picture_t *picture_NewFromFormat( const video_format_t *p_fmt ) { return picture_NewFromResource( p_fmt, NULL ); } picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) { video_format_t fmt; memset( &fmt, 0, sizeof(fmt) ); video_format_Setup( &fmt, i_chroma, i_width, i_height, i_sar_num, i_sar_den ); return picture_NewFromFormat( &fmt ); } /***************************************************************************** * *****************************************************************************/ picture_t *picture_Hold( picture_t *p_picture ) { vlc_atomic_inc( &p_picture->gc.refcount ); return p_picture; } void picture_Release( picture_t *p_picture ) { if( vlc_atomic_dec( &p_picture->gc.refcount ) == 0 && p_picture->gc.pf_destroy ) p_picture->gc.pf_destroy( p_picture ); } bool picture_IsReferenced( picture_t *p_picture ) { return vlc_atomic_get( &p_picture->gc.refcount ) > 1; } /***************************************************************************** * *****************************************************************************/ void plane_CopyPixels( plane_t *p_dst, const plane_t *p_src ) { const unsigned i_width = __MIN( p_dst->i_visible_pitch, p_src->i_visible_pitch ); const unsigned i_height = __MIN( p_dst->i_visible_lines, p_src->i_visible_lines ); /* The 2x visible pitch check does two things: 1) Makes field plane_t's work correctly (see the deinterlacer module) 2) Moves less data if the pitch and visible pitch differ much. */ if( p_src->i_pitch == p_dst->i_pitch && p_src->i_pitch < 2*p_src->i_visible_pitch ) { /* There are margins, but with the same width : perfect ! */ memcpy( p_dst->p_pixels, p_src->p_pixels, p_src->i_pitch * i_height ); } else { /* We need to proceed line by line */ uint8_t *p_in = p_src->p_pixels; uint8_t *p_out = p_dst->p_pixels; int i_line; assert( p_in ); assert( p_out ); for( i_line = i_height; i_line--; ) { memcpy( p_out, p_in, i_width ); p_in += p_src->i_pitch; p_out += p_dst->i_pitch; } } } void picture_CopyProperties( picture_t *p_dst, const picture_t *p_src ) { p_dst->date = p_src->date; p_dst->b_force = p_src->b_force; p_dst->b_progressive = p_src->b_progressive; p_dst->i_nb_fields = p_src->i_nb_fields; p_dst->b_top_field_first = p_src->b_top_field_first; /* FIXME: copy ->p_q and ->p_qstride */ } void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src ) { int i; for( i = 0; i < p_src->i_planes ; i++ ) plane_CopyPixels( p_dst->p+i, p_src->p+i ); } void picture_Copy( picture_t *p_dst, const picture_t *p_src ) { picture_CopyPixels( p_dst, p_src ); picture_CopyProperties( p_dst, p_src ); } /***************************************************************************** * *****************************************************************************/ int picture_Export( vlc_object_t *p_obj, block_t **pp_image, video_format_t *p_fmt, picture_t *p_picture, vlc_fourcc_t i_format, int i_override_width, int i_override_height ) { /* */ video_format_t fmt_in = p_picture->format; if( fmt_in.i_sar_num <= 0 || fmt_in.i_sar_den <= 0 ) { fmt_in.i_sar_num = fmt_in.i_sar_den = 1; } /* */ video_format_t fmt_out; memset( &fmt_out, 0, sizeof(fmt_out) ); fmt_out.i_sar_num = fmt_out.i_sar_den = 1; fmt_out.i_chroma = i_format; /* compute original width/height */ unsigned int i_original_width; unsigned int i_original_height; if( fmt_in.i_sar_num >= fmt_in.i_sar_den ) { i_original_width = (int64_t)fmt_in.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den; i_original_height = fmt_in.i_height; } else { i_original_width = fmt_in.i_width; i_original_height = (int64_t)fmt_in.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num; } /* */ fmt_out.i_width = ( i_override_width < 0 ) ? i_original_width : (unsigned)i_override_width; fmt_out.i_height = ( i_override_height < 0 ) ? i_original_height : (unsigned)i_override_height; /* scale if only one direction is provided */ if( fmt_out.i_height == 0 && fmt_out.i_width > 0 ) { fmt_out.i_height = fmt_in.i_height * fmt_out.i_width * fmt_in.i_sar_den / fmt_in.i_width / fmt_in.i_sar_num; } else if( fmt_out.i_width == 0 && fmt_out.i_height > 0 ) { fmt_out.i_width = fmt_in.i_width * fmt_out.i_height * fmt_in.i_sar_num / fmt_in.i_height / fmt_in.i_sar_den; } image_handler_t *p_image = image_HandlerCreate( p_obj ); block_t *p_block = image_Write( p_image, p_picture, &fmt_in, &fmt_out ); image_HandlerDelete( p_image ); if( !p_block ) return VLC_EGENERIC; p_block->i_pts = p_block->i_dts = p_picture->date; if( p_fmt ) *p_fmt = fmt_out; *pp_image = p_block; return VLC_SUCCESS; } void picture_BlendSubpicture(picture_t *dst, filter_t *blend, subpicture_t *src) { assert(src && !src->b_fade && src->b_absolute); subpicture_region_t *r; for ( r = src->p_region; r != NULL; r = r->p_next) { assert(r->p_picture && r->i_align == 0); if (filter_ConfigureBlend(blend, dst->format.i_width, dst->format.i_height, &r->fmt) || filter_Blend(blend, dst, r->i_x, r->i_y, r->p_picture, src->i_alpha * r->i_alpha / 255)) { return; msg_Err(blend, "blending %4.4s to %4.4s failed", (char *)&blend->fmt_in.video.i_chroma, (char *)&blend->fmt_out.video.i_chroma ); } } } picture_t *picture_FiltroColor( picture_t *p_picture ){ /* i_lines: Number of lines, including margins.*/ /* i_pitch: Number of bytes in a line, including margins. */ /* int i_visible_lines: How many visible lines are there ? */ /* int i_visible_pitch: How many visible pixels are there ? */ /* plane_t p:description of the planes */ /* p_pixels: Start of the plane's data. */ /*uint8_t *p_out0 = p_picture->p[0].p_pixels;*/ uint8_t *p_out1 = p_picture->p[1].p_pixels; /*uint8_t *p_out2 = p_picture->p[2].p_pixels;*/ /* A UINT8 is an 8-bit unsigned integer (range: 0 through 255 decimal)*/ int f, c; /*int ancho_l = p_picture->p[0].i_pitch; int alto_l = p_picture->p[0].i_lines;*/ int ancho = p_picture->p[1].i_pitch; int alto = p_picture->p[1].i_lines; /* Plano de luminancia Y */ /*for ( i = 0; i < alto_l; i++){ for( j = 0; j < ancho_l; j++){ *p_out0++ = 0; } }*/ /* Plano U*/ for ( f = 0; f < alto; f++){ for( c = 0; c < ancho ; c++){ *p_out1++ = 0; } } /* Plano V */ /*for ( i = 0; i < alto; i++){ for( j = 0; j < ancho ; j++){ *p_out2++ = 0; } }*/ return p_picture; } /* void *picture_sintetica( picture_t *p_picture ){ int ancho_l = p_picture->p[0].i_pitch; int alto_l = p_picture->p[0].i_lines; int ancho = p_picture->p[1].i_pitch; int alto = p_picture->p[1].i_lines; int i, j; int array_color_Y[alto_l][ancho_l/2]; int array_color_U[alto][ancho/2]; int array_color_V[alto][ancho/2]; int array_depth_Y[alto_l][ancho_l/2]; int array_depth_U[alto][ancho/2]; int array_depth_V[alto][ancho/2]; int array_out_Y[alto_l][ancho_l/2]; uint8_t *p_out0 = p_picture->p[0].p_pixels; uint8_t *p_out1 = p_picture->p[1].p_pixels; uint8_t *p_out2 = p_picture->p[2].p_pixels;*/ /* Imagen de color */ /*for ( i= 0; i< alto_l;i++){ for( j = 0; j<ancho_l/2; j++){ array_color_Y[i][j] = *p_out0++; } }*/ /*for ( i= 0; i< alto;i++){ for( j = 0; j<ancho/2; j++){ array_color_U[i][j] = *p_out1++ ; } } for ( i= 0; i< alto;i++){ for( j = 0; j<ancho/2; j++){ array_color_V[i][j] = *p_out2++ ; } }*/ /* Imagen de profundidad*/ /*for ( i= 0; i< alto_l;i++){ for( j = ancho_l/2; j<ancho_l; j++){ array_depth_Y[i][j] = *p_out0++; } }*/ /*for ( i= 0; i< alto_l;i++){ for( j = ancho/2; j<ancho; j++){ array_depth_U[i][j] = *p_out1++ ; } } for ( i= 0; i< alto_l;i++){ for( j = ancho/2; j<ancho; j++){ array_depth_V[i][j] = *p_out2++ ; } } JNIEXPORT jboolean JNICALL Java_org_videolan_vlc_gui_video_VirtualActivity_VirtualJNI(ancho_l, alto_l, array_color_Y, array_depth_Y, array_out_Y); }*/ JNIEXPORT void JNICALL Java_org_videolan_vlc_gui_video_VirtualActivity_HolaMundo (JNIEnv *env, jobject obj, jstring javaString) { const char *nativeString = (*env)->GetStringUTFChars(env, javaString, 0); (*env)->ReleaseStringUTFChars(env, javaString, nativeString); }
i haven't got any example of use and i don't know if i have to follow all the guidelines or it is sufficient with those changes, althoug they well implemented.

Thanks so much!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests