正在显示
4 个修改的文件
包含
23 行增加
和
6 行删除
| @@ -157,7 +157,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -157,7 +157,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 157 | enc_ctx->height = _nOutputHeight; | 157 | enc_ctx->height = _nOutputHeight; |
| 158 | enc_ctx->width = _nOutputWidth; | 158 | enc_ctx->width = _nOutputWidth; |
| 159 | enc_ctx->sample_aspect_ratio.den = 1; | 159 | enc_ctx->sample_aspect_ratio.den = 1; |
| 160 | - enc_ctx->sample_aspect_ratio.num = 1; | 160 | + enc_ctx->sample_aspect_ratio.num = 0; |
| 161 | /* take first format from list of supported formats */ | 161 | /* take first format from list of supported formats */ |
| 162 | enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P; | 162 | enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P; |
| 163 | /* video time_base can be set to whatever is handy and supported by encoder */ | 163 | /* video time_base can be set to whatever is handy and supported by encoder */ |
| @@ -169,6 +169,11 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -169,6 +169,11 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 169 | enc_ctx->qmin = 10; | 169 | enc_ctx->qmin = 10; |
| 170 | enc_ctx->qmax = 30; | 170 | enc_ctx->qmax = 30; |
| 171 | enc_ctx->qcompress = 0.6; | 171 | enc_ctx->qcompress = 0.6; |
| 172 | + | ||
| 173 | + AVDictionary * d = NULL; | ||
| 174 | + char *k = av_strdup("preset"); // if your strings are already allocated, | ||
| 175 | + char *v = av_strdup("ultrafast"); // you can avoid copying them like this | ||
| 176 | + av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); | ||
| 172 | /* Third parameter can be used to pass settings to encoder */ | 177 | /* Third parameter can be used to pass settings to encoder */ |
| 173 | ret = avcodec_open2(enc_ctx, encoder, NULL); | 178 | ret = avcodec_open2(enc_ctx, encoder, NULL); |
| 174 | if (ret < 0) { | 179 | if (ret < 0) { |
| @@ -292,13 +297,14 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -292,13 +297,14 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 292 | if (!pSrcFrame){ | 297 | if (!pSrcFrame){ |
| 293 | return 0; | 298 | return 0; |
| 294 | } | 299 | } |
| 300 | + | ||
| 295 | for (int i = 0; i < pSrcFrame->height; i++) { | 301 | for (int i = 0; i < pSrcFrame->height; i++) { |
| 296 | - memcpy(pDstFrame->data[0] + (y + i)*pDstFrame->linesize[0] + x, pSrcFrame->data[0] + i * pSrcFrame->linesize[0], pSrcFrame->linesize[0]); | 302 | + memcpy(pDstFrame->data[0] + (y + i)*pDstFrame->linesize[0] + x, pSrcFrame->data[0] + i * pSrcFrame->linesize[0], pSrcFrame->linesize[0]>0 ? pSrcFrame->linesize[0] : -pSrcFrame->linesize[0]); |
| 297 | } | 303 | } |
| 298 | 304 | ||
| 299 | for (int i = 0; i < pSrcFrame->height / 2; i++){ | 305 | for (int i = 0; i < pSrcFrame->height / 2; i++){ |
| 300 | - memcpy(pDstFrame->data[1] + (y / 2)*pDstFrame->linesize[1] + x / 2, pSrcFrame->data[1] + i * pSrcFrame->linesize[1], pSrcFrame->linesize[1]); | ||
| 301 | - memcpy(pDstFrame->data[2] + (y / 2)*pDstFrame->linesize[2] + x / 2, pSrcFrame->data[2] + i * pSrcFrame->linesize[2], pSrcFrame->linesize[2]); | 306 | + memcpy(pDstFrame->data[1] + (y / 2 + i)*pDstFrame->linesize[1] + x / 2, pSrcFrame->data[1] + i * pSrcFrame->linesize[1], pSrcFrame->linesize[1]>0 ? pSrcFrame->linesize[1] : -pSrcFrame->linesize[1]); |
| 307 | + memcpy(pDstFrame->data[2] + (y / 2 + i)*pDstFrame->linesize[2] + x / 2, pSrcFrame->data[2] + i * pSrcFrame->linesize[2], pSrcFrame->linesize[2]>0 ? pSrcFrame->linesize[2] : -pSrcFrame->linesize[2]); | ||
| 302 | } | 308 | } |
| 303 | return 0; | 309 | return 0; |
| 304 | } | 310 | } |
| @@ -310,6 +316,8 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -310,6 +316,8 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 310 | int nDstSize = avpicture_get_size(AV_PIX_FMT_YUV420P,_nOutputWidth, _nOutputHeight); | 316 | int nDstSize = avpicture_get_size(AV_PIX_FMT_YUV420P,_nOutputWidth, _nOutputHeight); |
| 311 | uint8_t *dstbuf = new uint8_t[nDstSize]; | 317 | uint8_t *dstbuf = new uint8_t[nDstSize]; |
| 312 | avpicture_fill((AVPicture*)pDstFrame, dstbuf, AV_PIX_FMT_YUV420P, _nOutputWidth, _nOutputHeight); | 318 | avpicture_fill((AVPicture*)pDstFrame, dstbuf, AV_PIX_FMT_YUV420P, _nOutputWidth, _nOutputHeight); |
| 319 | + memset(dstbuf, 0x80, nDstSize); | ||
| 320 | + | ||
| 313 | if (decoders_got_frame.size() == 2){ | 321 | if (decoders_got_frame.size() == 2){ |
| 314 | fillDestFrame(pDstFrame, decoders_got_frame[0]->_cur_v_frame, 0, decoders_got_frame[0]->_media_role == mr_teacher ? 0 : 240); | 322 | fillDestFrame(pDstFrame, decoders_got_frame[0]->_cur_v_frame, 0, decoders_got_frame[0]->_media_role == mr_teacher ? 0 : 240); |
| 315 | decoders_got_frame[0]->free_cur_v_frame(); | 323 | decoders_got_frame[0]->free_cur_v_frame(); |
| @@ -20,6 +20,7 @@ int CVideoDecoder::add(media_info &info) | @@ -20,6 +20,7 @@ int CVideoDecoder::add(media_info &info) | ||
| 20 | _uid = info.uid; | 20 | _uid = info.uid; |
| 21 | } | 21 | } |
| 22 | _info.push_back(info); | 22 | _info.push_back(info); |
| 23 | + _rotate = info.rotate; | ||
| 23 | 24 | ||
| 24 | int ret; | 25 | int ret; |
| 25 | 26 | ||
| @@ -300,7 +301,14 @@ int CVideoDecoder::filter_encode_write_frame(AVFrame *frame, unsigned int stream | @@ -300,7 +301,14 @@ int CVideoDecoder::filter_encode_write_frame(AVFrame *frame, unsigned int stream | ||
| 300 | } | 301 | } |
| 301 | 302 | ||
| 302 | filt_frame->pict_type = AV_PICTURE_TYPE_NONE; | 303 | filt_frame->pict_type = AV_PICTURE_TYPE_NONE; |
| 303 | - //todo: callback filted frame | 304 | + if (_rotate == 180) { |
| 305 | + filt_frame->data[0] += filt_frame->linesize[0] * (filt_frame->height - 1); | ||
| 306 | + filt_frame->linesize[0] = -filt_frame->linesize[0]; | ||
| 307 | + filt_frame->data[1] += filt_frame->linesize[1] * (filt_frame->height / 2 - 1); | ||
| 308 | + filt_frame->linesize[1] = -filt_frame->linesize[1]; | ||
| 309 | + filt_frame->data[2] += filt_frame->linesize[2] * (filt_frame->height / 2 - 1); | ||
| 310 | + filt_frame->linesize[2] = -filt_frame->linesize[2]; | ||
| 311 | + } | ||
| 304 | _decoded_frames.push_back(filt_frame); | 312 | _decoded_frames.push_back(filt_frame); |
| 305 | } | 313 | } |
| 306 | 314 |
| @@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
| 40 | <Filter>源文件</Filter> | 40 | <Filter>源文件</Filter> |
| 41 | </ClCompile> | 41 | </ClCompile> |
| 42 | <ClCompile Include="merge_pip.cpp"> | 42 | <ClCompile Include="merge_pip.cpp"> |
| 43 | - <Filter>资源文件</Filter> | 43 | + <Filter>源文件</Filter> |
| 44 | </ClCompile> | 44 | </ClCompile> |
| 45 | </ItemGroup> | 45 | </ItemGroup> |
| 46 | <ItemGroup> | 46 | <ItemGroup> |
-
请 注册 或 登录 后发表评论