- Timestamp:
- Mar 5, 2019 6:23:02 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/converter_libswscale.c
r5306 r5939 34 34 pjmedia_frame *src_frame, 35 35 pjmedia_frame *dst_frame); 36 static pj_status_t libswscale_conv_convert2( 37 pjmedia_converter *converter, 38 pjmedia_frame *src_frame, 39 const pjmedia_rect_size *src_frame_size, 40 const pjmedia_coord *src_pos, 41 pjmedia_frame *dst_frame, 42 const pjmedia_rect_size *dst_frame_size, 43 const pjmedia_coord *dst_pos, 44 pjmedia_converter_convert_setting 45 *param); 36 46 static void libswscale_conv_destroy(pjmedia_converter *converter); 37 47 … … 60 70 { 61 71 &libswscale_conv_convert, 62 &libswscale_conv_destroy 72 &libswscale_conv_destroy, 73 &libswscale_conv_convert2 63 74 }; 64 75 … … 165 176 } 166 177 178 static pj_status_t libswscale_conv_convert2( 179 pjmedia_converter *converter, 180 pjmedia_frame *src_frame, 181 const pjmedia_rect_size *src_frame_size, 182 const pjmedia_coord *src_pos, 183 pjmedia_frame *dst_frame, 184 const pjmedia_rect_size *dst_frame_size, 185 const pjmedia_coord *dst_pos, 186 pjmedia_converter_convert_setting 187 *param) 188 { 189 struct ffmpeg_converter *fcv = (struct ffmpeg_converter*)converter; 190 struct fmt_info *src = &fcv->src, 191 *dst = &fcv->dst; 192 int h; 193 unsigned j; 194 pjmedia_rect_size orig_src_size; 195 pjmedia_rect_size orig_dst_size; 196 197 PJ_UNUSED_ARG(param); 198 199 /* Save original conversion sizes */ 200 orig_src_size = src->apply_param.size; 201 orig_dst_size = dst->apply_param.size; 202 203 /* Set the first act buffer from src frame, and overwrite size. */ 204 src->apply_param.buffer = src_frame->buf; 205 src->apply_param.size = *src_frame_size; 206 (*src->fmt_info->apply_fmt)(src->fmt_info, &src->apply_param); 207 208 /* Set the last act buffer from dst frame, and overwrite size. */ 209 dst->apply_param.buffer = dst_frame->buf; 210 dst->apply_param.size = *dst_frame_size; 211 (*dst->fmt_info->apply_fmt)(dst->fmt_info, &dst->apply_param); 212 213 for (j = 0; j < src->fmt_info->plane_cnt; ++j) { 214 pjmedia_video_apply_fmt_param *ap = &src->apply_param; 215 int y = src_pos->y * ap->plane_bytes[j] / ap->strides[j] / 216 ap->size.h; 217 ap->planes[j] += y * ap->strides[j] + 218 src_pos->x * ap->strides[j] / ap->size.w; 219 } 220 221 for (j = 0; j < dst->fmt_info->plane_cnt; ++j) { 222 pjmedia_video_apply_fmt_param *ap = &dst->apply_param; 223 int y = dst_pos->y * ap->plane_bytes[j] / ap->strides[j] / 224 ap->size.h; 225 ap->planes[j] += y * ap->strides[j] + 226 dst_pos->x * ap->strides[j] / ap->size.w; 227 } 228 229 /* Return back the original conversion size */ 230 src->apply_param.size = orig_src_size; 231 dst->apply_param.size = orig_dst_size; 232 233 h = sws_scale(fcv->sws_ctx, 234 (const uint8_t* const *)src->apply_param.planes, 235 src->apply_param.strides, 236 0, src->apply_param.size.h, 237 dst->apply_param.planes, dst->apply_param.strides); 238 239 //sws_scale() return value can't be trusted? There are cases when 240 //sws_scale() returns zero but conversion seems to work okay. 241 //return h==(int)dst->apply_param.size.h ? PJ_SUCCESS : PJ_EUNKNOWN; 242 PJ_UNUSED_ARG(h); 243 244 return PJ_SUCCESS; 245 } 246 167 247 static void libswscale_conv_destroy(pjmedia_converter *converter) 168 248 {
Note: See TracChangeset
for help on using the changeset viewer.