mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-06-09 14:44:11 +02:00
Closes: https://bugs.gentoo.org/911179 Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
121 lines
3.4 KiB
Diff
121 lines
3.4 KiB
Diff
From 8504832e746b1581d5b51be7f04f24826440255f Mon Sep 17 00:00:00 2001
|
|
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
|
Date: Thu, 6 Jun 2024 15:59:51 +0200
|
|
Subject: [PATCH 1/2] use std namespace prefix
|
|
|
|
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
|
---
|
|
ng/encoding.hpp | 8 +++++++-
|
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/ng/encoding.hpp b/ng/encoding.hpp
|
|
index 9ea2ffb..498431c 100644
|
|
--- a/ng/encoding.hpp
|
|
+++ b/ng/encoding.hpp
|
|
@@ -16,6 +16,8 @@ extern "C" {
|
|
#include <libswresample/swresample.h>
|
|
}
|
|
|
|
+#include <iostream>
|
|
+
|
|
constexpr int BITRATE = 50000000;
|
|
|
|
class Mpeg {
|
|
@@ -55,6 +57,8 @@ class Mpeg {
|
|
int height;
|
|
bool IsStarted() { return is_started; }
|
|
int AddFrame() {
|
|
+ using std::cerr;
|
|
+ using std::endl;
|
|
int ret;
|
|
int got_packet = 0;
|
|
AVPacket pkt = { 0 };
|
|
@@ -113,7 +117,9 @@ class Mpeg {
|
|
return 0;
|
|
}
|
|
|
|
- int Start(string filename) {
|
|
+ int Start(std::string filename) {
|
|
+ using std::cerr;
|
|
+ using std::endl;
|
|
AVCodec *video_codec;
|
|
if(is_started) {
|
|
cerr << "Stream already started" << endl;
|
|
--
|
|
2.45.2
|
|
|
|
|
|
From 2e52e913603745670cfc5c4a461845a6fb22e118 Mon Sep 17 00:00:00 2001
|
|
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
|
Date: Thu, 6 Jun 2024 16:00:40 +0200
|
|
Subject: [PATCH 2/2] av_init_packet is deprecated
|
|
|
|
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
|
---
|
|
ng/encoding.hpp | 18 +++++++++++-------
|
|
1 file changed, 11 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/ng/encoding.hpp b/ng/encoding.hpp
|
|
index 498431c..97b9e6a 100644
|
|
--- a/ng/encoding.hpp
|
|
+++ b/ng/encoding.hpp
|
|
@@ -61,7 +61,6 @@ class Mpeg {
|
|
using std::endl;
|
|
int ret;
|
|
int got_packet = 0;
|
|
- AVPacket pkt = { 0 };
|
|
|
|
glReadPixels (0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, rgb_buffer);
|
|
av_image_fill_arrays(rgb_frame->data, rgb_frame->linesize, rgb_buffer, AV_PIX_FMT_RGB24, width, height, 1);
|
|
@@ -77,8 +76,6 @@ class Mpeg {
|
|
sws_scale(sws_ctx, flipped_data, flipped_stride, 0, enc->height, frame->data, frame->linesize);
|
|
|
|
|
|
- av_init_packet(&pkt);
|
|
-
|
|
got_packet = 0;
|
|
ret = avcodec_send_frame(enc, frame);
|
|
if (ret < 0)
|
|
@@ -87,28 +84,35 @@ class Mpeg {
|
|
return(1);
|
|
}
|
|
|
|
- ret = avcodec_receive_packet(enc, &pkt);
|
|
+ AVPacket* pkt = av_packet_alloc();
|
|
+ ret = avcodec_receive_packet(enc, pkt);
|
|
if (!ret)
|
|
got_packet = 1;
|
|
if (ret == AVERROR(EAGAIN))
|
|
+ {
|
|
+ av_packet_free(&pkt);
|
|
return 0;
|
|
+ }
|
|
|
|
if (ret < 0) {
|
|
cerr << "Error encoding video frame: " << endl;
|
|
+ av_packet_free(&pkt);
|
|
return 1;
|
|
}
|
|
|
|
if (got_packet) {
|
|
/* rescale output packet timestamp values from codec to stream timebase */
|
|
- av_packet_rescale_ts(&pkt, enc->time_base, st->time_base);
|
|
- pkt.stream_index = st->index;
|
|
+ av_packet_rescale_ts(pkt, enc->time_base, st->time_base);
|
|
+ pkt->stream_index = st->index;
|
|
|
|
/* Write the compressed frame to the media file. */
|
|
- ret = av_interleaved_write_frame(oc, &pkt);
|
|
+ ret = av_interleaved_write_frame(oc, pkt);
|
|
} else {
|
|
ret = 0;
|
|
}
|
|
|
|
+ av_packet_free(&pkt);
|
|
+
|
|
if (ret < 0) {
|
|
cerr << "Error while writing video frame: " << endl;
|
|
return(1);
|
|
--
|
|
2.45.2
|
|
|