| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Interface to xvidcore for mpeg4 encoding | 2 * Interface to xvidcore for mpeg4 encoding |
| 3 * Copyright (c) 2004 Adam Thayer <krevnik@comcast.net> | 3 * Copyright (c) 2004 Adam Thayer <krevnik@comcast.net> |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * Interface to xvidcore for MPEG-4 compliant encoding. | 24 * Interface to xvidcore for MPEG-4 compliant encoding. |
| 25 * @author Adam Thayer (krevnik@comcast.net) | 25 * @author Adam Thayer (krevnik@comcast.net) |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 /* needed for mkstemp() */ | 28 /* needed for mkstemp() */ |
| 29 #define _XOPEN_SOURCE 600 | 29 #define _XOPEN_SOURCE 600 |
| 30 | 30 |
| 31 #include <xvid.h> | 31 #include <xvid.h> |
| 32 #include <unistd.h> | 32 #include <unistd.h> |
| 33 #include "avcodec.h" | 33 #include "avcodec.h" |
| 34 #include "libavutil/cpu.h" |
| 34 #include "libavutil/intreadwrite.h" | 35 #include "libavutil/intreadwrite.h" |
| 35 #include "libxvid_internal.h" | 36 #include "libxvid_internal.h" |
| 36 #if !HAVE_MKSTEMP | 37 #if !HAVE_MKSTEMP |
| 37 #include <fcntl.h> | 38 #include <fcntl.h> |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * Buffer management macros. | 42 * Buffer management macros. |
| 42 */ | 43 */ |
| 43 #define BUFFER_SIZE 1024 | 44 #define BUFFER_SIZE 1024 |
| 44 #define BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x)) | 45 #define BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x)) |
| 45 #define BUFFER_CAT(x) (&((x)[strlen(x)])) | 46 #define BUFFER_CAT(x) (&((x)[strlen(x)])) |
| 46 | 47 |
| 47 /* For PPC Use */ | |
| 48 int has_altivec(void); | |
| 49 | |
| 50 /** | 48 /** |
| 51 * Structure for the private Xvid context. | 49 * Structure for the private Xvid context. |
| 52 * This stores all the private context for the codec. | 50 * This stores all the private context for the codec. |
| 53 */ | 51 */ |
| 54 struct xvid_context { | 52 struct xvid_context { |
| 55 void *encoder_handle; /**< Handle for Xvid encoder */ | 53 void *encoder_handle; /**< Handle for Xvid encoder */ |
| 56 int xsize; /**< Frame x size */ | 54 int xsize; /**< Frame x size */ |
| 57 int ysize; /**< Frame y size */ | 55 int ysize; /**< Frame y size */ |
| 58 int vop_flags; /**< VOP flags for Xvid encoder */ | 56 int vop_flags; /**< VOP flags for Xvid encoder */ |
| 59 int vol_flags; /**< VOL flags for Xvid encoder */ | 57 int vol_flags; /**< VOL flags for Xvid encoder */ |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 x->me_flags |= XVID_ME_QUARTERPELREFINE8; | 206 x->me_flags |= XVID_ME_QUARTERPELREFINE8; |
| 209 } | 207 } |
| 210 | 208 |
| 211 memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init)); | 209 memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init)); |
| 212 xvid_gbl_init.version = XVID_VERSION; | 210 xvid_gbl_init.version = XVID_VERSION; |
| 213 xvid_gbl_init.debug = 0; | 211 xvid_gbl_init.debug = 0; |
| 214 | 212 |
| 215 #if ARCH_PPC | 213 #if ARCH_PPC |
| 216 /* Xvid's PPC support is borked, use libavcodec to detect */ | 214 /* Xvid's PPC support is borked, use libavcodec to detect */ |
| 217 #if HAVE_ALTIVEC | 215 #if HAVE_ALTIVEC |
| 218 if( has_altivec() ) { | 216 if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { |
| 219 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC; | 217 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC; |
| 220 } else | 218 } else |
| 221 #endif | 219 #endif |
| 222 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE; | 220 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE; |
| 223 #else | 221 #else |
| 224 /* Xvid can detect on x86 */ | 222 /* Xvid can detect on x86 */ |
| 225 xvid_gbl_init.cpu_flags = 0; | 223 xvid_gbl_init.cpu_flags = 0; |
| 226 #endif | 224 #endif |
| 227 | 225 |
| 228 /* Initialize */ | 226 /* Initialize */ |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 CODEC_ID_MPEG4, | 816 CODEC_ID_MPEG4, |
| 819 sizeof(struct xvid_context), | 817 sizeof(struct xvid_context), |
| 820 xvid_encode_init, | 818 xvid_encode_init, |
| 821 xvid_encode_frame, | 819 xvid_encode_frame, |
| 822 xvid_encode_close, | 820 xvid_encode_close, |
| 823 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, | 821 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, |
| 824 .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), | 822 .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), |
| 825 }; | 823 }; |
| 826 | 824 |
| 827 #endif /* CONFIG_LIBXVID_ENCODER */ | 825 #endif /* CONFIG_LIBXVID_ENCODER */ |
| OLD | NEW |