Skip to content

Commit

Permalink
bmdplay: Convert to the decoupled decoding API
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed Mar 12, 2017
1 parent 56e9227 commit 1357bfb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bmdplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ int main(int argc, char *argv[])
exit(1);
}

if (avcodec_open2(avctx, codec, NULL) < 0) {
if (avcodec_parameters_to_context(avctx, par) < 0 ||
avcodec_open2(avctx, codec, NULL) < 0) {
avcodec_free_context(&avctx);
av_log(NULL, AV_LOG_ERROR, "Codec open failed\n");
exit(1);
Expand Down Expand Up @@ -685,6 +686,8 @@ void Player::StopRunning()
void Player::ScheduleNextFrame(bool prerolling)
{
AVPacket pkt;
void *frame;
int ret;

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

avcodec_decode_video2(video.codec, avframe, &got_picture, &pkt);
if (got_picture) {
avcodec_send_packet(video.codec, &pkt);

// TODO: support receiving multiple frames
ret = avcodec_receive_frame(video.codec, avframe);
if (ret >= 0) {
uint8_t *data[4];
int linesize[4];

Expand Down

0 comments on commit 1357bfb

Please sign in to comment.