I am passing the data and linesize of the raw frame as source and the same for the destination (scaled_ip_frame's data and linesize). These are arrays by definition, aren't they? In all, I am passing the raw frame's data and linesize, 0, and the scaled frame's data and linesize to the functions. I got this from various examples I have looked at and it seems to work for others, but not me!
-----Mensaje original----- De: [email protected] [mailto:[email protected]] En nombre de Glen Ruedinger Enviado el: lunes, 02 de agosto de 2010 16:00 Para: Libav* user questions and discussions Asunto: Re: [libav-user] sws_scale problem! Green screen means that you got all zeros. You would think all zeros would give you black, but due to the color space(YUV) zeros map to green. SWS_SCALE wants an array of pointers to source and destination data, I don't see that you are passing an array for either. Might want to check that. On Mon, Aug 2, 2010 at 8:12 AM, Candice Seenyen <[email protected]>wrote: > Hi again! > > Scratch my last email, it's still not working with srcSLiceY=0. I am saving > the scaled frame into an AVFrame that has been initialized. Here is the > code > I am using. I really don't understand why it is not working. The video > display class then access the destFrame buffer to display the video image > (which actually gives me only a green screen, still don't know why). > > PBoolean PVideoInputDevice_IPCamera::GetFrameDataNoDelay(BYTE *destFrame, > PINDEX * bytesReturned) > { > int frame_finished; > struct SwsContext *img_convert_ctx; > av_init_packet(&pckt); > > m_grabCount++; > > if (!is_open) > return PFalse; > > BYTE * readBuffer = destFrame; > > if (converter != NULL) > { > readBuffer = frameStore.GetPointer(ip_frame_size); > } > > int x = av_read_frame(ip_context, &pckt); // Gets the next frame in > the stream > > if(pckt.stream_index == video_stream) > { > int decode = avcodec_decode_video2(ip_codec_context, > raw_ip_frame, &frame_finished, &pckt); > if(raw_ip_frame->data == NULL) > PTRACE(1, "problem with raw_ip_frame. IT'S NULL"); > > if(frame_finished) > { > int w = ip_codec_context->width; > int h = ip_codec_context->height; > img_convert_ctx = sws_getContext(w, h, > ip_codec_context->pix_fmt, > w, h, PIX_FMT_RGB32, SWS_BICUBIC, NULL, > NULL, NULL); > > if(img_convert_ctx == NULL) > { > return PFalse; > } > > > if(img_convert_ctx == NULL) > { > PTRACE(1, "Conversion context not initialized"); > return PFalse; > } > > int scaled = sws_scale(img_convert_ctx, raw_ip_frame->data, > raw_ip_frame->linesize, 0, <---- THIS IS WHERE THE CRASH OCCURS > ip_codec_context->height, scaled_ip_frame->data, > scaled_ip_frame->linesize); > > > memcpy(destFrame, scaled_ip_frame->data, pckt.size); > } > > else > { > memcpy(destFrame, pckt.data, pckt.size); > } > > if (converter == NULL) > { > PTRACE(1, "converter is NULL"); > if (bytesReturned != NULL) > *bytesReturned = ip_frame_size; > } > > else > { > PBoolean y = converter->SetSrcFrameSize(ip_frame_width, > ip_frame_height); > > if (!converter->Convert(readBuffer, destFrame, > bytesReturned)) > { > PTRACE(1, "problem converting it seems"); > return PFalse; > } > > if (bytesReturned != NULL) > { > *bytesReturned = converter->GetMaxDstFrameBytes(); > } > } > } > > av_free(img_convert_ctx); > av_free_packet(&pckt); > //av_free(raw_ip_frame); > //av_free(scaled_ip_frame); > > return PTrue; > } > v-user > > _______________________________________________ > libav-user mailing list > [email protected] > https://lists.mplayerhq.hu/mailman/listinfo/libav-user > _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
