mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
generic-pc: reduce ffmpeg warnings
This commit is contained in:
@@ -457,11 +457,25 @@ void cAudio::run()
|
|||||||
int gotframe = 0;
|
int gotframe = 0;
|
||||||
if (av_read_frame(avfc, &avpkt) < 0)
|
if (av_read_frame(avfc, &avpkt) < 0)
|
||||||
break;
|
break;
|
||||||
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,37,100)
|
||||||
avcodec_decode_audio4(c, frame, &gotframe, &avpkt);
|
avcodec_decode_audio4(c, frame, &gotframe, &avpkt);
|
||||||
|
#else
|
||||||
|
int ret = avcodec_send_packet(c, &avpkt);
|
||||||
|
if (ret != 0 && ret != AVERROR(EAGAIN)) {
|
||||||
|
hal_info("%s: avcodec_send_packet %d\n", __func__, ret);
|
||||||
|
}else {
|
||||||
|
ret = avcodec_receive_frame(c, frame);
|
||||||
|
if (ret != 0 && ret != AVERROR(EAGAIN)) {
|
||||||
|
hal_info("%s: avcodec_send_packet %d\n", __func__, ret);
|
||||||
|
}else {
|
||||||
|
gotframe = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gotframe && thread_started) {
|
if (gotframe && thread_started) {
|
||||||
int out_linesize;
|
int out_linesize;
|
||||||
obuf_sz = av_rescale_rnd(swr_get_delay(swr, p->sample_rate) +
|
obuf_sz = av_rescale_rnd(swr_get_delay(swr, p->sample_rate) + frame->nb_samples, o_sr, p->sample_rate, AV_ROUND_UP);
|
||||||
frame->nb_samples, o_sr, p->sample_rate, AV_ROUND_UP);
|
|
||||||
if (obuf_sz > obuf_sz_max) {
|
if (obuf_sz > obuf_sz_max) {
|
||||||
hal_info("obuf_sz: %d old: %d\n", obuf_sz, obuf_sz_max);
|
hal_info("obuf_sz: %d old: %d\n", obuf_sz, obuf_sz_max);
|
||||||
av_free(obuf);
|
av_free(obuf);
|
||||||
@@ -481,8 +495,7 @@ void cAudio::run()
|
|||||||
curr_pts = frame->best_effort_timestamp;
|
curr_pts = frame->best_effort_timestamp;
|
||||||
#endif
|
#endif
|
||||||
hal_debug("%s: pts 0x%" PRIx64 " %3f\n", __func__, curr_pts, curr_pts/90000.0);
|
hal_debug("%s: pts 0x%" PRIx64 " %3f\n", __func__, curr_pts, curr_pts/90000.0);
|
||||||
int o_buf_sz = av_samples_get_buffer_size(&out_linesize, o_ch,
|
int o_buf_sz = av_samples_get_buffer_size(&out_linesize, o_ch, obuf_sz, AV_SAMPLE_FMT_S16, 1);
|
||||||
obuf_sz, AV_SAMPLE_FMT_S16, 1);
|
|
||||||
if (o_buf_sz > 0)
|
if (o_buf_sz > 0)
|
||||||
ao_play(adevice, (char *)obuf, o_buf_sz);
|
ao_play(adevice, (char *)obuf, o_buf_sz);
|
||||||
}
|
}
|
||||||
|
@@ -250,10 +250,10 @@ bool cVideo::ShowPicture(const char *fname)
|
|||||||
buf_out = 0;
|
buf_out = 0;
|
||||||
still_m.unlock();
|
still_m.unlock();
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i = 0;
|
||||||
int stream_id = -1;
|
int stream_id = -1;
|
||||||
int got_frame = 0;
|
int got_frame = 0;
|
||||||
int len;
|
int av_ret = 0;
|
||||||
AVFormatContext *avfc = NULL;
|
AVFormatContext *avfc = NULL;
|
||||||
AVCodecContext *c = NULL;
|
AVCodecContext *c = NULL;
|
||||||
AVCodecParameters *p = NULL;
|
AVCodecParameters *p = NULL;
|
||||||
@@ -296,14 +296,29 @@ bool cVideo::ShowPicture(const char *fname)
|
|||||||
hal_info("%s: av_read_frame < 0\n", __func__);
|
hal_info("%s: av_read_frame < 0\n", __func__);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
len = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,37,100)
|
||||||
if (len < 0) {
|
av_ret = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
|
||||||
hal_info("%s: avcodec_decode_video2 %d\n", __func__, len);
|
if (av_ret < 0) {
|
||||||
|
hal_info("%s: avcodec_decode_video2 %d\n", __func__, av_ret);
|
||||||
av_packet_unref(&avpkt);
|
av_packet_unref(&avpkt);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
if (avpkt.size > len)
|
if (avpkt.size > av_ret)
|
||||||
hal_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, len);
|
hal_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, av_ret);
|
||||||
|
#else
|
||||||
|
av_ret = avcodec_send_packet(c, &avpkt);
|
||||||
|
if (av_ret != 0 && av_ret != AVERROR(EAGAIN)) {
|
||||||
|
hal_info("%s: avcodec_send_packet %d\n", __func__, av_ret);
|
||||||
|
av_packet_unref(&avpkt);
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
av_ret = avcodec_receive_frame(c, frame);
|
||||||
|
if (av_ret != 0 && av_ret != AVERROR(EAGAIN))
|
||||||
|
goto out_free;
|
||||||
|
|
||||||
|
got_frame = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (got_frame) {
|
if (got_frame) {
|
||||||
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
||||||
struct SwsContext *convert = sws_getContext(c->width, c->height, c->pix_fmt,
|
struct SwsContext *convert = sws_getContext(c->width, c->height, c->pix_fmt,
|
||||||
@@ -473,6 +488,7 @@ void cVideo::run(void)
|
|||||||
|
|
||||||
time_t warn_r = 0; /* last read error */
|
time_t warn_r = 0; /* last read error */
|
||||||
time_t warn_d = 0; /* last decode error */
|
time_t warn_d = 0; /* last decode error */
|
||||||
|
int av_ret = 0;
|
||||||
|
|
||||||
bufpos = 0;
|
bufpos = 0;
|
||||||
buf_num = 0;
|
buf_num = 0;
|
||||||
@@ -539,17 +555,32 @@ void cVideo::run(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int got_frame = 0;
|
int got_frame = 0;
|
||||||
int len = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,37,100)
|
||||||
if (len < 0) {
|
av_ret = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
|
||||||
|
if (av_ret < 0) {
|
||||||
if (warn_d - time(NULL) > 4) {
|
if (warn_d - time(NULL) > 4) {
|
||||||
hal_info("%s: avcodec_decode_video2 %d\n", __func__, len);
|
hal_info("%s: avcodec_decode_video2 %d\n", __func__, av_ret);
|
||||||
warn_d = time(NULL);
|
warn_d = time(NULL);
|
||||||
}
|
}
|
||||||
av_packet_unref(&avpkt);
|
av_packet_unref(&avpkt);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (avpkt.size > len)
|
if (avpkt.size > av_ret)
|
||||||
hal_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, len);
|
hal_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, av_ret);
|
||||||
|
#else
|
||||||
|
av_ret = avcodec_send_packet(c, &avpkt);
|
||||||
|
if (av_ret != 0 && av_ret != AVERROR(EAGAIN)) {
|
||||||
|
if (warn_d - time(NULL) > 4) {
|
||||||
|
hal_info("%s: avcodec_send_packet %d\n", __func__, av_ret);
|
||||||
|
warn_d = time(NULL);
|
||||||
|
}
|
||||||
|
av_packet_unref(&avpkt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
av_ret = avcodec_receive_frame(c, frame);
|
||||||
|
if (!av_ret)
|
||||||
|
got_frame = 1;
|
||||||
|
#endif
|
||||||
still_m.lock();
|
still_m.lock();
|
||||||
if (got_frame && ! stillpicture) {
|
if (got_frame && ! stillpicture) {
|
||||||
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
||||||
|
Reference in New Issue
Block a user