| | |
| | | cvbridge *bridge; |
| | | } PicEncoder; |
| | | |
| | | void *CreateEncoder(const int w, const int h, const int fps, const int br, const int scale_flag, const int gi){ |
| | | void *CreateEncoder(const int w, const int h, const int fps, const int br, |
| | | const int scale_flag, const int gi){ |
| | | |
| | | PicEncoder *e = (PicEncoder*)malloc(sizeof(PicEncoder)); |
| | | e->enc = NULL; |
| | |
| | | PicEncoder *e = (PicEncoder*)hdl; |
| | | auto ctx = e->enc->getCodecContext(); |
| | | |
| | | AVPixelFormat pix_fmt = AV_PIX_FMT_BGR24; |
| | | if (e->bridge == NULL){ |
| | | e->bridge = new cvbridge( |
| | | w, h, AV_PIX_FMT_BGR24, |
| | | e->w, e->h, ctx->pix_fmt, e->flag); |
| | | } |
| | | |
| | | AVFrame *frame = cvbridge::fillFrame(in, w, h, pix_fmt); |
| | | AVFrame *bgr_frame = cvbridge::fillFrame(in, w, h, AV_PIX_FMT_BGR24); |
| | | AVFrame *frame = e->bridge->convert2Frame(bgr_frame); |
| | | av_frame_free(&bgr_frame); |
| | | |
| | | AVPacket *pkt = av_packet_alloc(); |
| | | |
| | | auto flag = e->enc->encode(pkt, frame); |