Skip to content

Commit 4c38f57

Browse files
committed
Refactor: Move the TCP scripts to home directory
1 parent 9a95df6 commit 4c38f57

File tree

11 files changed

+15
-1084
lines changed

11 files changed

+15
-1084
lines changed

decoder.cpp

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ bool quicsy_decoder_open(decoder_t* dec, const char* filename) {
4444
log("finding the proper decoder (CODEC)");
4545

4646
av_codec = avcodec_find_decoder(av_codec_params->codec_id);
47-
if (av_codec == NULL) {
48-
err_log("CODEC: couldn't find proper decoder");
49-
break;
47+
if (!av_codec) {
48+
continue;
5049
}
5150
if (av_codec_params->codec_type == AVMEDIA_TYPE_VIDEO) {
5251
video_stream_index = i;
@@ -108,24 +107,9 @@ bool quicsy_decoder_read_frame(decoder_t* dec, uint8_t* frame_buffer, int64_t* p
108107
auto& sws_scaler_ctx = dec->sws_scaler_ctx;
109108

110109
// Decode one frame
111-
int response;
112-
bool finished = false;
113-
114-
while (!finished)
115-
{
116-
if (response = (av_read_frame(av_format_ctx, av_packet)) < 0)
117-
{
118-
if (response == AVERROR_EOF)
119-
{
120-
finished = true;
121-
}
122-
else
123-
{
124-
exit(0);
125-
}
126-
}
127-
128-
if (av_packet->stream_index != video_stream_index) {
110+
int response;
111+
while (av_read_frame(av_format_ctx, av_packet) >= 0) {
112+
if (av_packet->stream_index != video_stream_index) {
129113
log("AVPacket->pts %" PRId64, av_packet->pts);
130114
av_packet_unref(av_packet);
131115
continue;
@@ -142,27 +126,24 @@ bool quicsy_decoder_read_frame(decoder_t* dec, uint8_t* frame_buffer, int64_t* p
142126
if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {
143127
av_packet_unref(av_packet);
144128
continue;
145-
} else if (response < 0) {
129+
} else if (response < 0) {
146130
log("Error while receiving a frame from the decoder");
147131
//FIXME: err_log("Error while receiving a frame from the decoder: %s", av_err2str(response));
148132
return false;
149133
}
150134

151135
av_packet_unref(av_packet);
152136
break;
153-
}
154-
155-
*pts = av_frame->pts;
137+
}
156138

157-
// Set up sws scaler
158-
if (!sws_scaler_ctx)
159-
{
160-
sws_scaler_ctx = sws_getContext(width, height, av_codec_ctx->pix_fmt,
161-
width, height, AV_PIX_FMT_RGB0,
162-
SWS_BILINEAR, NULL, NULL, NULL);
163-
}
139+
*pts = av_frame->pts;
140+
141+
// Set up sws scaler
142+
sws_scaler_ctx = sws_getContext(width, height, av_codec_ctx->pix_fmt,
143+
width, height, AV_PIX_FMT_RGB0,
144+
SWS_BILINEAR, NULL, NULL, NULL);
164145

165-
if (!sws_scaler_ctx) {
146+
if (!sws_scaler_ctx) {
166147
printf("Couldn't initialize sw scaler\n");
167148
return false;
168149
}

decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct decoder_st {
1313
// Private internal state
1414
AVFormatContext* av_format_ctx = NULL;
1515
AVCodecContext* av_codec_ctx = NULL;
16-
int video_stream_index = -1;
16+
int video_stream_index = 0;
1717
AVFrame* av_frame = NULL;
1818
AVPacket* av_packet = NULL;
1919
SwsContext* sws_scaler_ctx = NULL;
File renamed without changes.
File renamed without changes.
File renamed without changes.

tcp_streaming/debug.c

Lines changed: 0 additions & 136 deletions
This file was deleted.

tcp_streaming/debug.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)