* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * quant_deadzone code and fixes sponsored by NOA GmbH
*/
/**
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#endif
int max = classes[0];
int prev = 0;
+ const unsigned deadzone = s->quant_deadzone;
+ const unsigned threshold = 2 * deadzone;
av_assert2((((int) blk) & 15) == 0);
for (i = mb_area_start[area]; i < mb_area_start[area + 1]; i++) {
int level = blk[zigzag_scan[i]];
- if (level + 15 > 30U) {
+ if (level + deadzone > threshold) {
bi->sign[i] = (level >> 31) & 1;
/* Weight it and shift down into range, adding for rounding.
* The extra division by a factor of 2^4 reverses the 8x
* expansion of the DCT AND the 2x doubling of the weights. */
level = (FFABS(level) * weight[i] + (1 << (dv_weight_bits + 3))) >>
(dv_weight_bits + 4);
+ if (!level)
+ continue;
bi->mb[i] = level;
if (level > max)
max = level;
return 0;
}
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+#define OFFSET(x) offsetof(DVVideoContext, x)
+static const AVOption dv_options[] = {
+ { "quant_deadzone", "Quantizer dead zone", OFFSET(quant_deadzone), AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024, VE },
+ { NULL },
+};
+
+static const AVClass dvvideo_encode_class = {
+ .class_name = "dvvideo encoder",
+ .item_name = av_default_item_name,
+ .option = dv_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_dvvideo_encoder = {
.name = "dvvideo",
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P,
AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
},
+ .priv_class = &dvvideo_encode_class,
};