while ( (av_read_frame(pFormatCtx_l, &packet_l)>=0) && (av_read_frame(pFormatCtx_r, &packet_r)>=0) ) {
if ( (packet_l.stream_index == videoStream_l) && (packet_r.stream_index == videoStream_r) ) {
// Decode video frame
avcodec_decode_video(pCodecCtx_l, pFrame_l, &frameFinished_l, packet_l.data, packet_l.size);
avcodec_decode_video(pCodecCtx_r, pFrame_r, &frameFinished_r, packet_r.data, packet_r.size);
// Did we get a video frame?
if ( (frameFinished_l) && (frameFinished_r) )
{
img_convert( (AVPicture *) pFrameRGB_l, PIX_FMT_BGR24, (AVPicture*)pFrame_l,
pCodecCtx_l->pix_fmt, pCodecCtx_l->width, pCodecCtx_l->height);
img_convert( (AVPicture *) pFrameRGB_r, PIX_FMT_BGR24, (AVPicture*)pFrame_r,
pCodecCtx_r->pix_fmt, pCodecCtx_r->width, pCodecCtx_r->height);
// Write pixel data
for(ay=0; ay<img_h; ay++)
{
memcpy(aux_l, pFrameRGB_l->data[0]+ay*pFrameRGB_l->linesize[0], ancho);
memcpy(aux_r, pFrameRGB_r->data[0]+ay*pFrameRGB_r->linesize[0], ancho);
// incrementar data_l, data_r para recorrer la imagen nueva e irla generando
aux_l += ancho;
aux_r += ancho;
}
img_raw_set_data (img_l, data_l);
img_raw_set_data (img_r, data_r);
data32_l = RGB24toARGB(img_l);
data32_r = RGB24toARGB(img_r);
qimg_l
= QImage(data32_l, img_w, img_h,
QImage::Format_RGB32);
qimg_r
= QImage(data32_r, img_w, img_h,
QImage::Format_RGB32);
leftLabel
->setPixmap
(QPixmap::fromImage(qimg_l
));
rightLabel
->setPixmap
(QPixmap::fromImage(qimg_r
));
}
aux_l = data_l;
aux_r = data_r;
}
while ( (av_read_frame(pFormatCtx_l, &packet_l)>=0) && (av_read_frame(pFormatCtx_r, &packet_r)>=0) ) {
if ( (packet_l.stream_index == videoStream_l) && (packet_r.stream_index == videoStream_r) ) {
// Decode video frame
avcodec_decode_video(pCodecCtx_l, pFrame_l, &frameFinished_l, packet_l.data, packet_l.size);
avcodec_decode_video(pCodecCtx_r, pFrame_r, &frameFinished_r, packet_r.data, packet_r.size);
// Did we get a video frame?
if ( (frameFinished_l) && (frameFinished_r) )
{
img_convert( (AVPicture *) pFrameRGB_l, PIX_FMT_BGR24, (AVPicture*)pFrame_l,
pCodecCtx_l->pix_fmt, pCodecCtx_l->width, pCodecCtx_l->height);
img_convert( (AVPicture *) pFrameRGB_r, PIX_FMT_BGR24, (AVPicture*)pFrame_r,
pCodecCtx_r->pix_fmt, pCodecCtx_r->width, pCodecCtx_r->height);
// Write pixel data
for(ay=0; ay<img_h; ay++)
{
memcpy(aux_l, pFrameRGB_l->data[0]+ay*pFrameRGB_l->linesize[0], ancho);
memcpy(aux_r, pFrameRGB_r->data[0]+ay*pFrameRGB_r->linesize[0], ancho);
// incrementar data_l, data_r para recorrer la imagen nueva e irla generando
aux_l += ancho;
aux_r += ancho;
}
img_raw_set_data (img_l, data_l);
img_raw_set_data (img_r, data_r);
data32_l = RGB24toARGB(img_l);
data32_r = RGB24toARGB(img_r);
qimg_l = QImage(data32_l, img_w, img_h, QImage::Format_RGB32);
qimg_r = QImage(data32_r, img_w, img_h, QImage::Format_RGB32);
leftLabel->setPixmap(QPixmap::fromImage(qimg_l));
rightLabel->setPixmap(QPixmap::fromImage(qimg_r));
}
aux_l = data_l;
aux_r = data_r;
}
To copy to clipboard, switch view to plain text mode
Bookmarks