| 104 | } |
| 105 | |
| 106 | static int recon_frame_process(PrivData *pd, const AVPacket *pkt) |
| 107 | { |
| 108 | AVFrame *f = pd->frame_recon; |
| 109 | int ret; |
| 110 | |
| 111 | ret = avcodec_receive_frame(pd->enc, f); |
| 112 | if (ret < 0) { |
| 113 | fprintf(stderr, "Error retrieving a reconstructed frame\n"); |
| 114 | return ret; |
| 115 | } |
| 116 | |
| 117 | // the encoder's internal format (in which the reconstructed frames are |
| 118 | // exported) may be different from the user-facing pixel format |
| 119 | if (f->format != pd->enc->pix_fmt) { |
| 120 | if (!pd->scaler) { |
| 121 | pd->scaler = sws_getContext(f->width, f->height, f->format, |
| 122 | f->width, f->height, pd->enc->pix_fmt, |
| 123 | SWS_BITEXACT, NULL, NULL, NULL); |
| 124 | if (!pd->scaler) |
| 125 | return AVERROR(ENOMEM); |
| 126 | } |
| 127 | |
| 128 | ret = sws_scale_frame(pd->scaler, pd->frame, f); |
| 129 | if (ret < 0) { |
| 130 | fprintf(stderr, "Error converting pixel formats\n"); |
| 131 | return ret; |
| 132 | } |
| 133 | |
| 134 | av_frame_unref(f); |
| 135 | f = pd->frame; |
| 136 | } |
| 137 | |
| 138 | ret = frame_hash(&pd->checksums_recon, &pd->nb_checksums_recon, |
| 139 | pkt->pts, f); |
| 140 | av_frame_unref(f); |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | static int process_frame(DecodeContext *dc, AVFrame *frame) |
| 146 | { |
no test coverage detected