Groups | Search | Server Info | Login | Register


Groups > comp.lang.c.moderated > #491

problem with parameters of swscale method

From cervello <eceoozmen@gmail.com>
Newsgroups comp.lang.c.moderated
Subject problem with parameters of swscale method
Date 2011-02-10 21:40 -0600
Organization http://groups.google.com
Message-ID <clcm-20110210-0001@plethora.net> (permalink)

Show all headers | View raw


ece@ubuntu:~/workspace/FFmpeg/jni$ /home/ece/ndk/ndk-build
Install        : libffmpeg.so => /home/ece/workspace/FFmpeg/libs/
armeabi
Compile thumb  : takepics <= /home/ece/workspace/FFmpeg/jni/
takepics.c
/home/ece/workspace/FFmpeg/jni/takepics.c: In function 'fill_image':
/home/ece/workspace/FFmpeg/jni/takepics.c:323: warning: passing
argument 2 of 'sws_scale' from incompatible pointer type
/home/ece/workspace/FFmpeg/jni/ffmpeg/libswscale/swscale.h:195: note:
expected 'const uint8_t * const*' but argument is of type 'uint8_t
**'
/home/ece/workspace/FFmpeg/jni/takepics.c: In function
'Java_com_test_Test_takePics':
/home/ece/workspace/FFmpeg/jni/takepics.c:634: warning: passing
argument 2 of 'sws_scale' from incompatible pointer type
/home/ece/workspace/FFmpeg/jni/ffmpeg/libswscale/swscale.h:195: note:
expected 'const uint8_t * const*' but argument is of type 'uint8_t
**'
SharedLibrary  : libtakepics.so
Install        : libtakepics.so => /home/ece/workspace/FFmpeg/libs/
armeabi

How can I fix that warnings? Does anyone know anything about it?
Thanks..

Here is the types of sws_scale's parameters
int sws_scale(SwsContext *c, const uint8_t* const src[], const int
srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* const dst[], const int
dstStride[])

My main code is here:


jint Java_com_test_Test_takePics(JNIEnv* env, jobject javaThis) {
	int framecount;
	log_message("Fonka girdi");
//OPENING FILE**************************************************
	AVFormatContext *pFormatCtx;
	unsigned char r, g, b;
	int i,j;

	char* filename = "/sdcard/do-beer-not-drugs.3gp";
	av_register_all();


	// Open video file
	if(av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0)
	  return -1; // Couldn't open file

	// Retrieve stream information
	if(av_find_stream_info(pFormatCtx)<0)
	  return -1; // Couldn't find stream information

	// Dump information about file onto standard error
	dump_format(pFormatCtx, 0, filename, 0);
	framecount = pFormatCtx->streams[0]->nb_frames;
	hist = malloc(framecount*sizeof(int*));

	    for (j = 0; j < framecount; ++j) {
			hist[j] = malloc(sizeof(int)*64); // this is because we use 64-bin
histogram
		}
	    for (i = 0; i < framecount; i++) {
	    	for (j = 0; j < 64; j++) {
				hist[i][j] = 0;
			}

	    }

	AVCodecContext *pCodecCtx;

	// Find the first video stream
	int videoStream;
	videoStream=-1;
	/*char info[40];
	sprintf(info,"i degeri = %d",pFormatCtx->nb_streams);
	log_message(info);*/
	for(i=0; i<pFormatCtx->nb_streams; i++){
	  if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
	    videoStream=i;
	    break;
	  }}


	if(videoStream==-1)
	  return -1; // Didn't find a video stream

	AVCodec *pCodec;

	// Find the decoder for the video stream
	pCodec=avcodec_find_decoder(CODEC_ID_H263);//pCodecCtx->codec_id


	if(pCodec==NULL) {
	  fprintf(stderr, "Unsupported codec!\n");
	  return -1; // Codec not found
	}
	//pCodecCtx = avcodec_alloc_context();
// Get a pointer to the codec context for the video stream
	pCodecCtx=pFormatCtx->streams[videoStream]->codec;
	// Open codec
	if(avcodec_open(pCodecCtx, pCodec)<0)
	  return -1; // Could not open codec



//STORING THE DATA************************************************

	AVFrame *pFrame;

	// Allocate video frame
	pFrame=avcodec_alloc_frame();

	// Allocate an AVFrame structure
	AVFrame         *pFrameRGB;
	pFrameRGB=avcodec_alloc_frame();

	if(pFrameRGB==NULL)
	  return -1;

	uint8_t *buffer;
	int numBytes;
	// Determine required buffer size and allocate buffer
	numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
		                    pCodecCtx->height);
	buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

	// Assign appropriate parts of buffer to image planes in pFrameRGB
	// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
	// of AVPicture
	avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
		        pCodecCtx->width, pCodecCtx->height);

//READING DATA***************************************************

	int frameFinished;
	AVPacket packet;
	log_message("aaa");
	i=0;
	while(av_read_frame(pFormatCtx, &packet)>=0) {
	  // Is this a packet from the video stream?
	  if(packet.stream_index==videoStream) {

		// Decode video frame
	    avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,
		                 &packet);

	    // Did we get a video frame?
	    if(frameFinished) {
		static struct SwsContext *img_convert_ctx;

					// Convert the image into RGB format
					if(img_convert_ctx == NULL) {
						int w = pCodecCtx->width;
						int h = pCodecCtx->height;

						img_convert_ctx = sws_getContext(w, h,
										pCodecCtx->pix_fmt,
										w, h, PIX_FMT_RGB24, SWS_BICUBIC,
										NULL, NULL, NULL);
						if(img_convert_ctx == NULL) {
							fprintf(stderr, "Cannot initialize the conversion context!\n");
							exit(1);
						}
					}
					int ret = sws_scale(img_convert_ctx, pFrame->data, pFrame-
>linesize, 0,
							  pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);

					for (j = 0; j < 3*pCodecCtx->height*pCodecCtx->width -3; j++) {
						                						r = (unsigned char) pFrameRGB->data[0][j];
						                						g = (unsigned char) pFrameRGB->data[0][j
+1];
						                						b = (unsigned char) pFrameRGB->data[0][j
+2];


						                						r = (unsigned char) ((r >> 2) & 0x30);
						                						g = (unsigned char) ((g >> 4) & 0x0C);
						                						b = (unsigned char) ((b >> 6) & 0x03);

						                						unsigned char h = (unsigned char)(r|g|b);
						                						hist[i][h]++;
					}log_message("aaa");

	                // Save the frame to sdcard
	                SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx-
>height, ++i);
	    }
	  }

	  // Free the packet that was allocated by av_read_frame
	  av_free_packet(&packet);
	}



	// Free the RGB image
	av_free(buffer);
	av_free(pFrameRGB);

	// Free the YUV frame
	av_free(pFrame);

	// Close the codec
	avcodec_close(pCodecCtx);

	// Close the video file
	av_close_input_file(pFormatCtx);


	int keyframecount;
	framecount=i;
	keyframecount = select_keyFrames(framecount);
	encodeVideo(env,keyframecount);
	return 0;

}
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

Back to comp.lang.c.moderated | Previous | Next | Find similar


Thread

problem with parameters of swscale method cervello <eceoozmen@gmail.com> - 2011-02-10 21:40 -0600

csiph-web