~emersion/vaapi-decoder

8c32666f3773004b11c5df202341b8393a91a184 — Simon Ser 9 months ago a5437e1 kms
hacks
1 files changed, 21 insertions(+), 3 deletions(-)

M main.c
M main.c => main.c +21 -3
@@ 67,6 67,8 @@ static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,
	return AV_PIX_FMT_NONE;
}

static uint32_t conn_id = 0;

static uint32_t pick_crtc(int drm_fd) {
	drmModeRes *res = drmModeGetResources(drm_fd);
	if (!res) {


@@ 92,6 94,8 @@ static uint32_t pick_crtc(int drm_fd) {
		return 0;
	}

	conn_id = conn->connector_id;

	drmModeFreeResources(res);

	drmModeEncoder *enc = drmModeGetEncoder(drm_fd, conn->encoder_id);


@@ 316,6 320,8 @@ int main(int argc, char *argv[]) {
		return 1;
	}

	while (1) {

	AVFrame *frame = NULL;
	ret = decode_frame(input_ctx, video_stream, decoder_ctx, &frame);
	if (ret < 0) {


@@ 344,17 350,29 @@ int main(int argc, char *argv[]) {
		return 1;
	}

	ret = drmModePageFlip(drm_fd, crtc_id, fb_id, 0, NULL);
	drmModeCrtc *crtc = drmModeGetCrtc(drm_fd, crtc_id);
	if (!crtc->mode_valid) {
		fprintf(stderr, "No mode set\n");
		return 1;
	}

	static bool first = true;
	if (first) {
		ret = drmModeSetCrtc(drm_fd, crtc_id, fb_id, 0, 0, &conn_id, 1, &crtc->mode);
	} else {
		ret = drmModePageFlip(drm_fd, crtc_id, fb_id, 0, NULL);
	}
	if (ret < 0) {
		perror("drmModePageFlip");
		return 1;
	}

	sleep(5);

	av_frame_free(&drm_frame);
	av_frame_free(&frame);

	//usleep(16);
	}

	avcodec_free_context(&decoder_ctx);
	avformat_close_input(&input_ctx);
	av_buffer_unref(&hw_device_ctx);