EGLImage y_egl_image, cbcr_egl_image;
// Only if use_zerocopy == false.
- RefCountedGLsync readback_done_fence;
GLuint pbo;
uint8_t *y_ptr, *cbcr_ptr;
size_t y_offset, cbcr_offset;
if (support_encode == 0) {
printf("Can't find VAEntrypointEncSlice for H264 profiles. If you are using a non-Intel GPU\n");
- printf("but have one in your system, try launching Nageru with --va-display /dev/dri/card0\n");
+ printf("but have one in your system, try launching Nageru with --va-display /dev/dri/renderD128\n");
printf("to use VA-API against DRM instead of X11.\n");
exit(1);
} else {
glBindBuffer(GL_PIXEL_PACK_BUFFER, gl_surfaces[i].pbo);
glBufferStorage(GL_PIXEL_PACK_BUFFER, frame_width * frame_height * 2, nullptr, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
uint8_t *ptr = (uint8_t *)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, frame_width * frame_height * 2, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
- gl_surfaces[i].y_ptr = ptr;
- gl_surfaces[i].cbcr_ptr = ptr + frame_width * frame_height;
gl_surfaces[i].y_offset = 0;
gl_surfaces[i].cbcr_offset = frame_width * frame_height;
+ gl_surfaces[i].y_ptr = ptr + gl_surfaces[i].y_offset;
+ gl_surfaces[i].cbcr_ptr = ptr + gl_surfaces[i].cbcr_offset;
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
}
}
pending_audio_frames.erase(it);
}
- AVFrame *frame = avcodec_alloc_frame();
+ AVFrame *frame = av_frame_alloc();
frame->nb_samples = audio.size() / 2;
frame->format = AV_SAMPLE_FMT_S32;
frame->channel_layout = AV_CH_LAYOUT_STEREO;
httpd->add_packet(pkt, audio_pts + global_delay, audio_pts + global_delay);
}
// TODO: Delayed frames.
- avcodec_free_frame(&frame);
+ av_frame_unref(frame);
av_free_packet(&pkt);
if (audio_pts == task.pts) break;
}
int frame_type, int64_t pts, int64_t dts)
{
// Wait for the GPU to be done with the frame.
- glClientWaitSync(frame.fence.get(), 0, 0);
+ GLenum sync_status;
+ do {
+ sync_status = glClientWaitSync(frame.fence.get(), 0, 1000000000);
+ check_error();
+ } while (sync_status == GL_TIMEOUT_EXPIRED);
+ assert(sync_status != GL_WAIT_FAILED);
// Release back any input frames we needed to render this frame.
frame.input_frames.clear();
unsigned char *surface_p = nullptr;
vaMapBuffer(va_dpy, surf->surface_image.buf, (void **)&surface_p);
- unsigned char *y_ptr = (unsigned char *)surface_p + surf->surface_image.offsets[0];
- memcpy_with_pitch(y_ptr, surf->y_ptr, frame_width, surf->surface_image.pitches[0], frame_height);
+ unsigned char *va_y_ptr = (unsigned char *)surface_p + surf->surface_image.offsets[0];
+ memcpy_with_pitch(va_y_ptr, surf->y_ptr, frame_width, surf->surface_image.pitches[0], frame_height);
- unsigned char *cbcr_ptr = (unsigned char *)surface_p + surf->surface_image.offsets[1];
- memcpy_with_pitch(cbcr_ptr, surf->cbcr_ptr, (frame_width / 2) * sizeof(uint16_t), surf->surface_image.pitches[1], frame_height / 2);
+ unsigned char *va_cbcr_ptr = (unsigned char *)surface_p + surf->surface_image.offsets[1];
+ memcpy_with_pitch(va_cbcr_ptr, surf->cbcr_ptr, (frame_width / 2) * sizeof(uint16_t), surf->surface_image.pitches[1], frame_height / 2);
va_status = vaUnmapBuffer(va_dpy, surf->surface_image.buf);
CHECK_VASTATUS(va_status, "vaUnmapBuffer");