<commit_before>#include "atlas/utils/Film.hpp"
#include "atlas/core/Float.hpp"
#include "atlas/core/Log.hpp"

#include <iostream>
#include <fstream>

namespace atlas
{
    namespace utils
    {
        struct Film::FilmImpl
        {
            FilmImpl() :
                hRes(400),
                vRes(400),
                aspectRatio(1.0f),
                gamma(1.0f),
                invGamma(1.0f),
                showOutOfGamut(false)
            {
                frame.resize(hRes * vRes);
            }

            FilmImpl(int h, int v) :
                hRes(h),
                vRes(v),
                aspectRatio(float(h) / v),
                gamma(1.0f),
                invGamma(1.0f),
                showOutOfGamut(false)
            {
                frame.resize(hRes * vRes);
            }


            int hRes;
            int vRes;
            float aspectRatio;
            float gamma;
            float invGamma;
            bool showOutOfGamut;

            FilmFrame frame;
        };

        Film::Film() :
            mImpl(new FilmImpl)
        { }

        Film::Film(int hRes, int vRes) :
            mImpl(new FilmImpl(hRes, vRes))
        { }

        Film::~Film()
        { }

        void Film::setShowOutOfGamut(bool showOutOfGamut)
        {
            mImpl->showOutOfGamut = showOutOfGamut;
        }

        void Film::setGamma(float gamma)
        {
            mImpl->gamma = gamma;
        }

        int Film::getHRes() const
        {
            return mImpl->hRes;
        }

        int Film::getVRes() const
        {
            return mImpl->vRes;
        }

        float Film::getAspectRatio() const
        {
            return mImpl->aspectRatio;
        }

        const FilmFrame& Film::getCurrentFrame() const
        {
            return mImpl->frame;
        }

        void Film::drawPixel(int x, int y, RGBColour const& pixel)
        {
            USING_ATLAS_CORE_NS;

            RGBColour mappedColour = (mImpl->showOutOfGamut) ?
                clampToColour(pixel) :
                maxToOne(pixel);

            if (!areEqual(1.0f, mImpl->gamma))
            {
                mappedColour = powc(mappedColour, mImpl->invGamma);
            }

            int index = x * mImpl->hRes + y;
            mImpl->frame[index] = mappedColour;
        }

        void Film::saveToPPM(std::string const& frameName) const
        {
            typedef char RawPixel;

            std::ofstream fileStream(frameName, std::ios::binary | std::ios::out);
            if (fileStream.is_open())
            {
                fileStream << "P6\n" << mImpl->hRes << " " << mImpl->vRes <<
                    "\n255\n";
                RawPixel* pixel = new RawPixel[3];
                for (auto &pix : mImpl->frame)
                {
                    pixel[0] = RawPixel(pix.r * 255);
                    pixel[1] = RawPixel(pix.g * 255);
                    pixel[2] = RawPixel(pix.b * 255);

                    fileStream.write(pixel, 3);
                }
                fileStream.close();
                delete[] pixel;
            }
            else
            {
                ERROR_LOG("Could not open file " + frameName);
            }
        }

        RGBColour& Film::operator()(int x, int y)
        {
            int index = x * mImpl->hRes + y;
            return mImpl->frame[index];
        }
    }
}<commit_msg>[brief] Fixes header inclusion for core namespace macro.<commit_after>#include "atlas/utils/Film.hpp"
#include "atlas/core/Float.hpp"
#include "atlas/core/Log.hpp"
#include "atlas/core/Core.hpp"

#include <iostream>
#include <fstream>

namespace atlas
{
    namespace utils
    {
        struct Film::FilmImpl
        {
            FilmImpl() :
                hRes(400),
                vRes(400),
                aspectRatio(1.0f),
                gamma(1.0f),
                invGamma(1.0f),
                showOutOfGamut(false)
            {
                frame.resize(hRes * vRes);
            }

            FilmImpl(int h, int v) :
                hRes(h),
                vRes(v),
                aspectRatio(float(h) / v),
                gamma(1.0f),
                invGamma(1.0f),
                showOutOfGamut(false)
            {
                frame.resize(hRes * vRes);
            }


            int hRes;
            int vRes;
            float aspectRatio;
            float gamma;
            float invGamma;
            bool showOutOfGamut;

            FilmFrame frame;
        };

        Film::Film() :
            mImpl(new FilmImpl)
        { }

        Film::Film(int hRes, int vRes) :
            mImpl(new FilmImpl(hRes, vRes))
        { }

        Film::~Film()
        { }

        void Film::setShowOutOfGamut(bool showOutOfGamut)
        {
            mImpl->showOutOfGamut = showOutOfGamut;
        }

        void Film::setGamma(float gamma)
        {
            mImpl->gamma = gamma;
        }

        int Film::getHRes() const
        {
            return mImpl->hRes;
        }

        int Film::getVRes() const
        {
            return mImpl->vRes;
        }

        float Film::getAspectRatio() const
        {
            return mImpl->aspectRatio;
        }

        const FilmFrame& Film::getCurrentFrame() const
        {
            return mImpl->frame;
        }

        void Film::drawPixel(int x, int y, RGBColour const& pixel)
        {
            USING_ATLAS_CORE_NS;

            RGBColour mappedColour = (mImpl->showOutOfGamut) ?
                clampToColour(pixel) :
                maxToOne(pixel);

            if (!areEqual(1.0f, mImpl->gamma))
            {
                mappedColour = powc(mappedColour, mImpl->invGamma);
            }

            int index = x * mImpl->hRes + y;
            mImpl->frame[index] = mappedColour;
        }

        void Film::saveToPPM(std::string const& frameName) const
        {
            typedef char RawPixel;

            std::ofstream fileStream(frameName, std::ios::binary | std::ios::out);
            if (fileStream.is_open())
            {
                fileStream << "P6\n" << mImpl->hRes << " " << mImpl->vRes <<
                    "\n255\n";
                RawPixel* pixel = new RawPixel[3];
                for (auto &pix : mImpl->frame)
                {
                    pixel[0] = RawPixel(pix.r * 255);
                    pixel[1] = RawPixel(pix.g * 255);
                    pixel[2] = RawPixel(pix.b * 255);

                    fileStream.write(pixel, 3);
                }
                fileStream.close();
                delete[] pixel;
            }
            else
            {
                ERROR_LOG("Could not open file " + frameName);
            }
        }

        RGBColour& Film::operator()(int x, int y)
        {
            int index = x * mImpl->hRes + y;
            return mImpl->frame[index];
        }
    }
}
{'fraction_non_alphanumeric': 0.11106271777003485, 'fraction_numerical': 0.010452961672473868, 'mean_word_length': 1.169080604534005, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5496308', 'n_tokens_mistral': 2138, 'n_tokens_neox': 1985, 'n_words': 369}