shin_san
17th May 2006, 06:52
I take AVI frames and filter them. I want to write each frame in the same avi file, instead of the non-filtered ones. For that I use this code:
int read_frame_avis( x264_picture_t *p_pic, hnd_t handle, int i_frame )
{
avis_input_t *h = (avis_input_t *)handle;
PAVISTREAM pStream = h->p_avi;
PGETFRAME pFrame;
p_pic->img.i_csp = X264_CSP_YV12;
if( AVIStreamRead(pStream, i_frame, 1, p_pic->img.plane[0], h->width * h->height * 3 / 2, NULL, NULL ) )
return -1;
pFrame=AVIStreamGetFrameOpen(pStream, NULL);
BYTE* frame = (BYTE*) AVIStreamGetFrame(pFrame, i_frame);
AVIStreamGetFrameClose(pFrame);
frameFiltered = filter(frame);
printf("READ only error ?:%d\n",AVIStreamWrite(pStream,i_frame,1,frameFiltered,h->width * h->height * 3 / 2,AVIIF_KEYFRAME,NULL,NULL));
return 0;
}
My problem is that AVIStreamWrite(...) generate a READONLY error
Anybody know why? Thank in advance.
int read_frame_avis( x264_picture_t *p_pic, hnd_t handle, int i_frame )
{
avis_input_t *h = (avis_input_t *)handle;
PAVISTREAM pStream = h->p_avi;
PGETFRAME pFrame;
p_pic->img.i_csp = X264_CSP_YV12;
if( AVIStreamRead(pStream, i_frame, 1, p_pic->img.plane[0], h->width * h->height * 3 / 2, NULL, NULL ) )
return -1;
pFrame=AVIStreamGetFrameOpen(pStream, NULL);
BYTE* frame = (BYTE*) AVIStreamGetFrame(pFrame, i_frame);
AVIStreamGetFrameClose(pFrame);
frameFiltered = filter(frame);
printf("READ only error ?:%d\n",AVIStreamWrite(pStream,i_frame,1,frameFiltered,h->width * h->height * 3 / 2,AVIIF_KEYFRAME,NULL,NULL));
return 0;
}
My problem is that AVIStreamWrite(...) generate a READONLY error
Anybody know why? Thank in advance.