Skip to content

Commit 1357bfb

Browse files
committed
bmdplay: Convert to the decoupled decoding API
1 parent 56e9227 commit 1357bfb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bmdplay.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ int main(int argc, char *argv[])
394394
exit(1);
395395
}
396396

397-
if (avcodec_open2(avctx, codec, NULL) < 0) {
397+
if (avcodec_parameters_to_context(avctx, par) < 0 ||
398+
avcodec_open2(avctx, codec, NULL) < 0) {
398399
avcodec_free_context(&avctx);
399400
av_log(NULL, AV_LOG_ERROR, "Codec open failed\n");
400401
exit(1);
@@ -685,6 +686,8 @@ void Player::StopRunning()
685686
void Player::ScheduleNextFrame(bool prerolling)
686687
{
687688
AVPacket pkt;
689+
void *frame;
690+
int ret;
688691

689692
if (serial_fd > 0 && packet_queue_get(&dataqueue, &pkt, 0)) {
690693
if (pkt.data[0] != ' '){
@@ -704,12 +707,13 @@ void Player::ScheduleNextFrame(bool prerolling)
704707
pix,
705708
bmdFrameFlagDefault,
706709
&videoFrame);
707-
void *frame;
708-
int got_picture;
709710
videoFrame->GetBytes(&frame);
710711

711-
avcodec_decode_video2(video.codec, avframe, &got_picture, &pkt);
712-
if (got_picture) {
712+
avcodec_send_packet(video.codec, &pkt);
713+
714+
// TODO: support receiving multiple frames
715+
ret = avcodec_receive_frame(video.codec, avframe);
716+
if (ret >= 0) {
713717
uint8_t *data[4];
714718
int linesize[4];
715719

0 commit comments

Comments
 (0)