OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 * | 9 * |
10 * Based on code from the OggTheora software codec source code, | 10 * Based on code from the OggTheora software codec source code, |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 /*No conversion function needed.*/ | 693 /*No conversion function needed.*/ |
694 static void y4m_convert_null(y4m_input *_y4m, unsigned char *_dst, | 694 static void y4m_convert_null(y4m_input *_y4m, unsigned char *_dst, |
695 unsigned char *_aux) { | 695 unsigned char *_aux) { |
696 (void)_y4m; | 696 (void)_y4m; |
697 (void)_dst; | 697 (void)_dst; |
698 (void)_aux; | 698 (void)_aux; |
699 } | 699 } |
700 | 700 |
701 int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip, | 701 int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip, |
702 int only_420) { | 702 int only_420) { |
703 char buffer[80]; | 703 char buffer[80] = {0}; |
704 int ret; | 704 int ret; |
705 int i; | 705 int i; |
706 /*Read until newline, or 80 cols, whichever happens first.*/ | 706 /*Read until newline, or 80 cols, whichever happens first.*/ |
707 for (i = 0; i < 79; i++) { | 707 for (i = 0; i < 79; i++) { |
708 if (_nskip > 0) { | 708 if (_nskip > 0) { |
709 buffer[i] = *_skip++; | 709 buffer[i] = *_skip++; |
710 _nskip--; | 710 _nskip--; |
711 } else { | 711 } else { |
712 if (!file_read(buffer + i, 1, _fin)) return -1; | 712 if (!file_read(buffer + i, 1, _fin)) return -1; |
713 } | 713 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 } | 971 } |
972 /*The size of the final frame buffers is always computed from the | 972 /*The size of the final frame buffers is always computed from the |
973 destination chroma decimation type.*/ | 973 destination chroma decimation type.*/ |
974 _y4m->dst_buf_sz = _y4m->pic_w * _y4m->pic_h | 974 _y4m->dst_buf_sz = _y4m->pic_w * _y4m->pic_h |
975 + 2 * ((_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_
dec_h) * | 975 + 2 * ((_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_
dec_h) * |
976 ((_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v)
; | 976 ((_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v)
; |
977 if (_y4m->bit_depth == 8) | 977 if (_y4m->bit_depth == 8) |
978 _y4m->dst_buf = (unsigned char *)malloc(_y4m->dst_buf_sz); | 978 _y4m->dst_buf = (unsigned char *)malloc(_y4m->dst_buf_sz); |
979 else | 979 else |
980 _y4m->dst_buf = (unsigned char *)malloc(2 * _y4m->dst_buf_sz); | 980 _y4m->dst_buf = (unsigned char *)malloc(2 * _y4m->dst_buf_sz); |
981 _y4m->aux_buf = (unsigned char *)malloc(_y4m->aux_buf_sz); | 981 |
| 982 if (_y4m->aux_buf_sz > 0) |
| 983 _y4m->aux_buf = (unsigned char *)malloc(_y4m->aux_buf_sz); |
982 return 0; | 984 return 0; |
983 } | 985 } |
984 | 986 |
985 void y4m_input_close(y4m_input *_y4m) { | 987 void y4m_input_close(y4m_input *_y4m) { |
986 free(_y4m->dst_buf); | 988 free(_y4m->dst_buf); |
987 free(_y4m->aux_buf); | 989 free(_y4m->aux_buf); |
988 } | 990 } |
989 | 991 |
990 int y4m_input_fetch_frame(y4m_input *_y4m, FILE *_fin, vpx_image_t *_img) { | 992 int y4m_input_fetch_frame(y4m_input *_y4m, FILE *_fin, vpx_image_t *_img) { |
991 char frame[6]; | 993 char frame[6]; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 c_sz = c_w * c_h; | 1043 c_sz = c_w * c_h; |
1042 _img->stride[PLANE_Y] = _img->stride[PLANE_ALPHA] = | 1044 _img->stride[PLANE_Y] = _img->stride[PLANE_ALPHA] = |
1043 _y4m->pic_w * bytes_per_sample; | 1045 _y4m->pic_w * bytes_per_sample; |
1044 _img->stride[PLANE_U] = _img->stride[PLANE_V] = c_w; | 1046 _img->stride[PLANE_U] = _img->stride[PLANE_V] = c_w; |
1045 _img->planes[PLANE_Y] = _y4m->dst_buf; | 1047 _img->planes[PLANE_Y] = _y4m->dst_buf; |
1046 _img->planes[PLANE_U] = _y4m->dst_buf + pic_sz; | 1048 _img->planes[PLANE_U] = _y4m->dst_buf + pic_sz; |
1047 _img->planes[PLANE_V] = _y4m->dst_buf + pic_sz + c_sz; | 1049 _img->planes[PLANE_V] = _y4m->dst_buf + pic_sz + c_sz; |
1048 _img->planes[PLANE_ALPHA] = _y4m->dst_buf + pic_sz + 2 * c_sz; | 1050 _img->planes[PLANE_ALPHA] = _y4m->dst_buf + pic_sz + 2 * c_sz; |
1049 return 1; | 1051 return 1; |
1050 } | 1052 } |
OLD | NEW |