level 1
urtimee
楼主
MYLIBDLL uint8_t* DecodeOneFrame()
{
if (av_read_frame(pFormatCtx, packet) >= 0)
{
if (packet->stream_index == videoindex)
{
ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet);
//av_free_packet(packet);
if (ret < 0) {
printf("Decode Error.\n");
return NULL;
//break;
}
if (got_picture) {
sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height,
pFrameYUV->data, pFrameYUV->linesize);
y_size = pCodecCtx->width*pCodecCtx->height;
for (int j = 0;j < y_size / 4;j++)
{
int temp = *(pFrameYUV->data[1] + j);
*(pFrameYUV->data[1] + j) = *(pFrameYUV->data[2] + j);
*(pFrameYUV->data[2] + j) = temp;
}
av_free_packet(packet);
return pFrameYUV->data[0];
}
return NULL;
}
av_free_packet(packet);
}
为啥我在wpf中调用这个非托管的DLL解码这块运行一段时间后总报错,读取内存受保护什么的。。我的想法是通过这块获取解码之后的内存地址,然后在WPF中使用Timer。。每隔一段时间运行一下这个DLL函数。读取出来的数据直接显示。。请问大神,我的想法是不是错了?
2017年07月17日 10点07分
1
{
if (av_read_frame(pFormatCtx, packet) >= 0)
{
if (packet->stream_index == videoindex)
{
ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet);
//av_free_packet(packet);
if (ret < 0) {
printf("Decode Error.\n");
return NULL;
//break;
}
if (got_picture) {
sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height,
pFrameYUV->data, pFrameYUV->linesize);
y_size = pCodecCtx->width*pCodecCtx->height;
for (int j = 0;j < y_size / 4;j++)
{
int temp = *(pFrameYUV->data[1] + j);
*(pFrameYUV->data[1] + j) = *(pFrameYUV->data[2] + j);
*(pFrameYUV->data[2] + j) = temp;
}
av_free_packet(packet);
return pFrameYUV->data[0];
}
return NULL;
}
av_free_packet(packet);
}
为啥我在wpf中调用这个非托管的DLL解码这块运行一段时间后总报错,读取内存受保护什么的。。我的想法是通过这块获取解码之后的内存地址,然后在WPF中使用Timer。。每隔一段时间运行一下这个DLL函数。读取出来的数据直接显示。。请问大神,我的想法是不是错了?