크기 조절하는 부분이 맞기는한데..
void copyPixels(uint8_t *pixels) 에서 gPictureSize 로 디코딩된 데이터를 복사해가는데.
gPictureSize 가 원본 가로 x 세로로 설정하셨고,
또한 변환시 사용하는 gFrameRGB 의 사이즈도, 원본 사이즈로 mallioc 해 두었기 때문에, 오류가 난 것으로 추정됩니다.
아래 부분도 변환할 사이즈로 변경해 보세요..
gPictureSize = avpicture_get_size(PIX_FMT_RGB565LE, gVideoCodecCtx->width, gVideoCodecCtx->height);
gVideoBuffer = (uint8_t*)(malloc(sizeof(uint8_t) * gPictureSize));
avpicture_fill((AVPicture*)gFrameRGB, gVideoBuffer, PIX_FMT_RGB565LE, gVideoCodecCtx->width, gVideoCodecCtx->height);